Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
power_states.h
1 /*
2  * {% copyright %}
3  */
4 
5 #ifndef __POWER_STATES_H__
6 #define __POWER_STATES_H__
7 
8 #include "qm_common.h"
9 #include "qm_soc_regs.h"
10 
11 /**
12  * Power mode control for Quark D2000 Microcontrollers.
13  *
14  * @defgroup groupD2000Power Quark D2000 Power states
15  * @{
16  */
17 
18 /**
19 * Wake source for deep sleep mode type.
20 */
21 typedef enum {
22  /** Use GPIO/Comparator as wake source. */
24  QM_POWER_WAKE_FROM_RTC, /**< Use RTC as wake source. */
26 
27 /**
28  * Put CPU in halt state.
29  *
30  * Halts the CPU until next interrupt or reset.
31  *
32  * This function can be called with interrupts disabled.
33  * Interrupts will be enabled before triggering the transition.
34  */
35 void qm_power_cpu_halt(void);
36 
37 /**
38  * Put SoC to sleep.
39  *
40  * Enter into sleep mode. The hybrid oscillator is disabled, most peripherals
41  * are disabled and the voltage regulator is set into retention mode.
42  * The following peripherals are disabled in this mode:
43  * - I2C
44  * - SPI
45  * - GPIO debouncing
46  * - Watchdog timer
47  * - PWM / Timers
48  * - UART
49  *
50  * The SoC operates from the 32 kHz clock source and the following peripherals
51  * may bring the SoC back into an active state:
52  *
53  * - GPIO interrupts
54  * - AON Timers
55  * - RTC
56  * - Low power comparators
57  */
58 void qm_power_soc_sleep();
59 
60 /**
61  * Put SoC to deep sleep.
62  *
63  * Enter into deep sleep mode. All clocks are gated. The Wake source for this
64  * function depends on the input parameter, QM_POWER_WAKE_FROM_GPIO_COMP will
65  * enable waking from GPIO or comparator pins and QM_POWER_WAKE_FROM_RTC will
66  * enable waking from the RTC.
67  *
68  * @param[in] wake_event Select wake source for deep sleep mode.
69  */
70 void qm_power_soc_deep_sleep(const qm_power_wake_event_t wake_event);
71 
72 /**
73  * Restore system state after sleep or deep sleep.
74  *
75  * On wakeup, the system is restored to the previous state before
76  * qm_power_soc_sleep() or qm_power_soc_deep_sleep() was called.
77  */
78 void qm_power_soc_restore(void);
79 
80 /**
81  * Retention alternator regulator for Quark D2000.
82  *
83  * @defgroup groupRAR Quark(TM) D2000 Retention Alternator Regulator (RAR).
84  * @{
85  */
86 
87 /**
88  * RAR modes type.
89  */
90 typedef enum {
91  QM_RAR_NORMAL, /**< Normal mode = 50 mA. */
92  QM_RAR_RETENTION /**< Retention mode = 300 uA. */
94 
95 /**
96  * Change operating mode of RAR.
97  *
98  * Normal mode is able to source up to 50 mA.
99  * Retention mode is able to source up to 300 uA.
100  * Care must be taken when entering into retention mode
101  * to ensure the overall system draw is less than 300 uA.
102  *
103  * @param[in] mode Operating mode of the RAR.
104  *
105  * @return Standard errno return type for QMSI.
106  * @retval 0 on success.
107  * @retval Negative @ref errno for possible error codes.
108  */
109 int qm_rar_set_mode(const qm_rar_state_t mode);
110 
111 /**
112  * @}
113  */
114 #endif /* __POWER_STATES_H__ */
void qm_power_soc_restore(void)
Restore system state after sleep or deep sleep.
Definition: power_states.c:402
int qm_rar_set_mode(const qm_rar_state_t mode)
Change operating mode of RAR.
Definition: power_states.c:415
Normal mode = 50 mA.
Definition: power_states.h:91
Retention mode = 300 uA.
Definition: power_states.h:92
void qm_power_soc_deep_sleep(const qm_power_wake_event_t wake_event)
Put SoC to deep sleep.
Definition: power_states.c:180
Use RTC as wake source.
Definition: power_states.h:24
Use GPIO/Comparator as wake source.
Definition: power_states.h:23
qm_rar_state_t
RAR modes type.
Definition: power_states.h:90
void qm_power_soc_sleep()
Put SoC to sleep.
Definition: power_states.c:59
qm_power_wake_event_t
Wake source for deep sleep mode type.
Definition: power_states.h:21
void qm_power_cpu_halt(void)
Put CPU in halt state.
Definition: power_states.c:29