diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index e35d1f8..557e202 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -49,7 +49,7 @@ void MX_GPIO_Init(void) //__HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); -#if 1 +#if 0 // 0b0000 0000 0000 0000 // 0b0001 1010 0000 0000 INCLUDE PA9 PA11 PA12 --> 0x1A00 // 0b1110 0101 1111 1111 exclude PA9 PA11 PA12 --> 0xE5FF @@ -123,6 +123,42 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(BUT3_GPIO_Port, &GPIO_InitStruct); #endif + +#if (defined(TOF_1) && defined(TOF_2)) + GPIO_InitStruct.Pin = TOF_C_INT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + HAL_GPIO_Init(TOF_C_INT_GPIO_Port, &GPIO_InitStruct); +#endif +#if (defined(TOF_1) && defined(TOF_2)) + GPIO_InitStruct.Pin = TOF_C_XSHUT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(TOF_C_XSHUT_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : TOF_L_XSHUT_Pin */ + + GPIO_InitStruct.Pin = TOF_L_XSHUT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(TOF_L_XSHUT_GPIO_Port, &GPIO_InitStruct); +#endif + +#if defined(TOF_1) + HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_SET); +#endif +#if defined(TOF_2) + HAL_GPIO_WritePin(TOF_L_XSHUT_GPIO_Port, TOF_L_XSHUT_Pin, GPIO_PIN_SET); +#endif + +#if (defined(TOF_1) && defined(TOF_2)) + HAL_NVIC_SetPriority(TOF_C_INT_EXTI_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(TOF_C_INT_EXTI_IRQn); +#endif + #ifndef L8 /* STS-PME PB-4 */ /*Configure GPIO pins : PBPin PBPin PBPin */ diff --git a/Core/Src/main.c b/Core/Src/main.c index d0d2d8e..fec7fe2 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -102,7 +102,7 @@ int main(void) /* Initialize all configured peripherals */ MX_GPIO_Init(); -#if 1 +#if 0 if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) { __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); @@ -110,8 +110,9 @@ int main(void) else #endif { - MX_I2C2_Init(); MX_DMA_Init(); + MX_I2C2_Init(); + MX_LoRaWAN_Init(); } diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index db6f972..e97a649 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -93,12 +93,12 @@ void PWR_ExitOffMode(void) void PWR_EnterStopMode(void) { /* USER CODE BEGIN EnterStopMode_1 */ -#if 1 +#if 0 HAL_GPIO_WritePin(GPIOA, 0x65FF, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, 0xFEC3, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOC, 0xDFFF, GPIO_PIN_RESET); #endif -#if 0 +#if 1 HAL_UART_DeInit(&huart2); vcom_DeInit(); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_All, GPIO_PIN_RESET); @@ -135,7 +135,7 @@ void PWR_ExitStopMode(void) /* Resume not retained USARTx and DMA */ MX_GPIO_Init(); -#if 1 +#if 0 MX_I2C2_Init(); MX_DMA_Init(); // vcom_Resume(); diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c index 6f36a09..8655a6f 100644 --- a/Core/Src/stm32wlxx_it.c +++ b/Core/Src/stm32wlxx_it.c @@ -58,14 +58,17 @@ extern RTC_HandleTypeDef hrtc; extern SUBGHZ_HandleTypeDef hsubghz; extern DMA_HandleTypeDef hdma_usart2_tx; +#if 0 extern DMA_HandleTypeDef hdma_usart2_rx; +#endif extern UART_HandleTypeDef huart2; /* USER CODE BEGIN EV */ extern DMA_HandleTypeDef hdma_i2c2_rx; extern DMA_HandleTypeDef hdma_i2c2_tx; +#if 0 extern DMA_HandleTypeDef hdma_usart2_tx; extern DMA_HandleTypeDef hdma_usart2_rx; - +#endif /* USER CODE END EV */ /******************************************************************************/ @@ -218,7 +221,7 @@ void TAMP_STAMP_LSECSS_SSRU_IRQHandler(void) /* USER CODE END TAMP_STAMP_LSECSS_SSRU_IRQn 1 */ } - +#if 0 /** * @brief This function handles EXTI Line 0 Interrupt. */ @@ -246,6 +249,7 @@ void EXTI1_IRQHandler(void) /* USER CODE END EXTI1_IRQn 1 */ } +#endif void EXTI3_IRQHandler(void) { @@ -260,7 +264,7 @@ void EXTI3_IRQHandler(void) /* USER CODE END EXTI3_IRQn 1 */ } - +#if 0 /** * @brief This function handles EXTI Line 1 Interrupt. */ @@ -274,7 +278,8 @@ void EXTI4_IRQHandler(void) /* USER CODE END EXTI1_IRQn 1 */ } - +#endif +#if 0 /* SPI1 */ /** * @brief This function handles DMA1 Channel 2 Interrupt. @@ -303,7 +308,7 @@ void DMA1_Channel3_IRQHandler(void) /* USER CODE END DMA1_Channel3_IRQn 1 */ } - +#endif /* I2C2 */ /** @@ -335,7 +340,7 @@ void DMA1_Channel5_IRQHandler(void) /* USER CODE END DMA1_Channel5_IRQn 1 */ } - +#if 0 // USART2 /** * @brief This function handles DMA1 Channel 6 Interrupt. @@ -364,7 +369,8 @@ void DMA1_Channel7_IRQHandler(void) /* USER CODE END DMA1_Channel7_IRQn 1 */ } - +#endif +#if 0 /** * @brief This function handles EXTI Lines [9:5] Interrupt. */ @@ -383,7 +389,8 @@ void EXTI9_5_IRQHandler(void) /* USER CODE END EXTI9_5_IRQn 1 */ } - +#endif +#if 0 /** * @brief This function handles EXTI Lines [15:10] Interrupt. */ @@ -401,7 +408,8 @@ void EXTI15_10_IRQHandler(void) /* USER CODE END EXTI15_10_IRQn 1 */ } - +#endif +#if 0 /** * @brief This function handles USART2 Interrupt. */ @@ -415,7 +423,7 @@ void USART2_IRQHandler(void) /* USER CODE END USART2_IRQn 1 */ } - +#endif /** * @brief This function handles RTC Alarms (A and B) Interrupt. */ diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 954378b..ac3eaa1 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -26,8 +26,9 @@ 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) @@ -63,10 +64,12 @@ void MX_USART2_UART_Init(void) { Error_Handler(); } +#if 0 if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) { Error_Handler(); } +#endif if (HAL_UARTEx_EnableFifoMode(&huart2) != HAL_OK) { Error_Handler(); @@ -112,9 +115,16 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) GPIO_InitStruct.Alternate = GPIO_AF7_USART2; 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_LOW; + //GPIO_InitStruct.Alternate = GPIO_AF7_USART2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /* USART2 DMA Init */ /* USART2_TX Init */ - hdma_usart2_tx.Instance = DMA1_Channel6; + hdma_usart2_tx.Instance = DMA1_Channel7; hdma_usart2_tx.Init.Request = DMA_REQUEST_USART2_TX; hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE; @@ -136,7 +146,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx); #if 0 /* USART2_RX Init */ - hdma_usart2_rx.Instance = DMA1_Channel7; + hdma_usart2_rx.Instance = DMA1_Channel6; hdma_usart2_rx.Init.Request = DMA_REQUEST_USART2_RX; hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE; @@ -187,9 +197,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) /* USART2 DMA DeInit */ HAL_DMA_DeInit(uartHandle->hdmatx); - - //HAL_DMA_DeInit(uartHandle->hdmarx); - +#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/LoRaWAN/Target/lorawan_conf.h b/LoRaWAN/Target/lorawan_conf.h index 9ddccb0..1706743 100644 --- a/LoRaWAN/Target/lorawan_conf.h +++ b/LoRaWAN/Target/lorawan_conf.h @@ -109,7 +109,7 @@ extern "C" { * - CHANNEL_PLAN_GROUP_AS923_4 (Freq offset = -5.90 MHz / Freq range = 917-920MHz) * - CHANNEL_PLAN_GROUP_AS923_1_JP (Freq offset = 0.0 MHz / Freq range = 920.6-923.4MHz) */ -#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1_JP +#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1 /*! * @brief Limits the number usable channels by default for AU915, CN470 and US915 regions diff --git a/STM32CubeIDE/Release/STS_R1D_HK_2024NOV11.bin b/STM32CubeIDE/Release/STS_R1D_HK_2024NOV11.bin new file mode 100644 index 0000000..e356fa4 Binary files /dev/null and b/STM32CubeIDE/Release/STS_R1D_HK_2024NOV11.bin differ diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.bin b/STM32CubeIDE/Release/WLE5CC_NODE_STS.bin index d6f220c..e356fa4 100644 Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.bin and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.bin differ diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf index 43dbad7..b16036a 100644 Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf differ diff --git a/STM32CubeIDE/Release/makefile b/STM32CubeIDE/Release/makefile index 4a7f8c4..53e0240 100644 --- a/STM32CubeIDE/Release/makefile +++ b/STM32CubeIDE/Release/makefile @@ -14,6 +14,7 @@ RM := rm -rf -include Middlewares/LoRaWAN/subdir.mk -include Drivers/STM32WLxx_HAL_Driver/subdir.mk -include Drivers/CMSIS/subdir.mk +-include Drivers/BSP/STM32WLxx_Nucleo/subdir.mk -include Drivers/BSP/Components/subdir.mk -include Drivers/BSP/53L8A1/subdir.mk -include Application/User/Startup/subdir.mk diff --git a/STM32CubeIDE/Release/sources.mk b/STM32CubeIDE/Release/sources.mk index 3e2536a..6dd14c2 100644 --- a/STM32CubeIDE/Release/sources.mk +++ b/STM32CubeIDE/Release/sources.mk @@ -33,6 +33,7 @@ Application/User/STS/TOF/vl53l0x \ Application/User/Startup \ Drivers/BSP/53L8A1 \ Drivers/BSP/Components \ +Drivers/BSP/STM32WLxx_Nucleo \ Drivers/CMSIS \ Drivers/STM32WLxx_HAL_Driver \ Middlewares/LoRaWAN \