/** **************************************************************************************** * @brief Selects convertion function (XTAL32 or RCX20) for low power cycles to us. * * @param[in] lpcycles. Low power cycles * * @return uint32. microseconds **************************************************************************************** */ uint32_t lld_sleep_lpcycles_2_us_sel_func(uint32_t lpcycles) { volatile uint32_t us; if ( ((lp_clk_sel == LP_CLK_XTAL32) && (CFG_LP_CLK == LP_CLK_FROM_OTP)) || (CFG_LP_CLK == LP_CLK_XTAL32) ) us = lld_sleep_lpcycles_2_us_func(lpcycles); else if ( ((lp_clk_sel == LP_CLK_RCX20) && (CFG_LP_CLK == LP_CLK_FROM_OTP)) || (CFG_LP_CLK == LP_CLK_RCX20) ) us = lld_sleep_lpcycles_2_us_rcx_func(lpcycles); return(us); }
uint32_t lld_sleep_lpcycles_2_us_sel_func(uint32_t lpcycles) { volatile uint32_t us; if (lp_clk_sel == LP_CLK_XTAL32) us = lld_sleep_lpcycles_2_us_func(lpcycles); else //LP_CLK_RCX20 us = lld_sleep_lpcycles_2_us_rcx_func(lpcycles); return(us); }
void lld_sleep_init_func(void) { uint16_t delay; uint32_t twirq_set_value; if (lp_clk_sel == LP_CLK_RCX20) twirq_set_value = XTAL_TRIMMING_TIME_RCX; else // if (lp_clk_sel == LP_CLK_XTAL32) twirq_set_value = XTAL_TRIMMING_TIME; // Clear the environment memset(&lld_sleep_env, 0, sizeof(lld_sleep_env)); // Actual "delay" is application specific and is the execution time of the BLE_WAKEUP_LP_Handler(), which depends on XTAL trimming delay, // plus the time taken for the OTP copy. Time unit of delay is usec. delay = lld_sleep_lpcycles_2_us_func(twirq_set_value); // Icrease time taking in to account the time from the setting of BLE_DEEP_SLEEP_ON_BIT until the execution of WFI. delay += 200; rwip_wakeup_delay_set(delay); // Enable external wake-up by default ble_extwkupdsb_setf(0); }