MSP430 DriverLib for MSP430FR5xx_6xx Devices  2.70.00.08
 All Data Structures Files Functions Variables Enumerations Modules Pages
mpy32.h
1 //*****************************************************************************
2 //
3 // mpy32.h - Driver for the MPY32 Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_MPY32_H__
8 #define __MSP430WARE_MPY32_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_MPY32__
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 writeDelaySelect
30 // parameter for functions: MPY32_setWriteDelay().
31 //
32 //*****************************************************************************
33 #define MPY32_WRITEDELAY_OFF (!(MPYDLY32 + MPYDLYWRTEN))
34 #define MPY32_WRITEDELAY_32BIT (MPYDLYWRTEN)
35 #define MPY32_WRITEDELAY_64BIT (MPYDLY32 + MPYDLYWRTEN)
36 
37 //*****************************************************************************
38 //
39 // The following are values that can be passed to the multiplicationType
40 // parameter for functions: MPY32_setOperandOne8Bit(),
41 // MPY32_setOperandOne16Bit(), MPY32_setOperandOne24Bit(), and
42 // MPY32_setOperandOne32Bit().
43 //
44 //*****************************************************************************
45 #define MPY32_MULTIPLY_UNSIGNED (0x00)
46 #define MPY32_MULTIPLY_SIGNED (0x02)
47 #define MPY32_MULTIPLYACCUMULATE_UNSIGNED (0x04)
48 #define MPY32_MULTIPLYACCUMULATE_SIGNED (0x06)
49 
50 //*****************************************************************************
51 //
52 // The following are values that can be passed toThe following are values that
53 // can be returned by the MPY32_getSaturationMode() function.
54 //
55 //*****************************************************************************
56 #define MPY32_SATURATION_MODE_DISABLED 0x00
57 #define MPY32_SATURATION_MODE_ENABLED MPYSAT
58 
59 //*****************************************************************************
60 //
61 // The following are values that can be passed toThe following are values that
62 // can be returned by the MPY32_getFractionalMode() function.
63 //
64 //*****************************************************************************
65 #define MPY32_FRACTIONAL_MODE_DISABLED 0x00
66 #define MPY32_FRACTIONAL_MODE_ENABLED MPYFRAC
67 
68 //*****************************************************************************
69 //
70 // Prototypes for the APIs.
71 //
72 //*****************************************************************************
73 
74 //*****************************************************************************
75 //
76 //! \brief Sets the write delay setting for the MPY32 module.
77 //!
78 //! This function sets up a write delay to the MPY module's registers, which
79 //! holds any writes to the registers until all calculations are complete.
80 //! There are two different settings, one which waits for 32-bit results to be
81 //! ready, and one which waits for 64-bit results to be ready. This prevents
82 //! unpredicatble results if registers are changed before the results are
83 //! ready.
84 //!
85 //! \param writeDelaySelect delays the write to any MPY32 register until the
86 //! selected bit size of result has been written.
87 //! Valid values are:
88 //! - \b MPY32_WRITEDELAY_OFF [Default] - writes are not delayed
89 //! - \b MPY32_WRITEDELAY_32BIT - writes are delayed until a 32-bit
90 //! result is available in the result registers
91 //! - \b MPY32_WRITEDELAY_64BIT - writes are delayed until a 64-bit
92 //! result is available in the result registers
93 //! \n Modified bits are \b MPYDLY32 and \b MPYDLYWRTEN of \b MPY32CTL0
94 //! register.
95 //!
96 //! \return None
97 //
98 //*****************************************************************************
99 extern void MPY32_setWriteDelay(uint16_t writeDelaySelect);
100 
101 //*****************************************************************************
102 //
103 //! \brief Enables Saturation Mode.
104 //!
105 //! This function enables saturation mode. When this is enabled, the result
106 //! read out from the MPY result registers is converted to the most-positive
107 //! number in the case of an overflow, or the most-negative number in the case
108 //! of an underflow. Please note, that the raw value in the registers does not
109 //! reflect the result returned, and if the saturation mode is disabled, then
110 //! the raw value of the registers will be returned instead.
111 //!
112 //!
113 //! \return None
114 //
115 //*****************************************************************************
116 extern void MPY32_enableSaturationMode(void);
117 
118 //*****************************************************************************
119 //
120 //! \brief Disables Saturation Mode.
121 //!
122 //! This function disables saturation mode, which allows the raw result of the
123 //! MPY result registers to be returned.
124 //!
125 //!
126 //! \return None
127 //
128 //*****************************************************************************
129 extern void MPY32_disableSaturationMode(void);
130 
131 //*****************************************************************************
132 //
133 //! \brief Gets the Saturation Mode.
134 //!
135 //! This function gets the current saturation mode.
136 //!
137 //!
138 //! \return Gets the Saturation Mode
139 //! Return one of the following:
140 //! - \b MPY32_SATURATION_MODE_DISABLED
141 //! - \b MPY32_SATURATION_MODE_ENABLED
142 //! \n Gets the Saturation Mode
143 //
144 //*****************************************************************************
145 extern uint8_t MPY32_getSaturationMode(void);
146 
147 //*****************************************************************************
148 //
149 //! \brief Enables Fraction Mode.
150 //!
151 //! This function enables fraction mode.
152 //!
153 //!
154 //! \return None
155 //
156 //*****************************************************************************
157 extern void MPY32_enableFractionalMode(void);
158 
159 //*****************************************************************************
160 //
161 //! \brief Disables Fraction Mode.
162 //!
163 //! This function disables fraction mode.
164 //!
165 //!
166 //! \return None
167 //
168 //*****************************************************************************
169 extern void MPY32_disableFractionalMode(void);
170 
171 //*****************************************************************************
172 //
173 //! \brief Gets the Fractional Mode.
174 //!
175 //! This function gets the current fractional mode.
176 //!
177 //!
178 //! \return Gets the fractional mode
179 //! Return one of the following:
180 //! - \b MPY32_FRACTIONAL_MODE_DISABLED
181 //! - \b MPY32_FRACTIONAL_MODE_ENABLED
182 //! \n Gets the Fractional Mode
183 //
184 //*****************************************************************************
185 extern uint8_t MPY32_getFractionalMode(void);
186 
187 //*****************************************************************************
188 //
189 //! \brief Sets an 8-bit value into operand 1.
190 //!
191 //! This function sets the first operand for multiplication and determines what
192 //! type of operation should be performed. Once the second operand is set, then
193 //! the operation will begin.
194 //!
195 //! \param multiplicationType is the type of multiplication to perform once the
196 //! second operand is set.
197 //! Valid values are:
198 //! - \b MPY32_MULTIPLY_UNSIGNED
199 //! - \b MPY32_MULTIPLY_SIGNED
200 //! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
201 //! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
202 //! \param operand is the 8-bit value to load into the 1st operand.
203 //!
204 //! \return None
205 //
206 //*****************************************************************************
207 extern void MPY32_setOperandOne8Bit(uint8_t multiplicationType,
208  uint8_t operand);
209 
210 //*****************************************************************************
211 //
212 //! \brief Sets an 16-bit value into operand 1.
213 //!
214 //! This function sets the first operand for multiplication and determines what
215 //! type of operation should be performed. Once the second operand is set, then
216 //! the operation will begin.
217 //!
218 //! \param multiplicationType is the type of multiplication to perform once the
219 //! second operand is set.
220 //! Valid values are:
221 //! - \b MPY32_MULTIPLY_UNSIGNED
222 //! - \b MPY32_MULTIPLY_SIGNED
223 //! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
224 //! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
225 //! \param operand is the 16-bit value to load into the 1st operand.
226 //!
227 //! \return None
228 //
229 //*****************************************************************************
230 extern void MPY32_setOperandOne16Bit(uint8_t multiplicationType,
231  uint16_t operand);
232 
233 //*****************************************************************************
234 //
235 //! \brief Sets an 24-bit value into operand 1.
236 //!
237 //! This function sets the first operand for multiplication and determines what
238 //! type of operation should be performed. Once the second operand is set, then
239 //! the operation will begin.
240 //!
241 //! \param multiplicationType is the type of multiplication to perform once the
242 //! second operand is set.
243 //! Valid values are:
244 //! - \b MPY32_MULTIPLY_UNSIGNED
245 //! - \b MPY32_MULTIPLY_SIGNED
246 //! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
247 //! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
248 //! \param operand is the 24-bit value to load into the 1st operand.
249 //!
250 //! \return None
251 //
252 //*****************************************************************************
253 extern void MPY32_setOperandOne24Bit(uint8_t multiplicationType,
254  uint32_t operand);
255 
256 //*****************************************************************************
257 //
258 //! \brief Sets an 32-bit value into operand 1.
259 //!
260 //! This function sets the first operand for multiplication and determines what
261 //! type of operation should be performed. Once the second operand is set, then
262 //! the operation will begin.
263 //!
264 //! \param multiplicationType is the type of multiplication to perform once the
265 //! second operand is set.
266 //! Valid values are:
267 //! - \b MPY32_MULTIPLY_UNSIGNED
268 //! - \b MPY32_MULTIPLY_SIGNED
269 //! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
270 //! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
271 //! \param operand is the 32-bit value to load into the 1st operand.
272 //!
273 //! \return None
274 //
275 //*****************************************************************************
276 extern void MPY32_setOperandOne32Bit(uint8_t multiplicationType,
277  uint32_t operand);
278 
279 //*****************************************************************************
280 //
281 //! \brief Sets an 8-bit value into operand 2, which starts the multiplication.
282 //!
283 //! This function sets the second operand of the multiplication operation and
284 //! starts the operation.
285 //!
286 //! \param operand is the 8-bit value to load into the 2nd operand.
287 //!
288 //! \return None
289 //
290 //*****************************************************************************
291 extern void MPY32_setOperandTwo8Bit(uint8_t operand);
292 
293 //*****************************************************************************
294 //
295 //! \brief Sets an 16-bit value into operand 2, which starts the
296 //! multiplication.
297 //!
298 //! This function sets the second operand of the multiplication operation and
299 //! starts the operation.
300 //!
301 //! \param operand is the 16-bit value to load into the 2nd operand.
302 //!
303 //! \return None
304 //
305 //*****************************************************************************
306 extern void MPY32_setOperandTwo16Bit(uint16_t operand);
307 
308 //*****************************************************************************
309 //
310 //! \brief Sets an 24-bit value into operand 2, which starts the
311 //! multiplication.
312 //!
313 //! This function sets the second operand of the multiplication operation and
314 //! starts the operation.
315 //!
316 //! \param operand is the 24-bit value to load into the 2nd operand.
317 //!
318 //! \return None
319 //
320 //*****************************************************************************
321 extern void MPY32_setOperandTwo24Bit(uint32_t operand);
322 
323 //*****************************************************************************
324 //
325 //! \brief Sets an 32-bit value into operand 2, which starts the
326 //! multiplication.
327 //!
328 //! This function sets the second operand of the multiplication operation and
329 //! starts the operation.
330 //!
331 //! \param operand is the 32-bit value to load into the 2nd operand.
332 //!
333 //! \return None
334 //
335 //*****************************************************************************
336 extern void MPY32_setOperandTwo32Bit(uint32_t operand);
337 
338 //*****************************************************************************
339 //
340 //! \brief Returns an 64-bit result of the last multiplication operation.
341 //!
342 //! This function returns all 64 bits of the result registers
343 //!
344 //!
345 //! \return The 64-bit result is returned as a uint64_t type
346 //
347 //*****************************************************************************
348 extern uint64_t MPY32_getResult(void);
349 
350 //*****************************************************************************
351 //
352 //! \brief Returns the Sum Extension of the last multiplication operation.
353 //!
354 //! This function returns the Sum Extension of the MPY module, which either
355 //! gives the sign after a signed operation or shows a carry after a multiply-
356 //! and-accumulate operation. The Sum Extension acts as a check for overflows
357 //! or underflows.
358 //!
359 //!
360 //! \return The value of the MPY32 module Sum Extension.
361 //
362 //*****************************************************************************
363 extern uint16_t MPY32_getSumExtension(void);
364 
365 //*****************************************************************************
366 //
367 //! \brief Returns the Carry Bit of the last multiplication operation.
368 //!
369 //! This function returns the Carry Bit of the MPY module, which either gives
370 //! the sign after a signed operation or shows a carry after a multiply- and-
371 //! accumulate operation.
372 //!
373 //!
374 //! \return The value of the MPY32 module Carry Bit 0x0 or 0x1.
375 //
376 //*****************************************************************************
377 extern uint16_t MPY32_getCarryBitValue(void);
378 
379 //*****************************************************************************
380 //
381 //! \brief Clears the Carry Bit of the last multiplication operation.
382 //!
383 //! This function clears the Carry Bit of the MPY module
384 //!
385 //!
386 //! \return The value of the MPY32 module Carry Bit 0x0 or 0x1.
387 //
388 //*****************************************************************************
389 extern void MPY32_clearCarryBitValue(void);
390 
391 //*****************************************************************************
392 //
393 //! \brief Preloads the result register
394 //!
395 //! This function Preloads the result register
396 //!
397 //! \param result value to preload the result register to
398 //!
399 //! \return None
400 //
401 //*****************************************************************************
402 extern void MPY32_preloadResult(uint64_t result);
403 
404 //*****************************************************************************
405 //
406 // Mark the end of the C bindings section for C++ compilers.
407 //
408 //*****************************************************************************
409 #ifdef __cplusplus
410 }
411 #endif
412 
413 #endif
414 #endif // __MSP430WARE_MPY32_H__
void MPY32_disableFractionalMode(void)
Disables Fraction Mode.
Definition: mpy32.c:47
void MPY32_disableSaturationMode(void)
Disables Saturation Mode.
Definition: mpy32.c:32
uint8_t MPY32_getSaturationMode(void)
Gets the Saturation Mode.
Definition: mpy32.c:37
void MPY32_setOperandTwo32Bit(uint32_t operand)
Sets an 32-bit value into operand 2, which starts the multiplication.
Definition: mpy32.c:101
uint8_t MPY32_getFractionalMode(void)
Gets the Fractional Mode.
Definition: mpy32.c:52
void MPY32_setOperandOne24Bit(uint8_t multiplicationType, uint32_t operand)
Sets an 24-bit value into operand 1.
Definition: mpy32.c:69
uint16_t MPY32_getCarryBitValue(void)
Returns the Carry Bit of the last multiplication operation.
Definition: mpy32.c:123
void MPY32_setOperandOne8Bit(uint8_t multiplicationType, uint8_t operand)
Sets an 8-bit value into operand 1.
Definition: mpy32.c:57
void MPY32_enableFractionalMode(void)
Enables Fraction Mode.
Definition: mpy32.c:42
void MPY32_setWriteDelay(uint16_t writeDelaySelect)
Sets the write delay setting for the MPY32 module.
Definition: mpy32.c:21
void MPY32_setOperandTwo16Bit(uint16_t operand)
Sets an 16-bit value into operand 2, which starts the multiplication.
Definition: mpy32.c:90
void MPY32_setOperandOne32Bit(uint8_t multiplicationType, uint32_t operand)
Sets an 32-bit value into operand 1.
Definition: mpy32.c:77
void MPY32_clearCarryBitValue(void)
Clears the Carry Bit of the last multiplication operation.
Definition: mpy32.c:127
void MPY32_preloadResult(uint64_t result)
Preloads the result register.
Definition: mpy32.c:131
void MPY32_enableSaturationMode(void)
Enables Saturation Mode.
Definition: mpy32.c:27
void MPY32_setOperandTwo8Bit(uint8_t operand)
Sets an 8-bit value into operand 2, which starts the multiplication.
Definition: mpy32.c:85
uint16_t MPY32_getSumExtension(void)
Returns the Sum Extension of the last multiplication operation.
Definition: mpy32.c:118
uint64_t MPY32_getResult(void)
Returns an 64-bit result of the last multiplication operation.
Definition: mpy32.c:107
void MPY32_setOperandTwo24Bit(uint32_t operand)
Sets an 24-bit value into operand 2, which starts the multiplication.
Definition: mpy32.c:95
void MPY32_setOperandOne16Bit(uint8_t multiplicationType, uint16_t operand)
Sets an 16-bit value into operand 1.
Definition: mpy32.c:63

Copyright 2016, Texas Instruments Incorporated