#include "ach118x.h"

//#define USE_PS_MODE
#define HOST_SHALLOW_SLEEP_BIT	0x01
#define HOST_DEEP_SLEEP_BIT		0x02

//------------------------------------------------------------------------------
// in "FreeRTOSConfig.h" to defined hconfigUSE_IDLE_HOOK
// this function is use for freertos
//------------------------------------------------------------------------------
void vApplicationIdleHook( void )
{
#ifdef USE_PS_MODE
	extern u8 g_app_psm;
	if(g_app_psm & HOST_DEEP_SLEEP_BIT)
	{
		NVIC_SystemLPConfig(NVIC_LP_SEVONPEND,   ENABLE);
		NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP,   DISABLE);
		NVIC_SystemLPConfig(NVIC_LP_SLEEPONEXIT, DISABLE);

		__WFI();
	}
#else
    __WFI();
#endif
}
//------------------------------------------------------------------------------
