diff --git a/Core/Inc/main.h b/Core/Inc/main.h index f05fab8..38f24dd 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -28,7 +28,6 @@ extern "C" { /* Includes ------------------------------------------------------------------*/ #include "stm32wlxx_hal.h" -#include "stm32wlxx_nucleo.h" #include "yunhorn_sts_prd_conf.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index a963a2e..4941614 100644 --- a/Core/Inc/sys_conf.h +++ b/Core/Inc/sys_conf.h @@ -47,12 +47,12 @@ extern "C" { /** * @brief Verbose level for all trace logs */ -#define VERBOSE_LEVEL VLEVEL_H +#define VERBOSE_LEVEL VLEVEL_OFF /** * @brief Enable trace logs */ -#define APP_LOG_ENABLED 1 +#define APP_LOG_ENABLED 0 /** * @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) * @note by HW serial wires are ON by default, need to put them OFF to save power */ -#define DEBUGGER_ENABLED 1 +#define DEBUGGER_ENABLED 0 /** * @brief Disable Low Power mode diff --git a/Core/Inc/yunhorn_sts_prd_conf.h b/Core/Inc/yunhorn_sts_prd_conf.h index 6a75be3..8f690ad 100644 --- a/Core/Inc/yunhorn_sts_prd_conf.h +++ b/Core/Inc/yunhorn_sts_prd_conf.h @@ -232,9 +232,9 @@ -#define MajorVer 24U -#define MinorVer 02U -#define SubMinorVer 21U +#define MajorVer 23U +#define MinorVer 11U +#define SubMinorVer 18U #define FirmwareVersion 3U #define YUNHORN_STS_MAX_NVM_CFG_SIZE 64U #define YUNHORN_STS_AC_CODE_SIZE 20U diff --git a/Core/Src/dma.c b/Core/Src/dma.c index c34a3c2..366b255 100644 --- a/Core/Src/dma.c +++ b/Core/Src/dma.c @@ -70,11 +70,9 @@ void MX_DMA_Init(void) // **** I2C2 // **** USART2 -#if 0 /* DMA1_Channel6_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn); -#endif /* DMA1_Channel7_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn); diff --git a/Core/Src/main.c b/Core/Src/main.c index 2e7ad1b..8d4f1e9 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -29,7 +29,6 @@ #include "sys_app.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ -#include "stm32wlxx_nucleo.h" #include "yunhorn_sts_sensors.h" #include "sts_cmox_hmac_sha.h" #ifdef STS_USE_TOF_VL53L0X @@ -58,7 +57,7 @@ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ -static void WkupPin1_Config(void); + /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ @@ -103,10 +102,6 @@ int main(void) SystemClock_Config(); /* USER CODE BEGIN SysInit */ - /* Configure the wake_up pin */ - WkupPin1_Config(); - /* Un-comment to be able to debug after wake-up from Standby. Consumption will be increased */ - //HAL_DBGMCU_EnableDBGStandbyMode(); /* USER CODE END SysInit */ @@ -114,34 +109,47 @@ int main(void) MX_GPIO_Init(); MX_DMA_Init(); - /* Check if the system was resumed from Standby mode */ - if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) - { - /* Clear Standby flag */ - __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); - HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET); /* LED_BLUE */ - HAL_Delay(300); - HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); /* LED_BLUE */ - - } else - { + MX_I2C2_Init(); - HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET); /* LED_ */ - HAL_Delay(300); - HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET); /* LED_ */ - - MX_I2C2_Init(); - - MX_LoRaWAN_Init(); - } + MX_LoRaWAN_Init(); /* USER CODE BEGIN 2 */ + //HAL_Delay(3000); + + /* USER CODE END 2 */ /* Infinite loop */ /* 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) { @@ -203,17 +211,6 @@ void SystemClock_Config(void) } /* 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_USER, 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 */ diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index 66049c4..bfa47d5 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -81,25 +81,13 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver = void PWR_EnterOffMode(void) { /* USER CODE BEGIN EnterOffMode_1 */ - HAL_SuspendTick(); - WkupPin1_Config(); - /* 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_EnterSTANDBYMode(); /* USER CODE END EnterOffMode_1 */ } void PWR_ExitOffMode(void) { /* USER CODE BEGIN ExitOffMode_1 */ - HAL_ResumeTick(); - - /* Clear Standby flag */ - __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); /* USER CODE END ExitOffMode_1 */ } diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c index 33b1dda..e3545a0 100644 --- a/Core/Src/stm32wlxx_it.c +++ b/Core/Src/stm32wlxx_it.c @@ -76,9 +76,8 @@ extern DMA_HandleTypeDef hdma_i2c2_tx; //extern TIM_HandleTypeDef htim2; //extern TIM_HandleTypeDef htim16; extern DMA_HandleTypeDef hdma_usart2_tx; -#if 0 extern DMA_HandleTypeDef hdma_usart2_rx; -#endif + /* USER CODE BEGIN EV */ @@ -209,9 +208,8 @@ void SysTick_Handler(void) /* USER CODE BEGIN SysTick_IRQn 0 */ /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); /* USER CODE BEGIN SysTick_IRQn 1 */ - HAL_SYSTICK_IRQHandler(); + /* USER CODE END SysTick_IRQn 1 */ } @@ -330,9 +328,7 @@ void DMA1_Channel6_IRQHandler(void) /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */ /* USER CODE END DMA1_Channel6_IRQn 0 */ -#if 0 HAL_DMA_IRQHandler(&hdma_usart2_rx); -#endif /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */ /* USER CODE END DMA1_Channel6_IRQn 1 */ diff --git a/Core/Src/sys_app.c b/Core/Src/sys_app.c index 79cee28..afd0327 100644 --- a/Core/Src/sys_app.c +++ b/Core/Src/sys_app.c @@ -123,7 +123,6 @@ void SystemApp_Init(void) UTIL_LPM_Init(); /* 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_ENABLE); #if defined (LOW_POWER_DISABLE) && (LOW_POWER_DISABLE == 1) /* Disable Stop Mode */ diff --git a/Core/Src/usart.c b/Core/Src/usart.c index ac9ee6e..e62df72 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -28,9 +28,8 @@ UART_HandleTypeDef huart2; DMA_HandleTypeDef hdma_usart2_tx; -#if 0 DMA_HandleTypeDef hdma_usart2_rx; -#endif + /* USART2 init function */ void MX_USART2_UART_Init(void) @@ -134,7 +133,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) } #endif __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx); -#if 0 + /* USART2_RX Init */ hdma_usart2_rx.Instance = DMA1_Channel6; hdma_usart2_rx.Init.Request = DMA_REQUEST_USART2_RX; @@ -156,7 +155,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) } #endif __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx); -#endif + /* USART2 interrupt Init */ HAL_NVIC_SetPriority(USART2_IRQn, 2, 0); HAL_NVIC_EnableIRQ(USART2_IRQn); @@ -185,9 +184,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) /* USART2 DMA DeInit */ HAL_DMA_DeInit(uartHandle->hdmatx); -#if 0 HAL_DMA_DeInit(uartHandle->hdmarx); -#endif /* USART2 interrupt Deinit */ HAL_NVIC_DisableIRQ(USART2_IRQn); /* USER CODE BEGIN USART2_MspDeInit 1 */ diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index ed2fa1e..3cf6274 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -40,6 +40,7 @@