diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index 4dd4cfe..9cd7e13 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -59,8 +59,8 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOC_CLK_ENABLE(); GPIO_InitStruct.Pin = BUT1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); #if 0 diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index f358f2d..f174631 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -94,9 +94,9 @@ void PWR_EnterStopMode(void) /* USER CODE BEGIN EnterStopMode_1 */ /* USER CODE END EnterStopMode_1 */ - //HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_RESET); //HAL_GPIO_WritePin(GPIOC, GPIO_PIN_All, GPIO_PIN_RESET); - //HAL_GPIO_WritePin(GPIOA, GPIO_PIN_All, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOA, ~GPIO_PIN_0, GPIO_PIN_RESET); HAL_SuspendTick(); /* Clear Status Flag before entering STOP/STANDBY Mode */ LL_PWR_ClearFlag_C1STOP_C1STB(); diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 91208f1..fcc4c65 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -342,7 +342,7 @@ static UTIL_TIMER_Object_t JoinLedTimer; /* Exported functions ---------------------------------------------------------*/ /* USER CODE BEGIN EF */ - +volatile uint8_t door_status=0, door_changed_flag=0, door_previous_status=0; /* USER CODE END EF */ void LoRaWAN_Init(void) @@ -666,12 +666,21 @@ static void SendTxData(void) static void OnTxTimerEvent(void *context) { /* USER CODE BEGIN OnTxTimerEvent_1 */ - + door_status = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0); + if (door_status != door_previous_status) + { + door_changed_flag = 1; + door_previous_status = door_status; + } /* USER CODE END OnTxTimerEvent_1 */ - UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); + if (door_changed_flag ==1 ) + { + door_changed_flag = 0; + UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); - /*Wait for next tx slot*/ - UTIL_TIMER_Start(&TxTimer); + /*Wait for next tx slot*/ + UTIL_TIMER_Start(&TxTimer); + } /* USER CODE BEGIN OnTxTimerEvent_2 */ /* USER CODE END OnTxTimerEvent_2 */