2024-11-25 06:59 PM - edited 2024-11-25 07:00 PM
case PWR_KEY_Pin:
if (HAL_GPIO_ReadPin(PWR_KEY_GPIO_Port, PWR_KEY_Pin) == GPIO_PIN_RESET)
{
HAL_TIM_IC_Start_IT(&htim16, TIM_CHANNEL_1);
captureStart = HAL_TIM_ReadCapturedValue(&htim16, TIM_CHANNEL_1);
UTIL_LPM_SetStopMode(1 << CFG_LPM_HTIM16, UTIL_LPM_DISABLE);
}
else
{
HAL_TIM_IC_Stop_IT(&htim16, TIM_CHANNEL_1);
captureEnd = HAL_TIM_ReadCapturedValue(&htim16, TIM_CHANNEL_1);
pressDuration = captureEnd - captureStart;
UTIL_LPM_SetStopMode(1 << CFG_LPM_HTIM16, UTIL_LPM_ENABLE);
After LPM enabled
#define CFG_LPM_SUPPORTED 1
Long press the button for 5 secs, pressDuration will output ~2000 only.
The application was base on BLE_p2pServer and I'm sure PWR_EnterStopMode was not called by add "UTIL_LPM_SetStopMode(1 << CFG_LPM_HTIM16, UTIL_LPM_DISABLE);"