Exemple #1
0
/**
 ****************************************************************************************
 * @brief Sets the BLE wake-up delay.  
 *
 * @return void 
 ****************************************************************************************
 */
void set_sleep_delay(void)
{
    int16_t delay;
    uint32_t sleep_delay;
    
    delay = 0;
    
    if (lp_clk_sel == LP_CLK_RCX20)
    {
        if (rcx_period > (RCX_PERIOD_MAX << 10) )
            ASSERT_ERROR(0);
        
        sleep_delay = SLP_PROC_TIME + SLEEP_PROC_TIME + (4 * RCX_PERIOD_MAX);    // 400
    }
    else // if (lp_clk_sel == LP_CLK_XTAL32)
    {
        sleep_delay = /*SLP_PROC_TIME + SLEEP_PROC_TIME + */(4 * XTAL32_PERIOD_MAX); // ~200
    }
    
    // Actual "delay" is application specific and is the execution time of the BLE_WAKEUP_LP_Handler(), which depends on XTAL trimming delay.
    // In case of OTP copy, this is done while the XTAL is settling. Time unit of delay is usec.
    delay += XTAL_TRIMMING_TIME_USEC;
    // Icrease time taking into account the time from the setting of DEEP_SLEEP_ON until the assertion of DEEP_SLEEP_STAT.   
    delay += sleep_delay;
    // Add any application specific delay
    delay += APP_SLEEP_DELAY_OFFSET;
    
    rwip_wakeup_delay_set(delay);
}
Exemple #2
0
/**
 ****************************************************************************************
 * @brief Sets the BLE wake-up delay.  
 *
 * @return void 
 ****************************************************************************************
 */
void set_sleep_delay(void)
{
    int16_t delay;
    
#ifndef USE_POWER_OPTIMIZATIONS
    uint32_t sleep_delay;
    
    delay = 0;
    
    if ( ((lp_clk_sel == LP_CLK_RCX20) && (CFG_LP_CLK == LP_CLK_FROM_OTP)) || (CFG_LP_CLK == LP_CLK_RCX20) )
    {
        if (rcx_period > (RCX_PERIOD_MAX << 10) )
            ASSERT_ERROR(0);
        
        sleep_delay = SLP_PROC_TIME + SLEEP_PROC_TIME + (4 * RCX_PERIOD_MAX); // 400
//#ifdef USE_POWER_OPTIMIZATIONS
//        delay += RCX_CORRECTION_TIME * RCX_PERIOD_MAX;
//#endif        
    }
    else // if (lp_clk_sel == LP_CLK_XTAL32)
    {
        sleep_delay = /*SLP_PROC_TIME + SLEEP_PROC_TIME + */(4 * XTAL32_PERIOD_MAX); // ~200
    }
    
    // Actual "delay" is application specific and is the execution time of the BLE_WAKEUP_LP_Handler(), which depends on XTAL trimming delay.
    // In case of OTP copy, this is done while the XTAL is settling. Time unit of delay is usec.
    delay += XTAL_TRIMMING_TIME_USEC;
    // Icrease time taking into account the time from the setting of DEEP_SLEEP_ON until the assertion of DEEP_SLEEP_STAT.   
    delay += sleep_delay;
    // Add any application specific delay
    delay += APP_SLEEP_DELAY_OFFSET;
    
#else // USE_POWER_OPTIMIZATIONS
    delay = MINIMUM_SLEEP_DURATION;

    // if XTAL_TRIMMING_TIME_USEC changes (i.e. gets larger) then this
    // will make sure that the user gets notified to increase "delay" by 1 or more
    // slots so there's enough time for XTAL to settle
# if ( (3125 + (MINIMUM_SLEEP_DURATION + 625)) < (LP_ISR_TIME_USEC + 1100)) //1.1ms max power-up time
# error "Minimum sleep duration is too small for the 16MHz crystal used..."
# endif
#endif // USE_POWER_OPTIMIZATIONS
    
    rwip_wakeup_delay_set(delay);
}
Exemple #3
0
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);
}