/* cpu_pwr_down() is invoked from idle task when it detects that the kernel can go idle. cpu_pwr_down() checks the current cpu idle mode and put cpu into lower power mode according different idle mode.  */
void cpu_pwr_down(void)
/* cpu_pwr_down() is invoked from idle task when it detects that the kernel can go idle. cpu_pwr_down() checks the current cpu idle mode and put cpu into lower power mode according different idle mode.  */
void cpu_pwr_down(void)
{
    if (cpu_pwr_init_flag == 0) {
        return;
    }
    krhino_spin_lock_irq_save(&cpu_pwr_spin);
    pmu_yield_os_set(0);
    SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
    if(!AliOS_ready_to_sleep()){
	SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;    
        pmu_yield_os_set(1);
        krhino_spin_unlock_irq_restore(&cpu_pwr_spin);        
        return;
    }
    tickless_enter();
        SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
    pmu_yield_os_set(1);    krhino_spin_unlock_irq_restore(&cpu_pwr_spin);
}