14 #if RUUVI_NRF5_SDK15_YIELD_ENABLED
18 #include "nrf_delay.h"
19 #include "nrf_pwr_mgmt.h"
20 #include "nrf_error.h"
21 #if RUUVI_NRF5_SDK15_TIMER_ENABLED
26 static bool m_lp =
false;
27 static bool m_is_init =
false;
28 static volatile bool m_wakeup =
false;
32 #define IOC_MASK (0x01U)
33 #define DZC_MASK (0x02U)
34 #define OFC_MASK (0x04U)
39 void FPU_IRQHandler (
void)
43 uint32_t * fpscr = (uint32_t *) (FPU->FPCAR + 0x40);
52 if (*fpscr & IOC_MASK)
57 if (*fpscr & DZC_MASK)
62 if (*fpscr & OFC_MASK)
68 *fpscr = *fpscr & ~ (0x0000009F);
71 static void fpu_init (
void)
73 NVIC_SetPriority (FPU_IRQn, 7);
74 NVIC_ClearPendingIRQ (FPU_IRQn);
75 NVIC_EnableIRQ (FPU_IRQn);
79 static void fpu_init (
void)
86 static void wakeup_handler (
void * p_context)
93 return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
100 ret_code_t err_code = nrf_pwr_mgmt_init();
108 #if RUUVI_NRF5_SDK15_TIMER_ENABLED
114 if (NULL == wakeup_timer)
143 if (NULL != m_ind) { m_ind (
false); }
147 if (NULL != m_ind) { m_ind (
true); }
155 #if RUUVI_NRF5_SDK15_TIMER_ENABLED
158 if (m_lp && m_wakeup)
uint32_t rd_status_t
bitfield for representing errors
rd_status_t ruuvi_nrf5_sdk15_to_ruuvi_error(const ret_code_t error)
convert nrf5 sdk15 error code into Ruuvi error code.
#define RD_ERROR_NOT_SUPPORTED
Not supported.
#define RD_SUCCESS
Internal Error.
void ri_log(const ri_log_severity_t severity, const char *const message)
Queues messages into log.
rd_status_t ri_timer_start(ri_timer_id_t timer_id, uint32_t ms, void *const context)
Start given timer at a mode defined in ri_timer_create.
rd_status_t ri_timer_create(ri_timer_id_t *p_timer_id, ri_timer_mode_t mode, ruuvi_timer_timeout_handler_t timeout_handler)
void * ri_timer_id_t
Pointer to timer data.
@ RI_TIMER_MODE_SINGLE_SHOT
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Interface functions to timer.
rd_status_t ri_yield_uninit(void)
Uninitializes yielding functions.
rd_status_t ri_yield_init(void)
Initializes yielding functions.
bool ri_yield_is_interrupt_context(void)
Check if current execution is in interrupt context.
rd_status_t ri_yield(void)
Function which will release execution.
void ri_yield_indication_set(const ri_yield_state_ind_fp_t indication)
rd_status_t ri_delay_us(uint32_t time)
Delay a given number of microseconds.
void(* ri_yield_state_ind_fp_t)(const bool active)
Enable implementation selected by application.
rd_status_t ri_delay_ms(uint32_t time)
Delay a given number of milliseconds.
rd_status_t ri_yield_low_power_enable(const bool enable)
Initializes yielding functions.