diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index f10502a..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_M +#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,13 +75,13 @@ 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 * @note 0: LowPowerMode enabled. MCU enters stop2 mode, 1: LowPowerMode disabled. MCU enters sleep mode only */ -#define LOW_POWER_DISABLE 1 +#define LOW_POWER_DISABLE 0 /* USER CODE BEGIN EC */ diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index eaca7b8..172fbd9 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -52,9 +52,10 @@ void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, LED1_Pin|LED2_Pin|PROB2_Pin|PROB1_Pin |LED3_Pin, GPIO_PIN_RESET); +#ifdef L8 HAL_GPIO_WritePin(VL53L8A1_PWR_EN_C_PORT, VL53L8A1_PWR_EN_C_PIN, GPIO_PIN_SET); HAL_GPIO_WritePin(VL53L8A1_LPn_C_PORT, VL53L8A1_LPn_C_PIN, GPIO_PIN_SET); - +#endif /*Configure GPIO pins : PBPin PBPin PBPin */ GPIO_InitStruct.Pin = LED1_Pin|LED2_Pin|LED3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; diff --git a/Core/Src/main.c b/Core/Src/main.c index e6b23b1..66c56f9 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -102,10 +102,17 @@ int main(void) /* Initialize all configured peripherals */ MX_GPIO_Init(); - MX_I2C2_Init(); - MX_DMA_Init(); + if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) + { + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); + } + else + { + MX_I2C2_Init(); + MX_DMA_Init(); + MX_LoRaWAN_Init(); + } - MX_LoRaWAN_Init(); /* USER CODE BEGIN 2 */ MX_USART2_UART_Init(); /* USER CODE END 2 */ @@ -165,7 +172,7 @@ void SystemClock_Config(void) RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1; + //RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c index 9b11947..d3e538e 100644 --- a/Core/Src/stm32wlxx_it.c +++ b/Core/Src/stm32wlxx_it.c @@ -357,7 +357,9 @@ void EXTI15_10_IRQHandler(void) /* USER CODE BEGIN EXTI15_10_IRQn 0 */ /* USER CODE END EXTI15_10_IRQn 0 */ +#if defined(L8)||defined(STS_P2)||defined(STS_R1D)||defined(STS_R5) HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN); +#endif /* USER CODE BEGIN EXTI15_10_IRQn 1 */ /* USER CODE END EXTI15_10_IRQn 1 */ diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 52be86c..141d956 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -1107,6 +1107,7 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams) LmHandlerParams.IsTxConfirmed = true; LmHandlerErrorStatus_t status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false); if (status ==LORAMAC_HANDLER_SUCCESS ) LmHandlerParams.IsTxConfirmed = false; + } else { @@ -1456,26 +1457,26 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context) * @brief Yunhorn STS Heart Beat Periodicity Chagne function * @param duration of periodicty in ms (1/1000 sec) */ -void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity) +void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t newperiodicity) { /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_1 */ /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_1 */ - if (periodicity == 0) + if (newperiodicity == 0) { /* Revert to application default Heat-beat periodicity */ - periodicity = 10*APP_TX_DUTYCYCLE; //10*10 000 ms + newperiodicity = 10*APP_TX_DUTYCYCLE; //10*10 000 ms } /* Update timer YunhornSTSHeartBeatTimer */ UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer); - UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, periodicity); + UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, newperiodicity); UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */ - APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 ); + APP_LOG(TS_OFF, VLEVEL_H,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 ); /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */ } @@ -1508,6 +1509,6 @@ void OnYunhornSTSTxPeriodicityChanged(uint32_t periodicity) UTIL_TIMER_Start(&TxTimer); /* USER CODE BEGIN OnYunhornSTSTxPeriodicityChanged */ - APP_LOG(TS_OFF, VLEVEL_M,"* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 ); + APP_LOG(TS_OFF, VLEVEL_H,"* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 ); /* USER CODE END OnYunhornSTSTxPeriodicityChanged */ } diff --git a/LoRaWAN/App/lora_app.h b/LoRaWAN/App/lora_app.h index 52f4d16..ae4a403 100644 --- a/LoRaWAN/App/lora_app.h +++ b/LoRaWAN/App/lora_app.h @@ -68,7 +68,7 @@ extern "C" { /*! * LoRaWAN default class */ -#define LORAWAN_DEFAULT_CLASS CLASS_C +#define LORAWAN_DEFAULT_CLASS CLASS_A /*! * LoRaWAN default confirm state diff --git a/LoRaWAN/Target/lorawan_conf.h b/LoRaWAN/Target/lorawan_conf.h index 1706743..9ddccb0 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 +#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1_JP /*! * @brief Limits the number usable channels by default for AU915, CN470 and US915 regions diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index a2e5ab8..521ff96 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -133,7 +133,7 @@