tryp low power standby mode
This commit is contained in:
parent
3edb98355e
commit
01f2be75ed
|
@ -85,7 +85,20 @@ int main(void)
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
|
|
||||||
|
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) == RESET)
|
||||||
|
{
|
||||||
|
|
||||||
MX_LoRaWAN_Init();
|
MX_LoRaWAN_Init();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
|
||||||
|
//MX_LoRaWAN_Init();
|
||||||
|
SystemApp_Init();
|
||||||
|
UTIL_TIMER_Start(&TxTimer);
|
||||||
|
MX_LoRaWAN_Process();
|
||||||
|
}
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
|
@ -51,6 +51,19 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver =
|
||||||
|
|
||||||
/* USER CODE BEGIN PTD */
|
/* USER CODE BEGIN PTD */
|
||||||
|
|
||||||
|
extern RTC_HandleTypeDef hrtc;
|
||||||
|
|
||||||
|
void CPUcontextSave(void); /* this function is implemented in startup assembly file */
|
||||||
|
void SystemClock_Config(void);
|
||||||
|
void PeriphCommonClock_Config(void);
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
//static void ExitLowPower(void);
|
||||||
|
#if (CFG_LPM_STANDBY_SUPPORTED != 0)
|
||||||
|
static void ExitLowPower_standby(void);
|
||||||
|
#endif
|
||||||
/* USER CODE END PTD */
|
/* USER CODE END PTD */
|
||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
@ -80,6 +93,31 @@ void PWR_EnterOffMode(void)
|
||||||
/* USER CODE BEGIN EnterOffMode_1 */
|
/* USER CODE BEGIN EnterOffMode_1 */
|
||||||
|
|
||||||
/* USER CODE END EnterOffMode_1 */
|
/* USER CODE END EnterOffMode_1 */
|
||||||
|
/**
|
||||||
|
* The systick should be disabled for the same reason than when the device enters stop mode because
|
||||||
|
* at this time, the device may enter either OffMode or StopMode.
|
||||||
|
*/
|
||||||
|
HAL_SuspendTick();
|
||||||
|
__HAL_RCC_CLEAR_RESET_FLAGS();
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* ENTER OFF MODE
|
||||||
|
***********************************************************************************/
|
||||||
|
/*
|
||||||
|
* There is no risk to clear all the WUF here because in the current implementation, this API is called
|
||||||
|
* in critical section. If an interrupt occurs while in that critical section before that point,
|
||||||
|
* the flag is set and will be cleared here but the system will not enter Off Mode
|
||||||
|
* because an interrupt is pending in the NVIC. The ISR will be executed when moving out
|
||||||
|
* of this critical section
|
||||||
|
*/
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
|
||||||
|
/* Enter the Standby mode */
|
||||||
|
HAL_PWR_EnterSTANDBYMode();
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PWR_EnterOffMode_2 */
|
||||||
|
|
||||||
|
/* USER CODE END PWR_EnterOffMode_2 */
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PWR_ExitOffMode(void)
|
void PWR_ExitOffMode(void)
|
||||||
|
@ -87,6 +125,13 @@ void PWR_ExitOffMode(void)
|
||||||
/* USER CODE BEGIN ExitOffMode_1 */
|
/* USER CODE BEGIN ExitOffMode_1 */
|
||||||
|
|
||||||
/* USER CODE END ExitOffMode_1 */
|
/* USER CODE END ExitOffMode_1 */
|
||||||
|
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
|
||||||
|
HAL_ResumeTick();
|
||||||
|
/* USER CODE BEGIN PWR_ExitOffMode_2 */
|
||||||
|
|
||||||
|
/* USER CODE END PWR_ExitOffMode_2 */
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PWR_EnterStopMode(void)
|
void PWR_EnterStopMode(void)
|
||||||
|
|
|
@ -30,7 +30,7 @@ void sts_weight_scale_init(void)
|
||||||
{
|
{
|
||||||
HX711_Init();
|
HX711_Init();
|
||||||
Get_GrossWeight();
|
Get_GrossWeight();
|
||||||
HAL_Delay(500);
|
HAL_Delay(100);
|
||||||
Get_GrossWeight();
|
Get_GrossWeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void SystemApp_Init(void)
|
||||||
UTIL_TIMER_Init();
|
UTIL_TIMER_Init();
|
||||||
SYS_TimerInitialisedFlag = 1;
|
SYS_TimerInitialisedFlag = 1;
|
||||||
/* Initializes the SW probes pins and the monitor RF pins via Alternate Function */
|
/* Initializes the SW probes pins and the monitor RF pins via Alternate Function */
|
||||||
DBG_Init();
|
//DBG_Init();
|
||||||
|
|
||||||
/*Initialize the terminal */
|
/*Initialize the terminal */
|
||||||
UTIL_ADV_TRACE_Init();
|
UTIL_ADV_TRACE_Init();
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
|
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#ifdef STS_WS
|
#ifdef STS_WS
|
||||||
|
#include "stm32_lpm.h"
|
||||||
|
#include "timer_if.h"
|
||||||
|
#include "utilities_def.h"
|
||||||
#include "sts_weight_scale.h"
|
#include "sts_weight_scale.h"
|
||||||
#endif
|
#endif
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
@ -734,6 +737,9 @@ static void OnTxData(LmHandlerTxParams_t *params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* USER CODE END OnTxData_1 */
|
/* USER CODE END OnTxData_1 */
|
||||||
|
HAL_Delay(2000);
|
||||||
|
UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_ENABLE);
|
||||||
|
UTIL_LPM_SetOffMode((1 << CFG_LPM_UART_TX_Id), UTIL_LPM_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
||||||
|
@ -764,6 +770,8 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
||||||
APP_LOG(TS_OFF, VLEVEL_H, "###### U/L FRAME:JOIN | DR:%d | PWR:%d\r\n", joinParams->Datarate, joinParams->TxPower);
|
APP_LOG(TS_OFF, VLEVEL_H, "###### U/L FRAME:JOIN | DR:%d | PWR:%d\r\n", joinParams->Datarate, joinParams->TxPower);
|
||||||
}
|
}
|
||||||
/* USER CODE END OnJoinRequest_1 */
|
/* USER CODE END OnJoinRequest_1 */
|
||||||
|
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnBeaconStatusChange(LmHandlerBeaconParams_t *params)
|
static void OnBeaconStatusChange(LmHandlerBeaconParams_t *params)
|
||||||
|
|
Loading…
Reference in New Issue