STM32WB55 freertos 低功耗

修改app_conf.h
打开低功耗支持宏

/**
 *  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

关闭打印控制宏


/**
 * 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

修改FreeRTOSConfig.h configUSE_TICKLESS_IDLE
定义成 1 将使用默认的 vPortSuppressTicksAndSleep
定义成 2 将使用自定义的 vPortSuppressTicksAndSleep

#define configUSE_TICKLESS_IDLE                  2

选择低功耗模式为 stop 模式

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;
}

进入和退出低功耗 外设的处理放在下图中的两个函数
在这里插入图片描述

FreeRTOS.h中 configEXPECTED_IDLE_TIME_BEFORE_SLEEP
表示系统进入低功耗前空闲的tick数
默认值是2

#ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP
	#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2
#endif

猜你喜欢

转载自blog.csdn.net/qq_28851611/article/details/108095423