1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef __PCM_H__
33 #define __PCM_H__
34 
35 //*****************************************************************************
36 //
37 //! \addtogroup pcm_api
38 //! @{
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #include <stdint.h>
54 #include <stdbool.h>
55 #include <ti/devices/msp432p4xx/inc/msp.h>
56 
57 //*****************************************************************************
58 //
59 // Control specific variables
60 //
61 //*****************************************************************************
62 #define PCM_KEY 0x695A0000
63 
64 /* Power Modes */
65 #define PCM_AM_LDO_VCORE0      0x00
66 #define PCM_AM_LDO_VCORE1      0x01
67 #define PCM_AM_DCDC_VCORE0     0x04
68 #define PCM_AM_DCDC_VCORE1     0x05
69 #define PCM_AM_LF_VCORE0      0x08
70 #define PCM_AM_LF_VCORE1      0x09
71 #define PCM_LPM0_LDO_VCORE0    0x10
72 #define PCM_LPM0_LDO_VCORE1    0x11
73 #define PCM_LPM0_DCDC_VCORE0   0x14
74 #define PCM_LPM0_DCDC_VCORE1   0x15
75 #define PCM_LPM0_LF_VCORE0    0x18
76 #define PCM_LPM0_LF_VCORE1    0x19
77 #define PCM_LPM3               0x20
78 #define PCM_LPM4               0x21
79 #define PCM_LPM35_VCORE0       0xC0
80 #define PCM_LPM45              0xA0
81 
82 #define PCM_VCORE0     0x00
83 #define PCM_VCORE1     0x01
84 #define PCM_VCORELPM3   0x02
85 
86 #define PCM_LDO_MODE   0x00
87 #define PCM_DCDC_MODE  0x01
88 #define PCM_LF_MODE   0x02
89 
90 #define PCM_SHUTDOWN_PARTIAL PCM_LPM35_VCORE0
91 #define PCM_SHUTDOWN_COMPLETE PCM_LPM45
92 
93 #define PCM_DCDCERROR PCM_IE_DCDC_ERROR_IE
94 #define PCM_AM_INVALIDTRANSITION PCM_IE_AM_INVALID_TR_IE
95 #define PCM_SM_INVALIDCLOCK PCM_IE_LPM_INVALID_CLK_IE
96 #define PCM_SM_INVALIDTRANSITION PCM_IE_LPM_INVALID_TR_IE
97 
98 //*****************************************************************************
99 //
100 // Prototypes for the APIs.
101 //
102 //*****************************************************************************
103 
104 //******************************************************************************
105 //
106 //! Sets the core voltage level (Vcore). The function will take care of all
107 //! power state transitions needed to shift between core voltage levels.
108 //! Because transitions between voltage levels may require changes power modes,
109 //! the power mode might temporarily be change. The power mode will be returned
110 //! to the original state (with the new voltage level) at the end of a
111 //! successful execution of this function.
112 //!
113 //! Refer to the device specific data sheet for specifics about core voltage
114 //! levels.
115 //!
116 //! \param voltageLevel The voltage level to be shifted to.
117 //!           - \b PCM_VCORE0,
118 //!           - \b PCM_VCORE1
119 //!
120 //! \return true if voltage level set, false otherwise.
121 //
122 //******************************************************************************
123 extern bool PCM_setCoreVoltageLevel(uint_fast8_t voltageLevel);
124 
125 //******************************************************************************
126 //
127 //! Returns the current powers state of the system see the
128 //! PCM_setCoreVoltageLevel function for specific information about the modes.
129 //!
130 //! \return The current voltage of the system
131 //!
132 //! Possible return values include:
133 //!     - \b PCM_VCORE0
134 //!     - \b PCM_VCORE1
135 //!     - \b PCM_VCORELPM3
136 //!
137 //
138 //******************************************************************************
139 extern uint8_t PCM_getCoreVoltageLevel(void);
140 
141 //******************************************************************************
142 //
143 //! Sets the core voltage level (Vcore). This function will take care of all
144 //! power state transitions needed to shift between core voltage levels.
145 //! Because transitions between voltage levels may require changes power modes,
146 //! the power mode might temporarily be change. The power mode will be returned
147 //! to the original state (with the new voltage level) at the end of a
148 //! successful execution of this function.
149 //!
150 //! This function is similar to PCMSetCoreVoltageLevel, however a timeout
151 //! mechanism is used.
152 //!
153 //! Refer to the device specific data sheet for specifics about core voltage
154 //! levels.
155 //!
156 //! \param voltageLevel The voltage level to be shifted to.
157 //!           - \b PCM_VCORE0,
158 //!           - \b PCM_VCORE1
159 //!
160 //! \param timeOut Number of loop iterations to timeout when checking for
161 //!         power state transitions. This should be used for debugging initial
162 //!         power/hardware configurations. After a stable hardware base is
163 //!         established, the PCMSetCoreVoltageLevel function should be used
164 //!
165 //! \return true if voltage level set, false otherwise.
166 //
167 //******************************************************************************
168 extern bool PCM_setCoreVoltageLevelWithTimeout(uint_fast8_t voltageLevel,
169         uint32_t timeOut);
170 
171 //******************************************************************************
172 //
173 //! Sets the core voltage level (Vcore).  This function is similar to
174 //! PCM_setCoreVoltageLevel, however there are no polling flags to ensure
175 //! a state has changed. Execution is returned back to the calling program
176 //  and it is up to the user to ensure proper state transitions happen
177 //! correctly. For MSP432, changing into different power modes/states
178 //! require very specific logic. This function will initiate only one state
179 //! transition and then return. It is up to the user to keep calling this
180 //! function until the correct power state has been achieved.
181 //!
182 //! Refer to the device specific data sheet for specifics about core voltage
183 //! levels.
184 //!
185 //! \param voltageLevel The voltage level to be shifted to.
186 //!           - \b PCM_VCORE0,
187 //!           - \b PCM_VCORE1
188 //!
189 //! \return true if voltage level set, false otherwise.
190 //
191 //******************************************************************************
192 extern bool PCM_setCoreVoltageLevelNonBlocking(uint_fast8_t voltageLevel);
193 
194 //******************************************************************************
195 //
196 //! Switches between power modes. This function will take care of all
197 //! power state transitions needed to shift between power modes. Note for
198 //! changing to DCDC mode, specific hardware considerations are required.
199 //!
200 //! Refer to the device specific data sheet for specifics about power modes.
201 //!
202 //! \param powerMode The voltage modes to be shifted to. Valid values are:
203 //!           - \b PCM_LDO_MODE,
204 //!           - \b PCM_DCDC_MODE,
205 //!           - \b PCM_LF_MODE
206 //!
207 //! \return true if power mode is set, false otherwise.
208 //
209 //******************************************************************************
210 extern bool PCM_setPowerMode(uint_fast8_t powerMode);
211 
212 //******************************************************************************
213 //
214 //! Switches between power modes. This function will take care of all
215 //! power state transitions needed to shift between power modes. Note for
216 //! changing to DCDC mode, specific hardware considerations are required.
217 //!
218 //! This function is similar to PCMSetPowerMode, however a timeout
219 //! mechanism is used.
220 //!
221 //! Refer to the device specific data sheet for specifics about power modes.
222 //!
223 //! \param powerMode The voltage modes to be shifted to. Valid values are:
224 //!           - \b PCM_LDO_MODE,
225 //!           - \b PCM_DCDC_MODE,
226 //!           - \b PCM_LF_MODE
227 //!
228 //! \param timeOut Number of loop iterations to timeout when checking for
229 //!         power state transitions. This should be used for debugging initial
230 //!         power/hardware configurations. After a stable hardware base is
231 //!         established, the PCMSetPowerMode function should be used
232 //!
233 //! \return true if power mode is set, false otherwise.
234 //
235 //******************************************************************************
236 extern bool PCM_setPowerModeWithTimeout(uint_fast8_t powerMode,
237         uint32_t timeOut);
238 
239 //******************************************************************************
240 //
241 //! Sets the core voltage level (Vcore).  This function is similar to
242 //! PCM_setPowerMode, however there are no polling flags to ensure
243 //! a state has changed. Execution is returned back to the calling program
244 //  and it is up to the user to ensure proper state transitions happen
245 //! correctly. For MSP432, changing into different power modes/states
246 //! require very specific logic. This function will initiate only one state
247 //! transition and then return. It is up to the user to keep calling this
248 //! function until the correct power state has been achieved.
249 //!
250 //! Refer to the device specific data sheet for specifics about core voltage
251 //! levels.
252 //!
253 //! \param powerMode The voltage modes to be shifted to. Valid values are:
254 //!           - \b PCM_LDO_MODE,
255 //!           - \b PCM_DCDC_MODE,
256 //!           - \b PCM_LF_MODE
257 //!
258 //! \return true if power mode change was initiated, false otherwise
259 //
260 //******************************************************************************
261 extern bool PCM_setPowerModeNonBlocking(uint_fast8_t powerMode);
262 
263 //******************************************************************************
264 //
265 //! Returns the current powers state of the system see the \b PCM_setPowerState
266 //! function for specific information about the modes.
267 //!
268 //! \return The current power mode of the system
269 //!
270 //
271 //******************************************************************************
272 extern uint8_t PCM_getPowerMode(void);
273 
274 //******************************************************************************
275 //
276 //! Switches between power states. This is a convenience function that combines
277 //! the functionality of PCM_setPowerMode and PCM_setCoreVoltageLevel as well as
278 //! the LPM0/LPM3 functions.
279 //!
280 //! Refer to the device specific data sheet for specifics about power states.
281 //!
282 //! \param powerState The voltage modes to be shifted to. Valid values are:
283 //!           - \b PCM_AM_LDO_VCORE0,      [Active Mode, LDO, VCORE0]
284 //!           - \b PCM_AM_LDO_VCORE1,      [Active Mode, LDO, VCORE1]
285 //!           - \b PCM_AM_DCDC_VCORE0,     [Active Mode, DCDC, VCORE0]
286 //!           - \b PCM_AM_DCDC_VCORE1,     [Active Mode, DCDC, VCORE1]
287 //!           - \b PCM_AM_LF_VCORE0,       [Active Mode, Low Frequency, VCORE0]
288 //!           - \b PCM_AM_LF_VCORE1,       [Active Mode, Low Frequency, VCORE1]
289 //!           - \b PCM_LPM0_LDO_VCORE0,    [LMP0, LDO, VCORE0]
290 //!           - \b PCM_LPM0_LDO_VCORE1,    [LMP0, LDO, VCORE1]
291 //!           - \b PCM_LPM0_DCDC_VCORE0,   [LMP0, DCDC, VCORE0]
292 //!           - \b PCM_LPM0_DCDC_VCORE1,   [LMP0, DCDC, VCORE1]
293 //!           - \b PCM_LPM0_LF_VCORE0,     [LMP0, Low Frequency, VCORE0]
294 //!           - \b PCM_LPM0_LF_VCORE1,     [LMP0, Low Frequency, VCORE1]
295 //!           - \b PCM_LPM3,               [LPM3]
296 //!           - \b PCM_LPM35_VCORE0,       [LPM3.5 VCORE 0]
297 //!           - \b PCM_LPM4,               [LPM4]
298 //!           - \b PCM_LPM45,              [LPM4.5]
299 //!
300 //! \return true if power state is set, false otherwise.
301 //
302 //******************************************************************************
303 extern bool PCM_setPowerState(uint_fast8_t powerState);
304 
305 //******************************************************************************
306 //
307 //! Switches between power states. This is a convenience function that combines
308 //! the functionality of PCM_setPowerMode and PCM_setCoreVoltageLevel as well as
309 //! the LPM modes.
310 //!
311 //! This function is similar to PCM_setPowerState, however a timeout
312 //! mechanism is used.
313 //!
314 //! Refer to the device specific data sheet for specifics about power states.
315 //!
316 //! \param powerState The voltage modes to be shifted to. Valid values are:
317 //!           - \b PCM_AM_LDO_VCORE0,      [Active Mode, LDO, VCORE0]
318 //!           - \b PCM_AM_LDO_VCORE1,      [Active Mode, LDO, VCORE1]
319 //!           - \b PCM_AM_DCDC_VCORE0,     [Active Mode, DCDC, VCORE0]
320 //!           - \b PCM_AM_DCDC_VCORE1,     [Active Mode, DCDC, VCORE1]
321 //!           - \b PCM_AM_LF_VCORE0,       [Active Mode, Low Frequency, VCORE0]
322 //!           - \b PCM_AM_LF_VCORE1,       [Active Mode, Low Frequency, VCORE1]
323 //!           - \b PCM_LPM0_LDO_VCORE0,    [LMP0, LDO, VCORE0]
324 //!           - \b PCM_LPM0_LDO_VCORE1,    [LMP0, LDO, VCORE1]
325 //!           - \b PCM_LPM0_DCDC_VCORE0,   [LMP0, DCDC, VCORE0]
326 //!           - \b PCM_LPM0_DCDC_VCORE1,   [LMP0, DCDC, VCORE1]
327 //!           - \b PCM_LPM0_LF_VCORE0,     [LMP0, Low Frequency, VCORE0]
328 //!           - \b PCM_LPM0_LF_VCORE1,     [LMP0, Low Frequency, VCORE1]
329 //!           - \b PCM_LPM3,               [LPM3]
330 //!           - \b PCM_LPM35_VCORE0,       [LPM3.5 VCORE 0]
331 //!           - \b PCM_LPM4,               [LPM4]
332 //!           - \b PCM_LPM45,              [LPM4.5]
333 //!
334 //! \param timeout Number of loop iterations to timeout when checking for
335 //!         power state transitions. This should be used for debugging initial
336 //!         power/hardware configurations. After a stable hardware base is
337 //!         established, the PCMSetPowerMode function should be used
338 //!
339 //! \return true if power state is set, false otherwise. It is important to
340 //!         note that if a timeout occurs, false will be returned, however the
341 //!         power state at this point is not guaranteed to be the same as the
342 //!         state prior to the function call
343 //
344 //******************************************************************************
345 extern bool PCM_setPowerStateWithTimeout(uint_fast8_t powerState,
346         uint32_t timeout);
347 
348 //******************************************************************************
349 //
350 //! Returns the current powers state of the system see the PCMChangePowerState
351 //! function for specific information about the states.
352 //!
353 //! Refer to \link PCM_setPowerState \endlink for possible return values.
354 //!
355 //! \return The current power state of the system
356 //
357 //******************************************************************************
358 extern uint8_t PCM_getPowerState(void);
359 
360 //******************************************************************************
361 //
362 //! Sets the power state of the part.  This function is similar to
363 //! PCM_getPowerState, however there are no polling flags to ensure
364 //! a state has changed. Execution is returned back to the calling program
365 //  and it is up to the user to ensure proper state transitions happen
366 //! correctly. For MSP432, changing into different power modes/states
367 //! require very specific logic. This function will initiate only one state
368 //! transition and then return. It is up to the user to keep calling this
369 //! function until the correct power state has been achieved.
370 //!
371 //! Refer to the device specific data sheet for specifics about core voltage
372 //! levels.
373 //!
374 //! \param powerState The voltage modes to be shifted to. Valid values are:
375 //!           - \b PCM_AM_LDO_VCORE0,      [Active Mode, LDO, VCORE0]
376 //!           - \b PCM_AM_LDO_VCORE1,      [Active Mode, LDO, VCORE1]
377 //!           - \b PCM_AM_DCDC_VCORE0,     [Active Mode, DCDC, VCORE0]
378 //!           - \b PCM_AM_DCDC_VCORE1,     [Active Mode, DCDC, VCORE1]
379 //!           - \b PCM_AM_LF_VCORE0,       [Active Mode, Low Frequency, VCORE0]
380 //!           - \b PCM_AM_LF_VCORE1,       [Active Mode, Low Frequency, VCORE1]
381 //!           - \b PCM_LPM0_LDO_VCORE0,    [LMP0, LDO, VCORE0]
382 //!           - \b PCM_LPM0_LDO_VCORE1,    [LMP0, LDO, VCORE1]
383 //!           - \b PCM_LPM0_DCDC_VCORE0,   [LMP0, DCDC, VCORE0]
384 //!           - \b PCM_LPM0_DCDC_VCORE1,   [LMP0, DCDC, VCORE1]
385 //!           - \b PCM_LPM0_LF_VCORE0,     [LMP0, Low Frequency, VCORE0]
386 //!           - \b PCM_LPM0_LF_VCORE1,     [LMP0, Low Frequency, VCORE1]
387 //!           - \b PCM_LPM3,               [LPM3]
388 //!           - \b PCM_LPM35_VCORE0,       [LPM3.5 VCORE 0]
389 //!           - \b PCM_LPM45,              [LPM4.5]
390 //!
391 //! \return true if power state change was initiated, false otherwise
392 //
393 //******************************************************************************
394 extern bool PCM_setPowerStateNonBlocking(uint_fast8_t powerState);
395 
396 //******************************************************************************
397 //
398 //! Transitions the device into LPM3.5/LPM4.5 mode.
399 //!
400 //! Refer to the device specific data sheet for specifics about shutdown modes.
401 //!
402 //! The following events will cause a wake up from LPM3.5 mode:
403 //! - Device reset
404 //! - External reset RST
405 //! - Enabled RTC, WDT, and wake-up I/O only interrupt events
406 //!
407 //! The following events will cause a wake up from the LPM4.5 mode:
408 //! - Device reset
409 //! - External reset RST
410 //! - Wake-up I/O only interrupt events
411 //!
412 //! \param shutdownMode Specific mode to go to. Valid values are:
413 //!            - \b PCM_LPM35_VCORE0
414 //!            - \b PCM_LPM45
415 //!
416 //!
417 //! \return false if LPM state cannot be entered, true otherwise.
418 //
419 //******************************************************************************
420 extern bool PCM_shutdownDevice(uint32_t shutdownMode);
421 
422 //******************************************************************************
423 //
424 //! Transitions the device into LPM0.
425 //!
426 //! Refer to the device specific data sheet for specifics about low power modes.
427 //!
428 //! \return false if LPM0 state cannot be entered, true otherwise.
429 //
430 //******************************************************************************
431 extern bool PCM_gotoLPM0(void);
432 
433 //******************************************************************************
434 //
435 //! Transitions the device into LPM3
436 //!
437 //! Refer to the device specific data sheet for specifics about low power modes.
438 //! Note that since LPM3 cannot be entered from  a DCDC power modes, the
439 //! power mode is first switched to LDO operation (if in DCDC mode),
440 //! LPM3 is entered, and the DCDC mode is restored on wake up.
441 //!
442 //! \return false if LPM3 state cannot be entered, true otherwise.
443 //
444 //******************************************************************************
445 extern bool PCM_gotoLPM3(void);
446 
447 //******************************************************************************
448 //
449 //! Transitions the device into LPM0 while maintaining a safe
450 //! interrupt handling mentality. This function is meant to be used in
451 //! situations where the user wants to go to LPM0, however does not want
452 //! to go to "miss" any interrupts due to the fact that going to LPM0 is not
453 //! an atomic operation. This function will modify the PRIMASK and on exit of
454 //! the program the master interrupts will be disabled.
455 //!
456 //! Refer to the device specific data sheet for specifics about low power modes.
457 //!
458 //! \return false if LPM0 state cannot be entered, true otherwise.
459 //
460 //******************************************************************************
461 extern bool PCM_gotoLPM0InterruptSafe(void);
462 
463 //******************************************************************************
464 //
465 //! Transitions the device into LPM3 while maintaining a safe
466 //! interrupt handling mentality. This function is meant to be used in
467 //! situations where the user wants to go to LPM3, however does not want
468 //! to go to "miss" any interrupts due to the fact that going to LPM3 is not
469 //! an atomic operation. This function will modify the PRIMASK and on exit of
470 //! the program the master interrupts will be disabled.
471 //!
472 //! Refer to the device specific data sheet for specifics about low power modes.
473 //! Note that since LPM3 cannot be entered from  a DCDC power modes, the
474 //! power mode is first switched to LDO operation (if in DCDC mode), the LPM3
475 //! is entered, and the DCDC mode is restored on wake up.
476 //!
477 //! \return false if LPM3 cannot be entered, true otherwise.
478 //
479 //******************************************************************************
480 extern bool PCM_gotoLPM3InterruptSafe(void);
481 
482 //******************************************************************************
483 //
484 //! Transitions the device into LPM4. LPM4 is the exact same with LPM3, just
485 //! with RTC_C and WDT_A disabled. When waking up, RTC_C and WDT_A will remain
486 //! disabled until reconfigured by the user.
487 //!
488 //! \return false if LPM4 state cannot be entered, true otherwise.
489 //
490 //******************************************************************************
491 extern bool PCM_gotoLPM4(void);
492 
493 //******************************************************************************
494 //
495 //! Transitions the device into LPM4 while maintaining a safe
496 //! interrupt handling mentality. This function is meant to be used in
497 //! situations where the user wants to go to LPM4, however does not want
498 //! to go to "miss" any interrupts due to the fact that going to LPM4 is not
499 //! an atomic operation. This function will modify the PRIMASK and on exit of
500 //! the program the master interrupts will be disabled.
501 //!
502 //! Refer to the device specific data sheet for specifics about low power modes.
503 //! Note that since LPM3 cannot be entered from  a DCDC power modes, the
504 //! power mode is first switched to LDO operation (if in DCDC mode),
505 //! LPM4 is entered, and the DCDC mode is restored on wake up.
506 //!
507 //! \return false if LPM4 state cannot be entered, true otherwise.
508 //
509 //******************************************************************************
510 extern bool PCM_gotoLPM4InterruptSafe(void);
511 
512 //******************************************************************************
513 //
514 //! Enables "rude mode" entry into LPM3 and shutdown modes. With this mode
515 //! enabled, an entry into shutdown or LPM3 will occur even if there are
516 //! clock systems active. The system will forcibly  turn off all clock/systems
517 //! when going into these modes.
518 //!
519 //! \return None
520 //
521 //******************************************************************************
522 extern void PCM_enableRudeMode(void);
523 
524 //******************************************************************************
525 //
526 //! Disables "rude mode" entry into LPM3 and shutdown modes. With this
527 //! mode disabled, an entry into shutdown or LPM3 will wait for any
528 //! active clock requests to free up before going into LPM3 or shutdown.
529 //!
530 //! \return None
531 //
532 //******************************************************************************
533 extern void PCM_disableRudeMode(void);
534 
535 //*****************************************************************************
536 //
537 //! Enables individual power control interrupt sources.
538 //!
539 //! \param flags is a bit mask of the interrupt sources to be enabled.  Must
540 //! be a logical OR of:
541 //!         - \b PCM_DCDCERROR,
542 //!         - \b PCM_AM_INVALIDTRANSITION,
543 //!         - \b PCM_SM_INVALIDCLOCK,
544 //!         - \b PCM_SM_INVALIDTRANSITION
545 //!
546 //! This function enables the indicated power control interrupt sources.  Only
547 //! the sources that are enabled can be reflected to the processor interrupt;
548 //! disabled sources have no effect on the processor.
549 //!
550 //! \note The interrupt sources vary based on the part in use.
551 //! Please consult the data sheet for the part you are using to determine
552 //! which interrupt sources are available.
553 //!
554 //! \return None.
555 //
556 //*****************************************************************************
557 extern void PCM_enableInterrupt(uint32_t flags);
558 
559 //*****************************************************************************
560 //
561 //! Disables individual power control interrupt sources.
562 //!
563 //! \param flags is a bit mask of the interrupt sources to be enabled.  Must
564 //! be a logical OR of:
565 //!         - \b PCM_DCDCERROR,
566 //!         - \b PCM_AM_INVALIDTRANSITION,
567 //!         - \b PCM_SM_INVALIDCLOCK,
568 //!         - \b PCM_SM_INVALIDTRANSITION
569 //!
570 //! This function disables the indicated power control interrupt sources.  Only
571 //! the sources that are enabled can be reflected to the processor interrupt;
572 //! disabled sources have no effect on the processor.
573 //!
574 //! \note The interrupt sources vary based on the part in use.
575 //! Please consult the data sheet for the part you are using to determine
576 //! which interrupt sources are available.
577 //!
578 //! \return None.
579 //
580 //*****************************************************************************
581 extern void PCM_disableInterrupt(uint32_t flags);
582 
583 //*****************************************************************************
584 //
585 //! Gets the current interrupt status.
586 //!
587 //! \return The current interrupt status, enumerated as a bit field of:
588 //!         - \b PCM_DCDCERROR,
589 //!         - \b PCM_AM_INVALIDTRANSITION,
590 //!         - \b PCM_SM_INVALIDCLOCK,
591 //!         - \b PCM_SM_INVALIDTRANSITION
592 //!
593 //! \note The interrupt sources vary based on the part in use.
594 //! Please consult the data sheet for the part you are using to determine
595 //! which interrupt sources are available.
596 //
597 //*****************************************************************************
598 extern uint32_t PCM_getInterruptStatus(void);
599 
600 //*****************************************************************************
601 //
602 //! Gets the current interrupt status masked with the enabled interrupts.
603 //! This function is useful to call in ISRs to get a list of pending
604 //! interrupts that are actually enabled and could have caused
605 //! the ISR.
606 //!
607 //! \return The current interrupt status, enumerated as a bit field of:
608 //!         - \b PCM_DCDCERROR,
609 //!         - \b PCM_AM_INVALIDTRANSITION,
610 //!         - \b PCM_SM_INVALIDCLOCK,
611 //!         - \b PCM_SM_INVALIDTRANSITION
612 //!
613 //! \note The interrupt sources vary based on the part in use.
614 //! Please consult the data sheet for the part you are using to determine
615 //! which interrupt sources are available.
616 //
617 //*****************************************************************************
618 extern uint32_t PCM_getEnabledInterruptStatus(void);
619 
620 //*****************************************************************************
621 //
622 //! Clears power system interrupt sources.
623 //!
624 //! The specified power system interrupt sources are cleared, so that they no
625 //! longer assert.  This function must be called in the interrupt handler to
626 //! keep it from being called again immediately upon exit.
627 //!
628 //! \note Because there is a write buffer in the Cortex-M processor, it may
629 //! take several clock cycles before the interrupt source is actually cleared.
630 //! Therefore, it is recommended that the interrupt source be cleared early in
631 //! the interrupt handler (as opposed to the very last action) to avoid
632 //! returning from the interrupt handler before the interrupt source is
633 //! actually cleared.  Failure to do so may result in the interrupt handler
634 //! being immediately reentered (because the interrupt controller still sees
635 //! the interrupt source asserted).
636 //!
637 //! \param flags is a bit mask of the interrupt sources to be cleared.  Must
638 //! be a logical OR of
639 //!         - \b PCM_DCDCERROR,
640 //!         - \b PCM_AM_INVALIDTRANSITION,
641 //!         - \b PCM_SM_INVALIDCLOCK,
642 //!         - \b PCM_SM_INVALIDTRANSITION
643 //!
644 //! \note The interrupt sources vary based on the part in use.
645 //! Please consult the data sheet for the part you are using to determine
646 //! which interrupt sources are available.
647 //!
648 //! \return None.
649 //
650 //*****************************************************************************
651 extern void PCM_clearInterruptFlag(uint32_t flags);
652 
653 //*****************************************************************************
654 //
655 //! Registers an interrupt handler for the power system interrupt.
656 //!
657 //! \param intHandler is a pointer to the function to be called when the power
658 //! system interrupt occurs.
659 //!
660 //! This function registers the handler to be called when a clock system
661 //! interrupt occurs. This function enables the global interrupt in the
662 //! interrupt controller; specific PCM  interrupts must be enabled
663 //! via PCM_enableInterrupt().  It is the interrupt handler's responsibility to
664 //! clear the interrupt source via \link PCM_clearInterruptFlag \endlink .
665 //!
666 //! \sa Interrupt_registerInterrupt() for important information about
667 //! registering interrupt handlers.
668 //!
669 //! \return None.
670 //
671 //*****************************************************************************
672 extern void PCM_registerInterrupt(void (*intHandler)(void));
673 
674 //*****************************************************************************
675 //
676 //! Unregisters the interrupt handler for the power system.
677 //!
678 //! This function unregisters the handler to be called when a power system
679 //! interrupt occurs.  This function also masks off the interrupt in the
680 //! interrupt controller so that the interrupt handler no longer is called.
681 //!
682 //! \sa Interrupt_registerInterrupt() for important information about
683 //! registering interrupt handlers.
684 //!
685 //! \return None.
686 //
687 //*****************************************************************************
688 extern void PCM_unregisterInterrupt(void);
689 
690 //*****************************************************************************
691 //
692 // Mark the end of the C bindings section for C++ compilers.
693 //
694 //*****************************************************************************
695 #ifdef __cplusplus
696 }
697 #endif
698 
699 //*****************************************************************************
700 //
701 // Close the Doxygen group.
702 //! @}
703 //
704 //*****************************************************************************
705 
706 #endif // __PCM_H__
707