revised for low power
This commit is contained in:
parent
016e762a6f
commit
0ab4eefeea
|
@ -83,8 +83,13 @@ void MX_GPIO_Init(void)
|
||||||
#endif
|
#endif
|
||||||
/*Configure GPIO pin : PtPin */
|
/*Configure GPIO pin : PtPin */
|
||||||
GPIO_InitStruct.Pin = BUT2_Pin;
|
GPIO_InitStruct.Pin = BUT2_Pin;
|
||||||
|
#ifdef TOF_2
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
#else
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
#endif
|
||||||
HAL_GPIO_Init(BUT2_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(BUT2_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pin : PtPin */
|
/*Configure GPIO pin : PtPin */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#include "dma.h"
|
#include "dma.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
#include "usart_if.h"
|
||||||
#include "sys_app.h"
|
#include "sys_app.h"
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
@ -115,7 +116,7 @@ int main(void)
|
||||||
MX_LoRaWAN_Init();
|
MX_LoRaWAN_Init();
|
||||||
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
vcom_DeInit();
|
||||||
//HAL_Delay(3000);
|
//HAL_Delay(3000);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,15 +80,28 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver =
|
||||||
|
|
||||||
void PWR_EnterOffMode(void)
|
void PWR_EnterOffMode(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN EnterOffMode_1 */
|
#if 0
|
||||||
|
LED_OFF;
|
||||||
|
HAL_UART_DeInit(&huart2);
|
||||||
|
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);//禁用所有使用的唤醒源:PWR_WAKEUP_PIN1 connected to PA.00
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);//清除所有相关的唤醒标志
|
||||||
|
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);//启用连接到PA.00的WakeUp Pin
|
||||||
|
HAL_PWR_EnterSTANDBYMode();//进入待机模式
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EnterOffMode_1 */
|
||||||
|
HAL_PWR_EnterSTANDBYMode();
|
||||||
/* USER CODE END EnterOffMode_1 */
|
/* USER CODE END EnterOffMode_1 */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PWR_ExitOffMode(void)
|
void PWR_ExitOffMode(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN ExitOffMode_1 */
|
/* USER CODE BEGIN ExitOffMode_1 */
|
||||||
|
#if 0
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
|
||||||
|
LED_ON;
|
||||||
|
HAL_Delay(200);
|
||||||
|
#endif
|
||||||
/* USER CODE END ExitOffMode_1 */
|
/* USER CODE END ExitOffMode_1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +136,7 @@ void PWR_ExitStopMode(void)
|
||||||
SRAM ctrls, DMAx, DMAMux, AES, RNG, HSEM */
|
SRAM ctrls, DMAx, DMAMux, AES, RNG, HSEM */
|
||||||
|
|
||||||
/* Resume not retained USARTx and DMA */
|
/* Resume not retained USARTx and DMA */
|
||||||
vcom_Resume();
|
//vcom_Resume();
|
||||||
/* USER CODE BEGIN ExitStopMode_2 */
|
/* USER CODE BEGIN ExitStopMode_2 */
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
|
|
|
@ -122,7 +122,7 @@ void SystemApp_Init(void)
|
||||||
/*Init low power manager*/
|
/*Init low power manager*/
|
||||||
UTIL_LPM_Init();
|
UTIL_LPM_Init();
|
||||||
/* Disable Stand-by mode */
|
/* Disable Stand-by mode */
|
||||||
UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_ENABLE);
|
UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE);
|
||||||
|
|
||||||
#if defined (LOW_POWER_DISABLE) && (LOW_POWER_DISABLE == 1)
|
#if defined (LOW_POWER_DISABLE) && (LOW_POWER_DISABLE == 1)
|
||||||
/* Disable Stop Mode */
|
/* Disable Stop Mode */
|
||||||
|
|
|
@ -104,13 +104,21 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
PA3 ------> USART2_RX
|
PA3 ------> USART2_RX
|
||||||
PA2 ------> USART2_TX
|
PA2 ------> USART2_TX
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = USARTx_RX_Pin|USARTx_TX_Pin;
|
GPIO_InitStruct.Pin = USARTx_TX_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = USARTx_RX_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
//GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
//GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
|
||||||
/* USART2 DMA Init */
|
/* USART2 DMA Init */
|
||||||
/* USART2_TX Init */
|
/* USART2_TX Init */
|
||||||
hdma_usart2_tx.Instance = DMA1_Channel7;
|
hdma_usart2_tx.Instance = DMA1_Channel7;
|
||||||
|
|
|
@ -68,7 +68,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
||||||
sts_mtmcode2,
|
sts_mtmcode2,
|
||||||
sts_version,
|
sts_version,
|
||||||
sts_hardware_ver,
|
sts_hardware_ver,
|
||||||
0x05, //Regular TxPeriodicity interval
|
0x01, //Regular TxPeriodicity interval
|
||||||
'M', //unit of Regular TxPeriodicity interval
|
'M', //unit of Regular TxPeriodicity interval
|
||||||
0x3C, //Heart-beat interval or Sampling interval
|
0x3C, //Heart-beat interval or Sampling interval
|
||||||
'M', //unit of Heart-beat interval or Sampling interval
|
'M', //unit of Heart-beat interval or Sampling interval
|
||||||
|
|
Loading…
Reference in New Issue