2020-2021 Sunseeker Telemetry and Lighting System
mpy32.h
Go to the documentation of this file.
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 //
97 //
98 //*****************************************************************************
99 extern void MPY32_setWriteDelay(uint16_t writeDelaySelect);
100 
101 //*****************************************************************************
102 //
114 //
115 //*****************************************************************************
116 extern void MPY32_enableSaturationMode(void);
117 
118 //*****************************************************************************
119 //
127 //
128 //*****************************************************************************
129 extern void MPY32_disableSaturationMode(void);
130 
131 //*****************************************************************************
132 //
143 //
144 //*****************************************************************************
145 extern uint8_t MPY32_getSaturationMode(void);
146 
147 //*****************************************************************************
148 //
155 //
156 //*****************************************************************************
157 extern void MPY32_enableFractionalMode(void);
158 
159 //*****************************************************************************
160 //
167 //
168 //*****************************************************************************
169 extern void MPY32_disableFractionalMode(void);
170 
171 //*****************************************************************************
172 //
183 //
184 //*****************************************************************************
185 extern uint8_t MPY32_getFractionalMode(void);
186 
187 //*****************************************************************************
188 //
205 //
206 //*****************************************************************************
207 extern void MPY32_setOperandOne8Bit(uint8_t multiplicationType,
208  uint8_t operand);
209 
210 //*****************************************************************************
211 //
228 //
229 //*****************************************************************************
230 extern void MPY32_setOperandOne16Bit(uint8_t multiplicationType,
231  uint16_t operand);
232 
233 //*****************************************************************************
234 //
251 //
252 //*****************************************************************************
253 extern void MPY32_setOperandOne24Bit(uint8_t multiplicationType,
254  uint32_t operand);
255 
256 //*****************************************************************************
257 //
274 //
275 //*****************************************************************************
276 extern void MPY32_setOperandOne32Bit(uint8_t multiplicationType,
277  uint32_t operand);
278 
279 //*****************************************************************************
280 //
289 //
290 //*****************************************************************************
291 extern void MPY32_setOperandTwo8Bit(uint8_t operand);
292 
293 //*****************************************************************************
294 //
304 //
305 //*****************************************************************************
306 extern void MPY32_setOperandTwo16Bit(uint16_t operand);
307 
308 //*****************************************************************************
309 //
319 //
320 //*****************************************************************************
321 extern void MPY32_setOperandTwo24Bit(uint32_t operand);
322 
323 //*****************************************************************************
324 //
334 //
335 //*****************************************************************************
336 extern void MPY32_setOperandTwo32Bit(uint32_t operand);
337 
338 //*****************************************************************************
339 //
346 //
347 //*****************************************************************************
348 extern uint64_t MPY32_getResult(void);
349 
350 //*****************************************************************************
351 //
361 //
362 //*****************************************************************************
363 extern uint16_t MPY32_getSumExtension(void);
364 
365 //*****************************************************************************
366 //
375 //
376 //*****************************************************************************
377 extern uint16_t MPY32_getCarryBitValue(void);
378 
379 //*****************************************************************************
380 //
387 //
388 //*****************************************************************************
389 extern void MPY32_clearCarryBitValue(void);
390 
391 //*****************************************************************************
392 //
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__