Modify app_conf.h to
open the low-power support macro
/**
* When set to 1, the low power mode is enable
* When set to 0, the device stays in RUN mode
*/
#define CFG_LPM_SUPPORTED 1
Close print control macro
/**
* keep debugger enabled while in any low power mode when set to 1
* should be set to 0 in production
*/
#define CFG_DEBUGGER_SUPPORTED 0//1
/**
* When set to 1, the traces are enabled in the BLE services
*/
#define CFG_DEBUG_BLE_TRACE 0//1
/**
* Enable or Disable traces in application
*/
#define CFG_DEBUG_APP_TRACE 0//1
Modify FreeRTOSConfig.h configUSE_TICKLESS_IDLE to be
defined as 1 to use the default vPortSuppressTicksAndSleep to
define to 2 to use the custom vPortSuppressTicksAndSleep
#define configUSE_TICKLESS_IDLE 2
Select low power consumption mode as stop mode
static void APPE_SysUserEvtRx( void * pPayload )
{
UNUSED(pPayload);
/* Traces channel initialization */
APPD_EnableCPU2( );
APP_BLE_Init( );
// UTIL_LPM_SetOffMode(1U << CFG_LPM_APP, UTIL_LPM_ENABLE);
UTIL_LPM_SetStopMode(1U << CFG_LPM_APP, UTIL_LPM_ENABLE);
return;
}
The processing of entering and exiting low-power peripherals is placed in the two functions in the following figure
ConfigEXPECTED_IDLE_TIME_BEFORE_SLEEP in FreeRTOS.h
indicates the number of idle ticks before the system enters low power consumption. The
default value is 2
#ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2
#endif