/**
******************************************************************************
* @file stm8s_it.c
* @author MCD Application Team
* @version V2.2.0
* @date 30-September-2014
* @brief Main Interrupt Service Routines.
* This file provides template for all peripherals interrupt service
* routine.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s_it.h"
#include "tim1.h"
#include "uart1.h"
#include "stdio.h"
#include "string.h"
#include "main.h"
#include "uart3.h"
#include "modbus.h"
#include "rainfall.h"
#include "iwdg.h"
/** @addtogroup Template_Project
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
u8 UART1_Rxbuffer[64] = {0};
u8 UART1_Rxbuffer_Cnt = 0;
u8 UART1_Txbuffer[64] = {0};
u8 UART1_Txbuffer_Cnt = 0;
u8 UART3_Rxbuffer[64] = {0};
u8 UART3_Rxbuffer_Cnt = 0;
u8 UART3_Txbuffer[64] = {0};
u8 UART3_Txbuffer_Cnt = 0;
u8 RainFall_Get_Satus = 0;
u8 UART3_RX_TIMES;
u8 UART1_RX_TIMES;
u32 TimDelay_us = 0;
u32 TimDelay_us111 = 0;
u8 PB2_Status;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
#ifdef _COSMIC_
/**
* @brief Dummy Interrupt routine
* @par Parameters:
* None
* @retval
* None
*/
INTERRUPT_HANDLER(NonHandledInterrupt, 25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*_COSMIC_*/
/**
* @brief TRAP Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Top Level Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TLI_IRQHandler, 0)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
// if(!GPIO_ReadInputPin(GPIOB,GPIO_PIN_3))
// {
// RainFall.Value16++;
// }
}
/**
* @brief Auto Wake Up Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(AWU_IRQHandler, 1)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Clock Controller Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CLK_IRQHandler, 2)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTA Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTB Interrupt routine.
* @param None
* @retval None
*/
#if RAINFALL//雨量传感器中断使用
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)////////////////////////////////////////////////////////
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
if(GPIO_ReadInputPin(GPIOB,GPIO_PIN_3) == 0)
{
LED_Toggle;
RainFall.Value16++;
if(RainFall.Value16 >= 2000)
{
RainFall.Value16 = 2000;
}
while(!RainFall_Write_To_EEPROM(RainFall.Value8,RAINFALL_EEPROM_ADDR));
PB3_Exit_Cnt = PB3_Exit_Cnt+1;
if(PB3_Exit_Cnt > 30)
{
IWDG_Config();
TIM1_ITConfig(TIM1_IT_UPDATE , DISABLE);
while(1);
}
}
if(GPIO_ReadInputPin(GPIOB,GPIO_PIN_2) == 0)
{
LED_Toggle;
PB2_Exit_Cnt = PB2_Exit_Cnt+1;
if(PB2_Exit_Cnt > 20)
{
IWDG_Config();
TIM1_ITConfig(TIM1_IT_UPDATE , DISABLE);
while(1);
}
RainFall_Get_Satus = 1;
}
}
#endif
/**
* @brief External Interrupt PORTC Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTD Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTE Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#if defined (STM8S903) || defined (STM8AF622x)
/**
* @brief External Interrupt PORTF Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined (STM8AF52Ax)
/**
* @brief CAN RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief CAN TX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S208) || (STM8AF52Ax) */
/**
* @brief SPI Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(SPI_IRQHandler, 10)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler,11)//定时器1中断
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
i