platform_power.h
1 #pragma once 2 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #include <stdbool.h> 8 9 #include "sdk_errors.h" 10 11 typedef enum 12 { 13 PLATFORM_POWER_SLEEP, // a low-power idle state, not quite off 14 PLATFORM_POWER_OFF, // battery is dead and we are shutting down for good. 15 PLATFORM_POWER_DFU, // reboot to DFU mode. 16 PLATFORM_POWER_RESET, // reboot 17 PLATFORM_POWER_CONTINUE_SHUTDOWN, // used if a module blocks shutdown, to continue it. 18 } platform_power_shutdown_t; 19 20 typedef enum 21 { 22 PLATFORM_POWER_EVENT_PREPARE_WAKEUP = PLATFORM_POWER_SLEEP, 23 PLATFORM_POWER_EVENT_PREPARE_OFF = PLATFORM_POWER_OFF, 24 PLATFORM_POWER_EVENT_PREPARE_DFU = PLATFORM_POWER_DFU, 25 PLATFORM_POWER_EVENT_PREPARE_RESET = PLATFORM_POWER_RESET, 26 } platform_power_event_t; 27 28 typedef struct platform_power_driver_s { 29 ret_code_t (*initialize)(void); 30 void (*update)(void); 31 void (*feed)(void); 32 void (*shutdown)(platform_power_shutdown_t); 33 bool (*event_handler)(platform_power_event_t); 34 } platform_power_driver_t; 35 36 #ifdef NRF52840_XXAA 37 extern platform_power_driver_t platform_power_nrf52; 38 #endif //DNRF52840_XXAA 39 40 #ifdef __cplusplus 41 } 42 #endif