]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MSP430FR5969_LaunchPad/driverlib/MSP430FR5xx_6xx/mpy32.h
Start of an MSP430FR5969 IAR project - currently running Blinky only.
[freertos] / FreeRTOS / Demo / MSP430FR5969_LaunchPad / driverlib / MSP430FR5xx_6xx / mpy32.h
1 /* --COPYRIGHT--,BSD\r
2  * Copyright (c) 2014, Texas Instruments Incorporated\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  *\r
9  * *  Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  * *  Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the distribution.\r
15  *\r
16  * *  Neither the name of Texas Instruments Incorporated nor the names of\r
17  *    its contributors may be used to endorse or promote products derived\r
18  *    from this software without specific prior written permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  * --/COPYRIGHT--*/\r
32 //*****************************************************************************\r
33 //\r
34 // mpy32.h - Driver for the MPY32 Module.\r
35 //\r
36 //*****************************************************************************\r
37 \r
38 #ifndef __MSP430WARE_MPY32_H__\r
39 #define __MSP430WARE_MPY32_H__\r
40 \r
41 #include "inc/hw_memmap.h"\r
42 \r
43 #ifdef __MSP430_HAS_MPY32__\r
44 \r
45 //*****************************************************************************\r
46 //\r
47 // If building with a C++ compiler, make all of the definitions in this header\r
48 // have a C binding.\r
49 //\r
50 //*****************************************************************************\r
51 #ifdef __cplusplus\r
52 extern "C"\r
53 {\r
54 #endif\r
55 \r
56 #include "inc/hw_regaccess.h"\r
57 \r
58 //*****************************************************************************\r
59 //\r
60 // The following are values that can be passed to the writeDelaySelect\r
61 // parameter for functions: MPY32_setWriteDelay().\r
62 //\r
63 //*****************************************************************************\r
64 #define MPY32_WRITEDELAY_OFF                        (!(MPYDLY32 + MPYDLYWRTEN))\r
65 #define MPY32_WRITEDELAY_32BIT                                    (MPYDLYWRTEN)\r
66 #define MPY32_WRITEDELAY_64BIT                         (MPYDLY32 + MPYDLYWRTEN)\r
67 \r
68 //*****************************************************************************\r
69 //\r
70 // The following are values that can be passed to the multiplicationType\r
71 // parameter for functions: MPY32_setOperandOne8Bit(),\r
72 // MPY32_setOperandOne16Bit(), MPY32_setOperandOne24Bit(), and\r
73 // MPY32_setOperandOne32Bit().\r
74 //\r
75 //*****************************************************************************\r
76 #define MPY32_MULTIPLY_UNSIGNED                                          (0x00)\r
77 #define MPY32_MULTIPLY_SIGNED                                            (0x02)\r
78 #define MPY32_MULTIPLYACCUMULATE_UNSIGNED                                (0x04)\r
79 #define MPY32_MULTIPLYACCUMULATE_SIGNED                                  (0x06)\r
80 \r
81 //*****************************************************************************\r
82 //\r
83 // The following are values that can be passed toThe following are values that\r
84 // can be returned by the MPY32_getSaturationMode() function.\r
85 //\r
86 //*****************************************************************************\r
87 #define MPY32_SATURATION_MODE_DISABLED                                     0x00\r
88 #define MPY32_SATURATION_MODE_ENABLED                                    MPYSAT\r
89 \r
90 //*****************************************************************************\r
91 //\r
92 // The following are values that can be passed toThe following are values that\r
93 // can be returned by the MPY32_getFractionalMode() function.\r
94 //\r
95 //*****************************************************************************\r
96 #define MPY32_FRACTIONAL_MODE_DISABLED                                     0x00\r
97 #define MPY32_FRACTIONAL_MODE_ENABLED                                   MPYFRAC\r
98 \r
99 //*****************************************************************************\r
100 //\r
101 // Prototypes for the APIs.\r
102 //\r
103 //*****************************************************************************\r
104 \r
105 //*****************************************************************************\r
106 //\r
107 //! \brief Sets the write delay setting for the MPY32 module.\r
108 //!\r
109 //! This function sets up a write delay to the MPY module's registers, which\r
110 //! holds any writes to the registers until all calculations are complete.\r
111 //! There are two different settings, one which waits for 32-bit results to be\r
112 //! ready, and one which waits for 64-bit results to be ready. This prevents\r
113 //! unpredicatble results if registers are changed before the results are\r
114 //! ready.\r
115 //!\r
116 //! \param writeDelaySelect delays the write to any MPY32 register until the\r
117 //!        selected bit size of result has been written.\r
118 //!        Valid values are:\r
119 //!        - \b MPY32_WRITEDELAY_OFF [Default] - writes are not delayed\r
120 //!        - \b MPY32_WRITEDELAY_32BIT - writes are delayed until a 32-bit\r
121 //!           result is available in the result registers\r
122 //!        - \b MPY32_WRITEDELAY_64BIT - writes are delayed until a 64-bit\r
123 //!           result is available in the result registers\r
124 //!        \n Modified bits are \b MPYDLY32 and \b MPYDLYWRTEN of \b MPY32CTL0\r
125 //!        register.\r
126 //!\r
127 //! \return None\r
128 //\r
129 //*****************************************************************************\r
130 extern void MPY32_setWriteDelay(uint16_t writeDelaySelect);\r
131 \r
132 //*****************************************************************************\r
133 //\r
134 //! \brief Enables Saturation Mode.\r
135 //!\r
136 //! This function enables saturation mode. When this is enabled, the result\r
137 //! read out from the MPY result registers is converted to the most-positive\r
138 //! number in the case of an overflow, or the most-negative number in the case\r
139 //! of an underflow. Please note, that the raw value in the registers does not\r
140 //! reflect the result returned, and if the saturation mode is disabled, then\r
141 //! the raw value of the registers will be returned instead.\r
142 //!\r
143 //!\r
144 //! \return None\r
145 //\r
146 //*****************************************************************************\r
147 extern void MPY32_enableSaturationMode(void);\r
148 \r
149 //*****************************************************************************\r
150 //\r
151 //! \brief Disables Saturation Mode.\r
152 //!\r
153 //! This function disables saturation mode, which allows the raw result of the\r
154 //! MPY result registers to be returned.\r
155 //!\r
156 //!\r
157 //! \return None\r
158 //\r
159 //*****************************************************************************\r
160 extern void MPY32_disableSaturationMode(void);\r
161 \r
162 //*****************************************************************************\r
163 //\r
164 //! \brief Gets the Saturation Mode.\r
165 //!\r
166 //! This function gets the current saturation mode.\r
167 //!\r
168 //!\r
169 //! \return Gets the Saturation Mode\r
170 //!         Return one of the following:\r
171 //!         - \b MPY32_SATURATION_MODE_DISABLED\r
172 //!         - \b MPY32_SATURATION_MODE_ENABLED\r
173 //!         \n Gets the Saturation Mode\r
174 //\r
175 //*****************************************************************************\r
176 extern uint8_t MPY32_getSaturationMode(void);\r
177 \r
178 //*****************************************************************************\r
179 //\r
180 //! \brief Enables Fraction Mode.\r
181 //!\r
182 //! This function enables fraction mode.\r
183 //!\r
184 //!\r
185 //! \return None\r
186 //\r
187 //*****************************************************************************\r
188 extern void MPY32_enableFractionalMode(void);\r
189 \r
190 //*****************************************************************************\r
191 //\r
192 //! \brief Disables Fraction Mode.\r
193 //!\r
194 //! This function disables fraction mode.\r
195 //!\r
196 //!\r
197 //! \return None\r
198 //\r
199 //*****************************************************************************\r
200 extern void MPY32_disableFractionalMode(void);\r
201 \r
202 //*****************************************************************************\r
203 //\r
204 //! \brief Gets the Fractional Mode.\r
205 //!\r
206 //! This function gets the current fractional mode.\r
207 //!\r
208 //!\r
209 //! \return Gets the fractional mode\r
210 //!         Return one of the following:\r
211 //!         - \b MPY32_FRACTIONAL_MODE_DISABLED\r
212 //!         - \b MPY32_FRACTIONAL_MODE_ENABLED\r
213 //!         \n Gets the Fractional Mode\r
214 //\r
215 //*****************************************************************************\r
216 extern uint8_t MPY32_getFractionalMode(void);\r
217 \r
218 //*****************************************************************************\r
219 //\r
220 //! \brief Sets an 8-bit value into operand 1.\r
221 //!\r
222 //! This function sets the first operand for multiplication and determines what\r
223 //! type of operation should be performed. Once the second operand is set, then\r
224 //! the operation will begin.\r
225 //!\r
226 //! \param multiplicationType is the type of multiplication to perform once the\r
227 //!        second operand is set.\r
228 //!        Valid values are:\r
229 //!        - \b MPY32_MULTIPLY_UNSIGNED\r
230 //!        - \b MPY32_MULTIPLY_SIGNED\r
231 //!        - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED\r
232 //!        - \b MPY32_MULTIPLYACCUMULATE_SIGNED\r
233 //! \param operand is the 8-bit value to load into the 1st operand.\r
234 //!\r
235 //! \return None\r
236 //\r
237 //*****************************************************************************\r
238 extern void MPY32_setOperandOne8Bit(uint8_t multiplicationType,\r
239                                     uint8_t operand);\r
240 \r
241 //*****************************************************************************\r
242 //\r
243 //! \brief Sets an 16-bit value into operand 1.\r
244 //!\r
245 //! This function sets the first operand for multiplication and determines what\r
246 //! type of operation should be performed. Once the second operand is set, then\r
247 //! the operation will begin.\r
248 //!\r
249 //! \param multiplicationType is the type of multiplication to perform once the\r
250 //!        second operand is set.\r
251 //!        Valid values are:\r
252 //!        - \b MPY32_MULTIPLY_UNSIGNED\r
253 //!        - \b MPY32_MULTIPLY_SIGNED\r
254 //!        - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED\r
255 //!        - \b MPY32_MULTIPLYACCUMULATE_SIGNED\r
256 //! \param operand is the 16-bit value to load into the 1st operand.\r
257 //!\r
258 //! \return None\r
259 //\r
260 //*****************************************************************************\r
261 extern void MPY32_setOperandOne16Bit(uint8_t multiplicationType,\r
262                                      uint16_t operand);\r
263 \r
264 //*****************************************************************************\r
265 //\r
266 //! \brief Sets an 24-bit value into operand 1.\r
267 //!\r
268 //! This function sets the first operand for multiplication and determines what\r
269 //! type of operation should be performed. Once the second operand is set, then\r
270 //! the operation will begin.\r
271 //!\r
272 //! \param multiplicationType is the type of multiplication to perform once the\r
273 //!        second operand is set.\r
274 //!        Valid values are:\r
275 //!        - \b MPY32_MULTIPLY_UNSIGNED\r
276 //!        - \b MPY32_MULTIPLY_SIGNED\r
277 //!        - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED\r
278 //!        - \b MPY32_MULTIPLYACCUMULATE_SIGNED\r
279 //! \param operand is the 24-bit value to load into the 1st operand.\r
280 //!\r
281 //! \return None\r
282 //\r
283 //*****************************************************************************\r
284 extern void MPY32_setOperandOne24Bit(uint8_t multiplicationType,\r
285                                      uint32_t operand);\r
286 \r
287 //*****************************************************************************\r
288 //\r
289 //! \brief Sets an 32-bit value into operand 1.\r
290 //!\r
291 //! This function sets the first operand for multiplication and determines what\r
292 //! type of operation should be performed. Once the second operand is set, then\r
293 //! the operation will begin.\r
294 //!\r
295 //! \param multiplicationType is the type of multiplication to perform once the\r
296 //!        second operand is set.\r
297 //!        Valid values are:\r
298 //!        - \b MPY32_MULTIPLY_UNSIGNED\r
299 //!        - \b MPY32_MULTIPLY_SIGNED\r
300 //!        - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED\r
301 //!        - \b MPY32_MULTIPLYACCUMULATE_SIGNED\r
302 //! \param operand is the 32-bit value to load into the 1st operand.\r
303 //!\r
304 //! \return None\r
305 //\r
306 //*****************************************************************************\r
307 extern void MPY32_setOperandOne32Bit(uint8_t multiplicationType,\r
308                                      uint32_t operand);\r
309 \r
310 //*****************************************************************************\r
311 //\r
312 //! \brief Sets an 8-bit value into operand 2, which starts the multiplication.\r
313 //!\r
314 //! This function sets the second operand of the multiplication operation and\r
315 //! starts the operation.\r
316 //!\r
317 //! \param operand is the 8-bit value to load into the 2nd operand.\r
318 //!\r
319 //! \return None\r
320 //\r
321 //*****************************************************************************\r
322 extern void MPY32_setOperandTwo8Bit(uint8_t operand);\r
323 \r
324 //*****************************************************************************\r
325 //\r
326 //! \brief Sets an 16-bit value into operand 2, which starts the\r
327 //! multiplication.\r
328 //!\r
329 //! This function sets the second operand of the multiplication operation and\r
330 //! starts the operation.\r
331 //!\r
332 //! \param operand is the 16-bit value to load into the 2nd operand.\r
333 //!\r
334 //! \return None\r
335 //\r
336 //*****************************************************************************\r
337 extern void MPY32_setOperandTwo16Bit(uint16_t operand);\r
338 \r
339 //*****************************************************************************\r
340 //\r
341 //! \brief Sets an 24-bit value into operand 2, which starts the\r
342 //! multiplication.\r
343 //!\r
344 //! This function sets the second operand of the multiplication operation and\r
345 //! starts the operation.\r
346 //!\r
347 //! \param operand is the 24-bit value to load into the 2nd operand.\r
348 //!\r
349 //! \return None\r
350 //\r
351 //*****************************************************************************\r
352 extern void MPY32_setOperandTwo24Bit(uint32_t operand);\r
353 \r
354 //*****************************************************************************\r
355 //\r
356 //! \brief Sets an 32-bit value into operand 2, which starts the\r
357 //! multiplication.\r
358 //!\r
359 //! This function sets the second operand of the multiplication operation and\r
360 //! starts the operation.\r
361 //!\r
362 //! \param operand is the 32-bit value to load into the 2nd operand.\r
363 //!\r
364 //! \return None\r
365 //\r
366 //*****************************************************************************\r
367 extern void MPY32_setOperandTwo32Bit(uint32_t operand);\r
368 \r
369 //*****************************************************************************\r
370 //\r
371 //! \brief Returns an 64-bit result of the last multiplication operation.\r
372 //!\r
373 //! This function returns all 64 bits of the result registers\r
374 //!\r
375 //!\r
376 //! \return The 64-bit result is returned as a uint64_t type\r
377 //\r
378 //*****************************************************************************\r
379 extern uint64_t MPY32_getResult(void);\r
380 \r
381 //*****************************************************************************\r
382 //\r
383 //! \brief Returns the Sum Extension of the last multiplication operation.\r
384 //!\r
385 //! This function returns the Sum Extension of the MPY module, which either\r
386 //! gives the sign after a signed operation or shows a carry after a multiply-\r
387 //! and-accumulate operation. The Sum Extension acts as a check for overflows\r
388 //! or underflows.\r
389 //!\r
390 //!\r
391 //! \return The value of the MPY32 module Sum Extension.\r
392 //\r
393 //*****************************************************************************\r
394 extern uint16_t MPY32_getSumExtension(void);\r
395 \r
396 //*****************************************************************************\r
397 //\r
398 //! \brief Returns the Carry Bit of the last multiplication operation.\r
399 //!\r
400 //! This function returns the Carry Bit of the MPY module, which either gives\r
401 //! the sign after a signed operation or shows a carry after a multiply- and-\r
402 //! accumulate operation.\r
403 //!\r
404 //!\r
405 //! \return The value of the MPY32 module Carry Bit 0x0 or 0x1.\r
406 //\r
407 //*****************************************************************************\r
408 extern uint16_t MPY32_getCarryBitValue(void);\r
409 \r
410 //*****************************************************************************\r
411 //\r
412 //! \brief Clears the Carry Bit of the last multiplication operation.\r
413 //!\r
414 //! This function clears the Carry Bit of the MPY module\r
415 //!\r
416 //!\r
417 //! \return The value of the MPY32 module Carry Bit 0x0 or 0x1.\r
418 //\r
419 //*****************************************************************************\r
420 extern void MPY32_clearCarryBitValue(void);\r
421 \r
422 //*****************************************************************************\r
423 //\r
424 //! \brief Preloads the result register\r
425 //!\r
426 //! This function Preloads the result register\r
427 //!\r
428 //! \param result value to preload the result register to\r
429 //!\r
430 //! \return None\r
431 //\r
432 //*****************************************************************************\r
433 extern void MPY32_preloadResult(uint64_t result);\r
434 \r
435 //*****************************************************************************\r
436 //\r
437 // Mark the end of the C bindings section for C++ compilers.\r
438 //\r
439 //*****************************************************************************\r
440 #ifdef __cplusplus\r
441 }\r
442 #endif\r
443 \r
444 #endif\r
445 #endif // __MSP430WARE_MPY32_H__\r