gr55xx_pwr.h
Go to the documentation of this file.
1
50 #ifndef __GR55XX_PWR_H_
51 #define __GR55XX_PWR_H_
52
53 #include <stdint.h>
54 #include <stdbool.h>
55 #include <stdio.h>
56
57 #include "system_gr55xx.h"
58
71 typedef struct
72 {
73 uint32_t pwr_mgmt_app_timer_thrd;
74 uint32_t pwr_mgmt_ble_core_thrd;
75 uint32_t pwr_mgmt_rtc_timer_thrd;
76 } pwr_mgmt_var_box_t;
77
79 typedef enum
80 {
81 COLD_BOOT = 0,
82 WARM_BOOT,
83 } boot_mode_t;
84
86 typedef enum
87 {
88 PMR_MGMT_ACTIVE_MODE = 0x0,
89 PMR_MGMT_IDLE_MODE,
90 PMR_MGMT_SLEEP_MODE,
91 } pwr_mgmt_mode_t;
92
94 typedef enum
95 {
96 DEVICE_BUSY = 0x0,
97 DEVICE_IDLE,
98 } pwr_mgmt_dev_state_t;
99
101 typedef enum
102 {
103 EVENT_APP_TIMER_START = 0,
104 EVENT_APP_TIMER_STOP,
105 } notify_timer_event_t;
106
108 enum
109 {
110 TRC_PWR_WFE_MODE = 0,
111 TRC_PWR_DSLEEP_MODE,
112 TRC_PWR_ACTIVE_MODE,
113 TRC_PWR_BLE_RET_DSLEEP,
114 TRC_PWR_APP_TIMER_REFUSE,
115 TRC_PWR_APP_TIMER_PASS,
116 TRC_PWR_BLE_TIMER_PASS,
117 };
118
120 typedef struct
121 {
122 uint16_t pwr_dur;
123 uint16_t pwr_ext;
124 uint16_t pwr_osc;
125 uint8_t pwr_delay_hslot;
126 uint16_t pwr_delay_hus;
127 uint16_t pwr_push_hus;
128 uint32_t pwr_timer_ths;
129 uint32_t pwr_ble_ths;
130 } pwr_table_t;
131
133 typedef void (*trace_func_t)(uint8_t);
134
136 typedef void (*periph_func_t)(void);
137
139 typedef void (*pwr_before_sleep_func_t)(void);
140
142 typedef pwr_mgmt_dev_state_t (*pwr_dev_check_func_t)(void);
143
145 typedef void (*io_dump_func_t)(void);
146
148 typedef void (*mem_check_proc_t)(void);
149
151 extern pwr_table_t pwr_table[];
152
166 pwr_mgmt_mode_t pwr_mgmt_shutdown(void);
167
174 boot_mode_t pwr_mgmt_get_wakeup_flag(void);
175
183 void pwr_mgmt_set_wakeup_flag(boot_mode_t boot_mode);
184
193 void pwr_mgmt_mode_set(pwr_mgmt_mode_t pm_mode);
194
201 pwr_mgmt_mode_t pwr_mgmt_mode_get(void);
202
209 pwr_mgmt_mode_t pwr_mgmt_baseband_state_get(void);
210
217 pwr_mgmt_mode_t pwr_mgmt_check_ext_timer(void);
218
219
220
231 void pwr_mgmt_schedule(void);
232
244 bool pwr_mgmt_ble_wakeup(void);
245
246
253 void pwr_mgmt_check_ble_event(void);
254
255
265 void pwr_mgmt_notify_timer_event(notify_timer_event_t timer_event);
266
273 pwr_mgmt_mode_t pwr_mgmt_get_sleep_mode(void);
274
275
282 void pwr_mgmt_update_wkup_param(void);
283
291 void pwr_mgmt_wfe_sleep(void);
292
303 void pwr_mgmt_ultra_sleep(uint32_t time_ms);
304
313 void pwr_mgmt_init( pwr_table_t *p_pwr_table, mcu_clock_type_t sys_clk);
314
322 void pwr_mgmt_dev_init(periph_func_t p_periph_init);
323
330 void pwr_mgmt_dev_resume(void);
331
338 pwr_mgmt_dev_state_t pwr_mgmt_dev_suspend(void);
339
348 void pwr_mgmt_mem_ctl_set(uint32_t mem_sleep_state, uint32_t mem_work_state);
349
358 void pwr_mgmt_set_callback(pwr_dev_check_func_t dev_check_fun, pwr_before_sleep_func_t before_sleep_fun);
359
373 void pwr_mgmt_wakeup_source_setup(uint32_t wakeup_source);
374
388 void pwr_mgmt_wakeup_source_clear(uint32_t wakeup_source);
389
396 void pwr_mgmt_save_context(void);
397
404 void pwr_mgmt_load_context(void);
405
412 void pwr_mgmt_disable_nvic_irq(void);
413
420 void pwr_mgmt_enable_nvic_irq(void);
421
428 bool pwr_mgmt_check_pend_irq(void);
429
437 void pwr_mgmt_register_trace_func(trace_func_t trace_func);
438
445 void pwr_mgmt_register_io_dump_func(io_dump_func_t dump_func);
446
449 #endif
450
pwr_mgmt_ble_wakeup
bool pwr_mgmt_ble_wakeup(void)
Wake the BLE core via an external request.
io_dump_func_t
void(* io_dump_func_t)(void)
function registered to dump io configuration.
Definition: gr55xx_pwr.h:145
pwr_table_t::pwr_osc
uint16_t pwr_osc
Definition: gr55xx_pwr.h:124
TRC_PWR_BLE_RET_DSLEEP
@ TRC_PWR_BLE_RET_DSLEEP
Definition: gr55xx_pwr.h:113
pwr_table_t::pwr_ble_ths
uint32_t pwr_ble_ths
Definition: gr55xx_pwr.h:129
pwr_mgmt_get_sleep_mode
pwr_mgmt_mode_t pwr_mgmt_get_sleep_mode(void)
Query the sleep mode that the current system can access.
pwr_mgmt_init
void pwr_mgmt_init(pwr_table_t *p_pwr_table, mcu_clock_type_t sys_clk)
PMU Initialization Function.
pwr_mgmt_baseband_state_get
pwr_mgmt_mode_t pwr_mgmt_baseband_state_get(void)
Get the power state of baseband.
pwr_mgmt_mode_t
pwr_mgmt_mode_t
power manager model.
Definition: gr55xx_pwr.h:87
pwr_mgmt_mode_set
void pwr_mgmt_mode_set(pwr_mgmt_mode_t pm_mode)
Set the specified sleep mode. When the setting is completed, the system will automatically enter the ...
pwr_mgmt_ultra_sleep
void pwr_mgmt_ultra_sleep(uint32_t time_ms)
Execution of this function allows ARM to enter the ultra sleep state and wakeup the chip when an even...
pwr_table
pwr_table_t pwr_table[]
pwr table.
pwr_dev_check_func_t
pwr_mgmt_dev_state_t(* pwr_dev_check_func_t)(void)
Device check function type.
Definition: gr55xx_pwr.h:142
pwr_mgmt_dev_init
void pwr_mgmt_dev_init(periph_func_t p_periph_init)
Peripheral Controller Initialization Register interface.
pwr_table_t::pwr_ext
uint16_t pwr_ext
Definition: gr55xx_pwr.h:123
periph_func_t
void(* periph_func_t)(void)
Peripheral function type.
Definition: gr55xx_pwr.h:136
pwr_mgmt_load_context
void pwr_mgmt_load_context(void)
Load context function.
pwr_mgmt_var_box_t
power manager setting parameter. Use pwr_mgmt_var_set to transfer the parameters in the structure to ...
Definition: gr55xx_pwr.h:72
pwr_table_t
parameter configuration table.
Definition: gr55xx_pwr.h:121
pwr_mgmt_mem_ctl_set
void pwr_mgmt_mem_ctl_set(uint32_t mem_sleep_state, uint32_t mem_work_state)
Mem state control under deep sleep & work state.
pwr_table_t::pwr_delay_hus
uint16_t pwr_delay_hus
Definition: gr55xx_pwr.h:126
DEVICE_BUSY
@ DEVICE_BUSY
Definition: gr55xx_pwr.h:96
boot_mode_t
boot_mode_t
power manager boot type.
Definition: gr55xx_pwr.h:80
pwr_mgmt_register_trace_func
void pwr_mgmt_register_trace_func(trace_func_t trace_func)
Trace function register.
TRC_PWR_DSLEEP_MODE
@ TRC_PWR_DSLEEP_MODE
Definition: gr55xx_pwr.h:111
pwr_table_t::pwr_delay_hslot
uint8_t pwr_delay_hslot
Definition: gr55xx_pwr.h:125
pwr_mgmt_check_ble_event
void pwr_mgmt_check_ble_event(void)
Check whether there are ble events in the queue, and if so, handle them immediately.
pwr_mgmt_wakeup_source_clear
void pwr_mgmt_wakeup_source_clear(uint32_t wakeup_source)
Clear the wakeup source.
pwr_mgmt_mode_get
pwr_mgmt_mode_t pwr_mgmt_mode_get(void)
Get the specified sleep mode.
pwr_mgmt_notify_timer_event
void pwr_mgmt_notify_timer_event(notify_timer_event_t timer_event)
This function is used to push startup information in app timer. This information will optimize power ...
TRC_PWR_WFE_MODE
@ TRC_PWR_WFE_MODE
Definition: gr55xx_pwr.h:110
TRC_PWR_APP_TIMER_REFUSE
@ TRC_PWR_APP_TIMER_REFUSE
Definition: gr55xx_pwr.h:114
pwr_mgmt_wakeup_source_setup
void pwr_mgmt_wakeup_source_setup(uint32_t wakeup_source)
Set the wakeup source.
pwr_mgmt_check_ext_timer
pwr_mgmt_mode_t pwr_mgmt_check_ext_timer(void)
Get the state of extenal timer.
notify_timer_event_t
notify_timer_event_t
power manager app timer work state.
Definition: gr55xx_pwr.h:102
pwr_mgmt_var_box_t::pwr_mgmt_rtc_timer_thrd
uint32_t pwr_mgmt_rtc_timer_thrd
Definition: gr55xx_pwr.h:75
WARM_BOOT
@ WARM_BOOT
Definition: gr55xx_pwr.h:82
pwr_mgmt_dev_resume
void pwr_mgmt_dev_resume(void)
Device config resume interface.
EVENT_APP_TIMER_START
@ EVENT_APP_TIMER_START
Definition: gr55xx_pwr.h:103
pwr_before_sleep_func_t
void(* pwr_before_sleep_func_t)(void)
Before sleep function type.
Definition: gr55xx_pwr.h:139
pwr_mgmt_disable_nvic_irq
void pwr_mgmt_disable_nvic_irq(void)
Disable nvic irq.
pwr_mgmt_update_wkup_param
void pwr_mgmt_update_wkup_param(void)
Update wakeup param.
pwr_table_t::pwr_timer_ths
uint32_t pwr_timer_ths
Definition: gr55xx_pwr.h:128
pwr_mgmt_check_pend_irq
bool pwr_mgmt_check_pend_irq(void)
Check nvic irq.
pwr_mgmt_schedule
void pwr_mgmt_schedule(void)
Sleep Policy Scheduling Function. Note that:
pwr_mgmt_var_box_t::pwr_mgmt_ble_core_thrd
uint32_t pwr_mgmt_ble_core_thrd
Definition: gr55xx_pwr.h:74
pwr_table_t::pwr_push_hus
uint16_t pwr_push_hus
Definition: gr55xx_pwr.h:127
mem_check_proc_t
void(* mem_check_proc_t)(void)
mem check process type.
Definition: gr55xx_pwr.h:148
pwr_mgmt_save_context
void pwr_mgmt_save_context(void)
Save context function.
DEVICE_IDLE
@ DEVICE_IDLE
Definition: gr55xx_pwr.h:97
pwr_mgmt_var_box_t::pwr_mgmt_app_timer_thrd
uint32_t pwr_mgmt_app_timer_thrd
Definition: gr55xx_pwr.h:73
PMR_MGMT_ACTIVE_MODE
@ PMR_MGMT_ACTIVE_MODE
Definition: gr55xx_pwr.h:88
COLD_BOOT
@ COLD_BOOT
Definition: gr55xx_pwr.h:81
TRC_PWR_BLE_TIMER_PASS
@ TRC_PWR_BLE_TIMER_PASS
Definition: gr55xx_pwr.h:116
pwr_mgmt_wfe_sleep
void pwr_mgmt_wfe_sleep(void)
Execution of this function allows ARM to enter the WFE state and exit the WFE state when an event or ...
pwr_mgmt_dev_state_t
pwr_mgmt_dev_state_t
power manager device work state.
Definition: gr55xx_pwr.h:95
trace_func_t
void(* trace_func_t)(uint8_t)
Trace function type.
Definition: gr55xx_pwr.h:133
pwr_mgmt_register_io_dump_func
void pwr_mgmt_register_io_dump_func(io_dump_func_t dump_func)
function registered to dump io configuration.
TRC_PWR_ACTIVE_MODE
@ TRC_PWR_ACTIVE_MODE
Definition: gr55xx_pwr.h:112
pwr_mgmt_get_wakeup_flag
boot_mode_t pwr_mgmt_get_wakeup_flag(void)
Get the current boot mode.
pwr_mgmt_enable_nvic_irq
void pwr_mgmt_enable_nvic_irq(void)
Enable nvic irq.
pwr_table_t::pwr_dur
uint16_t pwr_dur
Definition: gr55xx_pwr.h:122
PMR_MGMT_SLEEP_MODE
@ PMR_MGMT_SLEEP_MODE
Definition: gr55xx_pwr.h:90
pwr_mgmt_shutdown
pwr_mgmt_mode_t pwr_mgmt_shutdown(void)
This function allows ARM to enter deep sleep mode, but users should not use this function directly....
pwr_mgmt_set_callback
void pwr_mgmt_set_callback(pwr_dev_check_func_t dev_check_fun, pwr_before_sleep_func_t before_sleep_fun)
Set PMU callback function.
EVENT_APP_TIMER_STOP
@ EVENT_APP_TIMER_STOP
Definition: gr55xx_pwr.h:104
pwr_mgmt_set_wakeup_flag
void pwr_mgmt_set_wakeup_flag(boot_mode_t boot_mode)
Mark the mode of next boot, cold boot or warm boot.
TRC_PWR_APP_TIMER_PASS
@ TRC_PWR_APP_TIMER_PASS
Definition: gr55xx_pwr.h:115
pwr_mgmt_dev_suspend
pwr_mgmt_dev_state_t pwr_mgmt_dev_suspend(void)
Device config suspend interface.
PMR_MGMT_IDLE_MODE
@ PMR_MGMT_IDLE_MODE
Definition: gr55xx_pwr.h:89