try low power 2024 03 08
This commit is contained in:
parent
06310aa51f
commit
4b4e837395
|
@ -1,290 +0,0 @@
|
||||||
/* USER CODE BEGIN Header */
|
|
||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file : stm32wlxx_nucleo.h
|
|
||||||
* @brief : header file for the BSP Common driver
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2023 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header */
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32WLXX_NUCLEO_H
|
|
||||||
#define __STM32WLXX_NUCLEO_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32wlxx_nucleo_conf.h"
|
|
||||||
#include "stm32wlxx_nucleo_errno.h"
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#if (USE_BSP_COM_FEATURE > 0)
|
|
||||||
#if (USE_COM_LOG > 0)
|
|
||||||
#if defined(__ICCARM__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) /* For IAR and ARM Compiler 5 and 6*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** @addtogroup BSP
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup STM32L4XX_NUCLEO_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief STM32WLXX NUCLEO BSP Driver version number V1.0.0
|
|
||||||
*/
|
|
||||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_MAIN (uint32_t)(0x01) /*!< [31:24] main version */
|
|
||||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_SUB1 (uint32_t)(0x00) /*!< [23:16] sub1 version */
|
|
||||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_SUB2 (uint32_t)(0x00) /*!< [15:8] sub2 version */
|
|
||||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_RC (uint32_t)(0x00) /*!< [7:0] release candidate */
|
|
||||||
#define __STM32WLXX_NUCLEO_BSP_VERSION ((__STM32WLXX_NUCLEO_BSP_VERSION_MAIN << 24)\
|
|
||||||
|(__STM32WLXX_NUCLEO_BSP_VERSION_SUB1 << 16)\
|
|
||||||
|(__STM32WLXX_NUCLEO_BSP_VERSION_SUB2 << 8 )\
|
|
||||||
|(__STM32WLXX_NUCLEO_BSP_VERSION_RC))
|
|
||||||
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Types STM32WLXX_NUCLEO LOW LEVEL Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Define for STM32WLXX_NUCLEO board
|
|
||||||
*/
|
|
||||||
#if !defined (USE_STM32WLXX_NUCLEO)
|
|
||||||
#define USE_STM32WLXX_NUCLEO
|
|
||||||
#endif
|
|
||||||
#ifndef USE_BSP_COM_FEATURE
|
|
||||||
#define USE_BSP_COM_FEATURE 0U
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON STM32WLXX_NUCLEO LOW LEVEL BUTTON
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Button state */
|
|
||||||
#define BUTTON_RELEASED 0U
|
|
||||||
#define BUTTON_PRESSED 1U
|
|
||||||
/** Define number of BUTTON **/
|
|
||||||
#define BUTTONn 1U
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief User push-button
|
|
||||||
*/
|
|
||||||
/** Definition for BSP USER BUTTON **/
|
|
||||||
|
|
||||||
#define USER_BUTTON_PIN GPIO_PIN_0
|
|
||||||
#define USER_BUTTON_GPIO_PORT GPIOA
|
|
||||||
#define USER_BUTTON_EXTI_IRQn EXTI0_IRQn
|
|
||||||
#define USER_BUTTON_EXTI_LINE EXTI_LINE_0
|
|
||||||
#define H_EXTI_0 hpb_exti[BUTTON_USER]
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_COM STM32WLXX_NUCLEO LOW LEVEL COM
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief Definition for COM portx, connected to USART1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BUS_USART1_INSTANCE USART1
|
|
||||||
#define BUS_USART1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
|
||||||
#define BUS_USART1_RX_GPIO_PORT GPIOB
|
|
||||||
#define BUS_USART1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
|
||||||
#define BUS_USART1_RX_GPIO_PIN GPIO_PIN_7
|
|
||||||
#define BUS_USART1_RX_GPIO_AF GPIO_AF7_USART1
|
|
||||||
#define BUS_USART1_TX_GPIO_PIN GPIO_PIN_6
|
|
||||||
#define BUS_USART1_TX_GPIO_PORT GPIOB
|
|
||||||
#define BUS_USART1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
|
||||||
#define BUS_USART1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
|
||||||
#define BUS_USART1_TX_GPIO_AF GPIO_AF7_USART1
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#ifndef USE_BSP_COM
|
|
||||||
#define USE_BSP_COM 0U
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef USE_COM_LOG
|
|
||||||
#define USE_COM_LOG 1U
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BSP_BUTTON_USER_IT_PRIORITY
|
|
||||||
#define BSP_BUTTON_USER_IT_PRIORITY 15U
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
BUTTON_USER = 0U,
|
|
||||||
}Button_TypeDef;
|
|
||||||
|
|
||||||
/* Keep compatibility with CMSIS Pack already delivered */
|
|
||||||
#define BUTTON_KEY BUTTON_USER
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
BUTTON_MODE_GPIO = 0,
|
|
||||||
BUTTON_MODE_EXTI = 1
|
|
||||||
} ButtonMode_TypeDef;
|
|
||||||
|
|
||||||
#if (USE_BSP_COM_FEATURE > 0)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
COM1 = 0U,
|
|
||||||
COMn
|
|
||||||
}COM_TypeDef;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
|
|
||||||
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
|
|
||||||
}COM_WordLengthTypeDef;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
COM_STOPBITS_1 = UART_STOPBITS_1,
|
|
||||||
COM_STOPBITS_2 = UART_STOPBITS_2,
|
|
||||||
}COM_StopBitsTypeDef;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
COM_PARITY_NONE = UART_PARITY_NONE,
|
|
||||||
COM_PARITY_EVEN = UART_PARITY_EVEN,
|
|
||||||
COM_PARITY_ODD = UART_PARITY_ODD,
|
|
||||||
}COM_ParityTypeDef;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
|
|
||||||
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
|
|
||||||
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
|
|
||||||
COM_HWCONTROL_RTS_CTS = UART_HWCONTROL_RTS_CTS,
|
|
||||||
}COM_HwFlowCtlTypeDef;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t BaudRate;
|
|
||||||
COM_WordLengthTypeDef WordLength;
|
|
||||||
COM_StopBitsTypeDef StopBits;
|
|
||||||
COM_ParityTypeDef Parity;
|
|
||||||
COM_HwFlowCtlTypeDef HwFlowCtl;
|
|
||||||
}COM_InitTypeDef;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MX_UART_InitTypeDef COM_InitTypeDef
|
|
||||||
#define MX_UART_StopBitsTypeDef COM_StopBitsTypeDef
|
|
||||||
#define MX_UART_ParityTypeDef COM_ParityTypeDef
|
|
||||||
#define MX_UART_HwFlowCtlTypeDef COM_HwFlowCtlTypeDef
|
|
||||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1U)
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
void (* pMspInitCb)(UART_HandleTypeDef *);
|
|
||||||
void (* pMspDeInitCb)(UART_HandleTypeDef *);
|
|
||||||
} BSP_COM_Cb_t;
|
|
||||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 1U) */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define COMn 1U
|
|
||||||
#define COM1_UART USART1
|
|
||||||
|
|
||||||
#define COM_POLL_TIMEOUT 1000
|
|
||||||
extern UART_HandleTypeDef hcom_uart[COMn];
|
|
||||||
#define huart1 hcom_uart[COM1]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Variables LOW LEVEL Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
extern EXTI_HandleTypeDef hpb_exti[BUTTONn];
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Functions STM32WLXX_NUCLEO LOW LEVEL Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
int32_t BSP_GetVersion(void);
|
|
||||||
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
|
|
||||||
int32_t BSP_PB_DeInit(Button_TypeDef Button);
|
|
||||||
int32_t BSP_PB_GetState(Button_TypeDef Button);
|
|
||||||
void BSP_PB_Callback(Button_TypeDef Button);
|
|
||||||
void BSP_PB_IRQHandler (Button_TypeDef Button);
|
|
||||||
#if (USE_BSP_COM_FEATURE > 0)
|
|
||||||
int32_t BSP_COM_Init(COM_TypeDef COM);
|
|
||||||
int32_t BSP_COM_DeInit(COM_TypeDef COM);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (USE_COM_LOG > 0)
|
|
||||||
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1U)
|
|
||||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM);
|
|
||||||
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback);
|
|
||||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32WLXX_NUCLEO__H */
|
|
||||||
|
|
|
@ -47,12 +47,12 @@ extern "C" {
|
||||||
/**
|
/**
|
||||||
* @brief Verbose level for all trace logs
|
* @brief Verbose level for all trace logs
|
||||||
*/
|
*/
|
||||||
#define VERBOSE_LEVEL VLEVEL_OFF
|
#define VERBOSE_LEVEL VLEVEL_H
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable trace logs
|
* @brief Enable trace logs
|
||||||
*/
|
*/
|
||||||
#define APP_LOG_ENABLED 0
|
#define APP_LOG_ENABLED 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Activate monitoring (probes) of some internal RF signals for debug purpose
|
* @brief Activate monitoring (probes) of some internal RF signals for debug purpose
|
||||||
|
@ -75,7 +75,7 @@ extern "C" {
|
||||||
* @brief Enable/Disable MCU Debugger pins (dbg serial wires)
|
* @brief Enable/Disable MCU Debugger pins (dbg serial wires)
|
||||||
* @note by HW serial wires are ON by default, need to put them OFF to save power
|
* @note by HW serial wires are ON by default, need to put them OFF to save power
|
||||||
*/
|
*/
|
||||||
#define DEBUGGER_ENABLED 0
|
#define DEBUGGER_ENABLED 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable Low Power mode
|
* @brief Disable Low Power mode
|
||||||
|
|
|
@ -147,7 +147,7 @@ void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Pin = LED1_Pin;
|
GPIO_InitStruct.Pin = LED1_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#ifdef STS_USE_TOF_VL53L1X
|
#ifdef STS_USE_TOF_VL53L1X
|
||||||
#include "app_tof_peoplecount.h"
|
#include "app_tof_peoplecount.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "stm32wlxx_nucleo.h"
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
@ -63,6 +66,7 @@
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
static void WkupPin1_Config(void);
|
||||||
//#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
//#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
@ -108,55 +112,43 @@ int main(void)
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
|
WkupPin1_Config();
|
||||||
|
if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
|
||||||
|
{
|
||||||
|
/* Clear Standby flag */
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
|
||||||
|
|
||||||
MX_I2C2_Init();
|
} else {
|
||||||
|
|
||||||
|
|
||||||
MX_LoRaWAN_Init();
|
MX_LoRaWAN_Init();
|
||||||
|
LED_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_Delay(1000);
|
||||||
|
LED_OFF;
|
||||||
|
//MX_LoRaWAN_Process();
|
||||||
|
#if 0
|
||||||
|
/* Enable WakeUp Pin PWR_WAKEUP_PIN1 connected to PA0 */
|
||||||
|
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_LOW);
|
||||||
|
|
||||||
|
/* Clear all related wakeup flags*/
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);
|
||||||
|
|
||||||
|
/* Enter the Standby mode */
|
||||||
|
HAL_PWR_EnterSTANDBYMode();
|
||||||
|
#endif
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
HAL_Delay(3000);
|
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
#if 0
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(SOAP_SWITCH_GPIO_Port, SOAP_SWITCH_Pin, GPIO_PIN_SET);
|
|
||||||
HAL_Delay(1000);
|
|
||||||
//uint8_t soapData = SOAP_DATA;
|
|
||||||
uint8_t soapData = HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin);
|
|
||||||
uint8_t read2nd = 0;
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n Soap State = %d \r\n", soapData);
|
|
||||||
#if 0
|
|
||||||
HAL_GPIO_WritePin(SOAP_SWITCH_GPIO_Port, SOAP_SWITCH_Pin, GPIO_PIN_RESET);
|
|
||||||
HAL_Delay(1000);
|
|
||||||
read2nd = HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin);
|
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n 2nd read after 1 seconds= %d \r\n", read2nd);
|
|
||||||
|
|
||||||
HAL_Delay(1000);
|
|
||||||
|
|
||||||
read2nd = HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin);
|
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n 3rd read after another 1 seconds= %d \r\n", read2nd);
|
|
||||||
#endif
|
|
||||||
HAL_Delay(20000);
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
//LED_ON;
|
||||||
MX_LoRaWAN_Process();
|
MX_LoRaWAN_Process();
|
||||||
|
//LED_OFF;
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
|
@ -211,7 +203,17 @@ void SystemClock_Config(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
static void WkupPin1_Config(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Configure Button pin and unmask Wakeup with Interrupt request from line 0.*/
|
||||||
|
BSP_PB_Init(BUTTON_SW1, BUTTON_MODE_EXTI);
|
||||||
|
|
||||||
|
/* Enable wake-up pin pull-up state in Standby mode.*/
|
||||||
|
HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_0);
|
||||||
|
HAL_PWREx_EnablePullUpPullDownConfig();
|
||||||
|
|
||||||
|
}
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -81,14 +81,23 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver =
|
||||||
void PWR_EnterOffMode(void)
|
void PWR_EnterOffMode(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN EnterOffMode_1 */
|
/* USER CODE BEGIN EnterOffMode_1 */
|
||||||
|
HAL_SuspendTick();
|
||||||
|
/* Enable WakeUp Pin PWR_WAKEUP_PIN1 connected to PA0 */
|
||||||
|
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_LOW);
|
||||||
|
|
||||||
|
/* Clear all related wakeup flags*/
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
|
||||||
|
/* Enter the Standby mode */
|
||||||
|
HAL_PWR_EnterSTANDBYMode();
|
||||||
/* USER CODE END EnterOffMode_1 */
|
/* USER CODE END EnterOffMode_1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
void PWR_ExitOffMode(void)
|
void PWR_ExitOffMode(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN ExitOffMode_1 */
|
/* USER CODE BEGIN ExitOffMode_1 */
|
||||||
|
HAL_ResumeTick();
|
||||||
|
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
|
||||||
/* USER CODE END ExitOffMode_1 */
|
/* USER CODE END ExitOffMode_1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +136,7 @@ void PWR_ExitStopMode(void)
|
||||||
/* USER CODE BEGIN ExitStopMode_2 */
|
/* USER CODE BEGIN ExitStopMode_2 */
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
MX_I2C2_Init();
|
//MX_I2C2_Init();
|
||||||
|
|
||||||
/* USER CODE END ExitStopMode_2 */
|
/* USER CODE END ExitStopMode_2 */
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ void SystemApp_Init(void)
|
||||||
UTIL_LPM_Init();
|
UTIL_LPM_Init();
|
||||||
/* Disable Stand-by mode */
|
/* Disable Stand-by mode */
|
||||||
//UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE);
|
//UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE);
|
||||||
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 */
|
||||||
|
|
|
@ -637,7 +637,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||||
case BUT1_Pin:
|
case BUT1_Pin:
|
||||||
|
|
||||||
#ifdef STS_O5
|
#ifdef STS_O5
|
||||||
|
LED_ON;
|
||||||
uint8_t pinstate = (STS_Reed_Hall_State== 0)?1:0;
|
uint8_t pinstate = (STS_Reed_Hall_State== 0)?1:0;
|
||||||
APP_LOG(TS_OFF, VLEVEL_H, "## BUTTON-1 DETECTED: %2d \r\n", pinstate);
|
APP_LOG(TS_OFF, VLEVEL_H, "## BUTTON-1 DETECTED: %2d \r\n", pinstate);
|
||||||
|
|
||||||
|
@ -646,15 +646,15 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||||
if (EventType == TX_ON_EVENT)
|
if (EventType == TX_ON_EVENT)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef LED_ONBOARD
|
//#ifdef LED_ONBOARD
|
||||||
LED_ON;
|
LED_ON;
|
||||||
HAL_Delay(20);
|
HAL_Delay(20);
|
||||||
LED_OFF;
|
LED_OFF;
|
||||||
#endif
|
//#endif
|
||||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
LED_OFF;
|
||||||
break;
|
break;
|
||||||
case BUT2_Pin:
|
case BUT2_Pin:
|
||||||
#if defined(STS_USE_STM32WLE5)
|
#if defined(STS_USE_STM32WLE5)
|
||||||
|
@ -733,6 +733,15 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DeviceClass_t deviceClass = CLASS_A;
|
||||||
|
LmHandlerGetCurrentClass( &deviceClass );
|
||||||
|
uint8_t i=0;
|
||||||
|
outbuf[i++] = (uint8_t) 'L';
|
||||||
|
outbuf[i++] = (uint8_t) sts_mtmcode1;
|
||||||
|
outbuf[i++] = (uint8_t) sts_mtmcode2;
|
||||||
|
outbuf[i++] = (uint8_t) sts_version;
|
||||||
|
outbuf[i++] = (uint8_t) (0x41+ deviceClass); //translate to 'A','B','C'
|
||||||
|
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
|
||||||
break;
|
break;
|
||||||
case LORAWAN_USER_APP_PORT:
|
case LORAWAN_USER_APP_PORT:
|
||||||
if (appData->BufferSize == 1)
|
if (appData->BufferSize == 1)
|
||||||
|
|
|
@ -78,5 +78,6 @@
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||||
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|
Loading…
Reference in New Issue