switch_test/User/stm32f4xx_it.c

309 lines
6.8 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
******************************************************************************
* @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c
* @author MCD Application Team
* @version V1.8.0
* @date 04-November-2016
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2016 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 "stm32f4xx_it.h"
#include "basic.h"
int it_100us_flag = 0; //100us<75><73>ʱ<EFBFBD><CAB1>־
int it_100us_cnt = 0;
int it_500us_flag = 0; //100us<75><73>ʱ<EFBFBD><CAB1>־
int it_500us_cnt = 0;
int it_1ms_flag = 0; //1ms<6D><73>ʱ<EFBFBD><CAB1>־
int it_1ms_cnt = 0;
int it_50ms_flag = 0; //10ms<6D><73>ʱ<EFBFBD><CAB1>־
int it_50ms_cnt = 0;
int it_100ms_flag = 0; //100ms<6D><73>ʱ<EFBFBD><CAB1>־
int it_100ms_cnt = 0;
int it_500ms_flag = 0; //300ms<6D><73>ʱ<EFBFBD><CAB1>־
int it_500ms_cnt = 0;
int it_1s_flag = 0; //1s<31><73>ʱ<EFBFBD><CAB1>־
int it_1s_cnt = 0;
int time_cnt = 0;
int x = 0;
extern void TimingDelay_Decrement(void);
//定时器3中断
void TIM3_IRQHandler(void)
{
if(TIM_GetITStatus(TIM3,TIM_IT_Update) != RESET)
{
it_100us_cnt++;
if(it_100us_cnt >= 1)
{
it_100us_flag = 1;
it_100us_cnt = 0;
//检查时间测试标志
if(get_time_flag == 2)
{
if(time_cnt >= 2)//延时3s
get_time();
}
}
it_500us_cnt++;
if(it_500us_cnt >= 5)
{
it_500us_flag = 1;
it_500us_cnt = 0;
}
it_1ms_cnt++;
if(it_1ms_cnt >= 10)
{
it_1ms_flag = 1;
it_1ms_cnt = 0;
}
it_50ms_cnt++;
if(it_50ms_cnt >= 500)
{
it_50ms_flag = 1;
it_50ms_cnt = 0;
//检查频率测试标志
if(Mode_Flag == 3)
{
//光电开关变换频率
count_array[N] = count;
count_sum += count_array[N];
count = 0;
//ADC变换频率
ADC_Count_array[N] = ADC_Count;
ADC_Count_sum += ADC_Count_array[N];
ADC_Count = 0;
N++;
//取20次总和
if(N>=20)
{
MOT_Fre = count_sum;
ADC_Fre = ADC_Count_sum;
N = 0;
count_sum = 0;
ADC_Count_sum = 0;
}
}
}
it_100ms_cnt++;
if(it_100ms_cnt >= 1000)
{
it_100ms_flag = 1;
it_100ms_cnt = 0;
}
it_500ms_cnt++;
if(it_500ms_cnt >= 5000)
{
it_500ms_flag = 1;
it_500ms_cnt = 0;
}
it_1s_cnt++;
if(it_1s_cnt >= 10000)
{
//时间测试计时
if(get_time_flag == 2)
time_cnt++;
//依次断开ADC
else if(get_time_flag == 3)
{
time_cnt = 0;
GPIO_ResetBits(GPIOF,GPIO_Pin_11); //断开
get_time_flag = 2;
}
it_1s_flag = 1;
it_1s_cnt = 0;
}
TIM_ClearITPendingBit(TIM3,TIM_IT_Update);
}
}
//串口1中断
void USART1_IRQHandler(void)
{
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
{
unsigned char ch = 0;
ch = USART_ReceiveData(USART1);
//printf("%c",ch);
receive_ttl_data(ch);
//USART_ClearFlag(USART1, USART_FLAG_RXNE);
}
}
//<2F>жϻ<D0B6><CFBB><EFBFBD><E6B4AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//#define UART_BUFF_SIZE 10
//int buf_flag = 0;
//volatile uint16_t uart_p = 0;
//uint8_t uart_buff[UART_BUFF_SIZE];
void USART3_IRQHandler(void) //<2F><><EFBFBD><EFBFBD>3<EFBFBD>жϷ<D0B6><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
if(USART_GetFlagStatus(USART3, USART_FLAG_IDLE) == SET)
{
DealWith_UartData();
get_length(com3_rx_buffer);
USART3->SR;
USART3->DR; //<2F><>USART_IT_IDLE<4C><45>־
//USART_ReceiveData(USART3); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ<D6BE><CEBB><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ<D6BE><CEBB><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
}
}
//外部IO中断对应频率测试光电开关
void EXTI9_5_IRQHandler(void)
{
//ȷ<><C8B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EXTI Line<6E>ж<EFBFBD>
if(EXTI_GetITStatus(EXTI_Line6) != RESET)
{
count++;
//<2F><><EFBFBD><EFBFBD>жϱ<D0B6>־λ
EXTI_ClearITPendingBit(EXTI_Line6);
}
}
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSVC exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
TimingDelay_Decrement();
}
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32f4xx.s). */
/******************************************************************************/
/**
* @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/