MSP430 DriverLib for MSP430i2xx Devices  2.91.13.01
mpy.h
1 //*****************************************************************************
2 //
3 // mpy.h - Driver for the MPY Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_MPY_H__
8 #define __MSP430WARE_MPY_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_MPY__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 
27 //*****************************************************************************
28 //
29 // The following are values that can be passed to the multiplicationType
30 // parameter for functions: MPY_setOperandOne8Bit(), and
31 // MPY_setOperandOne16Bit().
32 //
33 //*****************************************************************************
34 #define MPY_MULTIPLY_UNSIGNED (0x00)
35 #define MPY_MULTIPLY_SIGNED (0x02)
36 #define MPY_MULTIPLYACCUMULATE_UNSIGNED (0x04)
37 #define MPY_MULTIPLYACCUMULATE_SIGNED (0x06)
38 
39 //*****************************************************************************
40 //
41 // Prototypes for the APIs.
42 //
43 //*****************************************************************************
44 
45 //*****************************************************************************
46 //
47 //! \brief Sets an 8-bit value into operand 1.
48 //!
49 //! This function sets the first operand for multiplication and determines what
50 //! type of operation should be performed. Once the second operand is set, then
51 //! the operation will begin.
52 //!
53 //! \param multiplicationType is the type of multiplication to perform once the
54 //! second operand is set.
55 //! Valid values are:
56 //! - \b MPY_MULTIPLY_UNSIGNED
57 //! - \b MPY_MULTIPLY_SIGNED
58 //! - \b MPY_MULTIPLYACCUMULATE_UNSIGNED
59 //! - \b MPY_MULTIPLYACCUMULATE_SIGNED
60 //! \param operand is the 8-bit value to load into the 1st operand.
61 //!
62 //! \return None
63 //
64 //*****************************************************************************
65 extern void MPY_setOperandOne8Bit(uint8_t multiplicationType,
66  uint8_t operand);
67 
68 //*****************************************************************************
69 //
70 //! \brief Sets an 16-bit value into operand 1.
71 //!
72 //! This function sets the first operand for multiplication and determines what
73 //! type of operation should be performed. Once the second operand is set, then
74 //! the operation will begin.
75 //!
76 //! \param multiplicationType is the type of multiplication to perform once the
77 //! second operand is set.
78 //! Valid values are:
79 //! - \b MPY_MULTIPLY_UNSIGNED
80 //! - \b MPY_MULTIPLY_SIGNED
81 //! - \b MPY_MULTIPLYACCUMULATE_UNSIGNED
82 //! - \b MPY_MULTIPLYACCUMULATE_SIGNED
83 //! \param operand is the 16-bit value to load into the 1st operand.
84 //!
85 //! \return None
86 //
87 //*****************************************************************************
88 extern void MPY_setOperandOne16Bit(uint8_t multiplicationType,
89  uint16_t operand);
90 
91 //*****************************************************************************
92 //
93 //! \brief Sets an 8-bit value into operand 2, which starts the multiplication.
94 //!
95 //! This function sets the second operand of the multiplication operation and
96 //! starts the operation.
97 //!
98 //! \param operand is the 8-bit value to load into the 2nd operand.
99 //!
100 //! \return None
101 //
102 //*****************************************************************************
103 extern void MPY_setOperandTwo8Bit(uint8_t operand);
104 
105 //*****************************************************************************
106 //
107 //! \brief Sets an 16-bit value into operand 2, which starts the
108 //! multiplication.
109 //!
110 //! This function sets the second operand of the multiplication operation and
111 //! starts the operation.
112 //!
113 //! \param operand is the 16-bit value to load into the 2nd operand.
114 //!
115 //! \return None
116 //
117 //*****************************************************************************
118 extern void MPY_setOperandTwo16Bit(uint16_t operand);
119 
120 //*****************************************************************************
121 //
122 //! \brief Returns an 64-bit result of the last multiplication operation.
123 //!
124 //! This function returns all 64 bits of the result registers
125 //!
126 //!
127 //! \return The 64-bit result is returned as a uint64_t type
128 //
129 //*****************************************************************************
130 extern uint32_t MPY_getResult(void);
131 
132 //*****************************************************************************
133 //
134 //! \brief Returns the Sum Extension of the last multiplication operation.
135 //!
136 //! This function returns the Sum Extension of the MPY module, which either
137 //! gives the sign after a signed operation or shows a carry after a multiply-
138 //! and-accumulate operation. The Sum Extension acts as a check for overflows
139 //! or underflows.
140 //!
141 //!
142 //! \return The value of the MPY module Sum Extension.
143 //
144 //*****************************************************************************
145 extern uint16_t MPY_getSumExtension(void);
146 
147 //*****************************************************************************
148 //
149 // Mark the end of the C bindings section for C++ compilers.
150 //
151 //*****************************************************************************
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif
157 #endif // __MSP430WARE_MPY_H__
void MPY_setOperandOne8Bit(uint8_t multiplicationType, uint8_t operand)
Sets an 8-bit value into operand 1.
Definition: mpy.c:21
uint32_t MPY_getResult(void)
Returns an 64-bit result of the last multiplication operation.
Definition: mpy.c:43
void MPY_setOperandTwo16Bit(uint16_t operand)
Sets an 16-bit value into operand 2, which starts the multiplication.
Definition: mpy.c:38
void MPY_setOperandTwo8Bit(uint8_t operand)
Sets an 8-bit value into operand 2, which starts the multiplication.
Definition: mpy.c:33
void MPY_setOperandOne16Bit(uint8_t multiplicationType, uint16_t operand)
Sets an 16-bit value into operand 1.
Definition: mpy.c:27
uint16_t MPY_getSumExtension(void)
Returns the Sum Extension of the last multiplication operation.
Definition: mpy.c:51

Copyright 2020, Texas Instruments Incorporated