123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- #ifndef NRFX_POWER_H__
- #define NRFX_POWER_H__
- #include <nrfx.h>
- #include <hal/nrf_power.h>
- #include <nrfx_power_clock.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef enum
- {
- NRFX_POWER_MODE_CONSTLAT,
- NRFX_POWER_MODE_LOWPWR
- }nrfx_power_mode_t;
- #if NRF_POWER_HAS_SLEEPEVT || defined(__NRFX_DOXYGEN__)
- typedef enum
- {
- NRFX_POWER_SLEEP_EVT_ENTER,
- NRFX_POWER_SLEEP_EVT_EXIT
- }nrfx_power_sleep_evt_t;
- #endif
- #if NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
- typedef enum
- {
- NRFX_POWER_USB_EVT_DETECTED,
- NRFX_POWER_USB_EVT_REMOVED,
- NRFX_POWER_USB_EVT_READY
- }nrfx_power_usb_evt_t;
- typedef enum
- {
- NRFX_POWER_USB_STATE_DISCONNECTED,
- NRFX_POWER_USB_STATE_CONNECTED,
- NRFX_POWER_USB_STATE_READY
- }nrfx_power_usb_state_t;
- #endif
- typedef void (*nrfx_power_pofwarn_event_handler_t)(void);
- #if NRF_POWER_HAS_SLEEPEVT || defined(__NRFX_DOXYGEN__)
- typedef void (*nrfx_power_sleep_event_handler_t)(nrfx_power_sleep_evt_t event);
- #endif
- #if NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
- typedef void (*nrfx_power_usb_event_handler_t)(nrfx_power_usb_evt_t event);
- #endif
- typedef struct
- {
-
- bool dcdcen:1;
- #if NRF_POWER_HAS_VDDH || defined(__NRFX_DOXYGEN__)
-
- bool dcdcenhv: 1;
- #endif
- }nrfx_power_config_t;
- typedef struct
- {
- nrfx_power_pofwarn_event_handler_t handler;
- #if NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
- nrf_power_pof_thr_t thr;
- #endif
- #if NRF_POWER_HAS_VDDH || defined(__NRFX_DOXYGEN__)
- nrf_power_pof_thrvddh_t thrvddh;
- #endif
- }nrfx_power_pofwarn_config_t;
- #if NRF_POWER_HAS_SLEEPEVT || defined(__NRFX_DOXYGEN__)
- typedef struct
- {
- nrfx_power_sleep_event_handler_t handler;
- bool en_enter:1;
- bool en_exit :1;
- }nrfx_power_sleepevt_config_t;
- #endif
- #if NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
- typedef struct
- {
- nrfx_power_usb_event_handler_t handler;
- }nrfx_power_usbevt_config_t;
- #endif
- nrfx_power_pofwarn_event_handler_t nrfx_power_pof_handler_get(void);
- #if NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
- nrfx_power_usb_event_handler_t nrfx_power_usb_handler_get(void);
- #endif
- nrfx_err_t nrfx_power_init(nrfx_power_config_t const * p_config);
- void nrfx_power_uninit(void);
- #if NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
- void nrfx_power_pof_init(nrfx_power_pofwarn_config_t const * p_config);
- void nrfx_power_pof_enable(nrfx_power_pofwarn_config_t const * p_config);
- void nrfx_power_pof_disable(void);
- void nrfx_power_pof_uninit(void);
- #endif
- #if NRF_POWER_HAS_SLEEPEVT || defined(__NRFX_DOXYGEN__)
- void nrfx_power_sleepevt_init(nrfx_power_sleepevt_config_t const * p_config);
- void nrfx_power_sleepevt_enable(nrfx_power_sleepevt_config_t const * p_config);
- void nrfx_power_sleepevt_disable(void);
- void nrfx_power_sleepevt_uninit(void);
- #endif
- #if NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
- void nrfx_power_usbevt_init(nrfx_power_usbevt_config_t const * p_config);
- void nrfx_power_usbevt_enable(void);
- void nrfx_power_usbevt_disable(void);
- void nrfx_power_usbevt_uninit(void);
- __STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void);
- #endif
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- #if NRF_POWER_HAS_USBREG
- __STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
- {
- uint32_t status = nrf_power_usbregstatus_get();
- if(0 == (status & NRF_POWER_USBREGSTATUS_VBUSDETECT_MASK))
- {
- return NRFX_POWER_USB_STATE_DISCONNECTED;
- }
- if(0 == (status & NRF_POWER_USBREGSTATUS_OUTPUTRDY_MASK))
- {
- return NRFX_POWER_USB_STATE_CONNECTED;
- }
- return NRFX_POWER_USB_STATE_READY;
- }
- #endif
- #endif
- void nrfx_power_irq_handler(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|