359 lines
8.6 KiB
C
359 lines
8.6 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file stm32f0xx_it.c
|
|
* @brief Interrupt Service Routines.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
* the "License"; You may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at:
|
|
* opensource.org/licenses/BSD-3-Clause
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "main.h"
|
|
#include "stm32f0xx_it.h"
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* USER CODE BEGIN Includes */
|
|
|
|
#include "fifo.h"
|
|
#include "lora.h"
|
|
#include "sensor.h"
|
|
#include "user_tim.h"
|
|
#include "user_flash.h"
|
|
/* USER CODE END Includes */
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* USER CODE BEGIN TD */
|
|
|
|
/* USER CODE END TD */
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN PD */
|
|
|
|
/* USER CODE END PD */
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
/* USER CODE BEGIN PM */
|
|
extern volatile uint8_t IF_LORA_JOINED;
|
|
|
|
/* USER CODE END PM */
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
/* USER CODE BEGIN PV */
|
|
|
|
/* USER CODE END PV */
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/* Private user code ---------------------------------------------------------*/
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
/* External variables --------------------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN EV */
|
|
|
|
/* USER CODE END EV */
|
|
|
|
/******************************************************************************/
|
|
/* Cortex-M0 Processor Interruption and Exception Handlers */
|
|
/******************************************************************************/
|
|
/**
|
|
* @brief This function handles Non maskable interrupt.
|
|
*/
|
|
void NMI_Handler(void)
|
|
{
|
|
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
|
|
|
/* USER CODE END NonMaskableInt_IRQn 0 */
|
|
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
|
|
|
/* USER CODE END NonMaskableInt_IRQn 1 */
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles Hard fault interrupt.
|
|
*/
|
|
void HardFault_Handler(void)
|
|
{
|
|
/* USER CODE BEGIN HardFault_IRQn 0 */
|
|
|
|
/* USER CODE END HardFault_IRQn 0 */
|
|
while (1)
|
|
{
|
|
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
|
/* USER CODE END W1_HardFault_IRQn 0 */
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles System service call via SWI instruction.
|
|
*/
|
|
void SVC_Handler(void)
|
|
{
|
|
/* USER CODE BEGIN SVC_IRQn 0 */
|
|
|
|
/* USER CODE END SVC_IRQn 0 */
|
|
/* USER CODE BEGIN SVC_IRQn 1 */
|
|
|
|
/* USER CODE END SVC_IRQn 1 */
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles Pendable request for system service.
|
|
*/
|
|
void PendSV_Handler(void)
|
|
{
|
|
/* USER CODE BEGIN PendSV_IRQn 0 */
|
|
|
|
/* USER CODE END PendSV_IRQn 0 */
|
|
/* USER CODE BEGIN PendSV_IRQn 1 */
|
|
|
|
/* USER CODE END PendSV_IRQn 1 */
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles System tick timer.
|
|
*/
|
|
void SysTick_Handler(void)
|
|
{
|
|
/* USER CODE BEGIN SysTick_IRQn 0 */
|
|
|
|
/* USER CODE END SysTick_IRQn 0 */
|
|
HAL_IncTick();
|
|
/* USER CODE BEGIN SysTick_IRQn 1 */
|
|
|
|
/* USER CODE END SysTick_IRQn 1 */
|
|
}
|
|
|
|
/******************************************************************************/
|
|
/* STM32F0xx Peripheral Interrupt Handlers */
|
|
/* Add here the Interrupt Handlers for the used peripherals. */
|
|
/* For the available peripheral interrupt handler names, */
|
|
/* please refer to the startup file (startup_stm32f0xx.s). */
|
|
/******************************************************************************/
|
|
|
|
/**
|
|
* @brief This function handles TIM16 global interrupt.
|
|
*/
|
|
void TIM16_IRQHandler(void)
|
|
{
|
|
/* USER CODE BEGIN TIM16_IRQn 0 */
|
|
if(LL_TIM_IsActiveFlag_UPDATE(TIM16))
|
|
{
|
|
IF_LORA_JOINED = ENABLE;
|
|
LL_TIM_ClearFlag_UPDATE(TIM16);
|
|
}
|
|
/* USER CODE END TIM16_IRQn 0 */
|
|
/* USER CODE BEGIN TIM16_IRQn 1 */
|
|
|
|
/* USER CODE END TIM16_IRQn 1 */
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles TIM17 global interrupt.
|
|
*/
|
|
void TIM17_IRQHandler(void)
|
|
{
|
|
/* USER CODE BEGIN TIM17_IRQn 0 */
|
|
static uint32_t count = 0;
|
|
|
|
StopTIM(TIM17);
|
|
if(count >= read_config())
|
|
{
|
|
count = 0;
|
|
TIME_CTRL = TIME_SEND_DATA;
|
|
}
|
|
else
|
|
{
|
|
TIME_CTRL = TIME_GET_DATA;
|
|
}
|
|
count++;
|
|
StartTIM(TIM17);
|
|
/* USER CODE END TIM17_IRQn 0 */
|
|
/* USER CODE BEGIN TIM17_IRQn 1 */
|
|
|
|
/* USER CODE END TIM17_IRQn 1 */
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
|
|
*/
|
|
void USART1_IRQHandler(void)
|
|
{
|
|
/* USER CODE BEGIN USART1_IRQn 0 */
|
|
if(LL_USART_IsActiveFlag_ORE(NH3_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(NH3_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(NH3_USART))
|
|
{
|
|
Write_RingBuff(&nh3.recvRingBuff,LL_USART_ReceiveData8(NH3_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(NH3_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(NH3_USART);
|
|
|
|
SENSOR_CTRL |= NH3_BIT;
|
|
|
|
}
|
|
/* USER CODE END USART1_IRQn 0 */
|
|
/* USER CODE BEGIN USART1_IRQn 1 */
|
|
|
|
/* USER CODE END USART1_IRQn 1 */
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26.
|
|
*/
|
|
void USART2_IRQHandler(void)
|
|
{
|
|
/* USER CODE BEGIN USART2_IRQn 0 */
|
|
// if(LL_USART_IsActiveFlag_RXNE(DEBUG_USART))
|
|
// {
|
|
// uint8_t Res = LL_USART_ReceiveData8(DEBUG_USART);
|
|
// LL_USART_TransmitData8(LORA_USART,Res);
|
|
// while(LL_USART_IsActiveFlag_TXE(LORA_USART)==RESET);
|
|
// }
|
|
if(LL_USART_IsActiveFlag_ORE(DEBUG_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(DEBUG_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(DEBUG_USART))
|
|
{
|
|
Write_RingBuff(&lora.recvRingBuff,LL_USART_ReceiveData8(DEBUG_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(DEBUG_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(DEBUG_USART);
|
|
SENSOR_CTRL |= LORA_BIT;
|
|
}
|
|
|
|
|
|
/* USER CODE END USART2_IRQn 0 */
|
|
/* USER CODE BEGIN USART2_IRQn 1 */
|
|
|
|
/* USER CODE END USART2_IRQn 1 */
|
|
}
|
|
|
|
/**
|
|
* @brief This function handles USART3 to USART8 global interrupts / USART3 wake-up interrupt through EXTI line 28.
|
|
*/
|
|
void USART3_8_IRQHandler(void)
|
|
{
|
|
/* USER CODE BEGIN USART3_8_IRQn 0 */
|
|
if(LL_USART_IsActiveFlag_ORE(CO2_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(CO2_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(CO2_USART))
|
|
{
|
|
Write_RingBuff(&co2.recvRingBuff,LL_USART_ReceiveData8(CO2_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(CO2_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(CO2_USART);
|
|
SENSOR_CTRL |= CO2_BIT;
|
|
}
|
|
|
|
|
|
if(LL_USART_IsActiveFlag_ORE(PM25_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(PM25_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(PM25_USART))
|
|
{
|
|
Write_RingBuff(&pm25.recvRingBuff,LL_USART_ReceiveData8(PM25_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(PM25_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(PM25_USART);
|
|
|
|
SENSOR_CTRL |= PM25_BIT;
|
|
}
|
|
|
|
|
|
if(LL_USART_IsActiveFlag_ORE(CH2O_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(CH2O_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(CH2O_USART))
|
|
{
|
|
Write_RingBuff(&ch2o.recvRingBuff,LL_USART_ReceiveData8(CH2O_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(CH2O_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(CH2O_USART);
|
|
SENSOR_CTRL |= CH2O_BIT;
|
|
}
|
|
|
|
|
|
if(LL_USART_IsActiveFlag_ORE(O3_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(O3_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(O3_USART))
|
|
{
|
|
Write_RingBuff(&o3.recvRingBuff,LL_USART_ReceiveData8(O3_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(O3_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(O3_USART);
|
|
SENSOR_CTRL |= O3_BIT;
|
|
}
|
|
|
|
|
|
if(LL_USART_IsActiveFlag_ORE(H2S_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(H2S_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(H2S_USART))
|
|
{
|
|
Write_RingBuff(&h2s.recvRingBuff,LL_USART_ReceiveData8(H2S_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(H2S_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(H2S_USART);
|
|
SENSOR_CTRL |= H2S_BIT;
|
|
}
|
|
|
|
|
|
if(LL_USART_IsActiveFlag_ORE(LORA_USART))
|
|
{
|
|
LL_USART_ClearFlag_ORE(LORA_USART);
|
|
}
|
|
if(LL_USART_IsActiveFlag_RXNE(LORA_USART))
|
|
{
|
|
Write_RingBuff(&lora.recvRingBuff,LL_USART_ReceiveData8(LORA_USART));
|
|
}
|
|
if(LL_USART_IsActiveFlag_IDLE(LORA_USART))
|
|
{
|
|
LL_USART_ClearFlag_IDLE(LORA_USART);
|
|
SENSOR_CTRL |= LORA_BIT;
|
|
}
|
|
|
|
/* USER CODE END USART3_8_IRQn 0 */
|
|
|
|
/* USER CODE BEGIN USART3_8_IRQn 1 */
|
|
|
|
/* USER CODE END USART3_8_IRQn 1 */
|
|
}
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|