📄 stm32f10x_it.c
字号:
#include "stm32f10x_it.h"
/** @addtogroup STM32F10x_StdPeriph_Examples
* @{
*/
/** @addtogroup SysTick_TimeBase
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M3 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @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)
{
// GPIO_SetBits(LCD_BACKLIGHT_PORT, LCD_BACKLIGHT_PIN);
/* 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)
{
// GPIO_SetBits(LCD_BACKLIGHT_PORT, LCD_BACKLIGHT_PIN);
/* 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)
{
// GPIO_SetBits(LCD_BACKLIGHT_PORT, LCD_BACKLIGHT_PIN);
/* 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 PendSV_Handler exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
gSystem_1ms_CNT++;
}
/******************************************************************************/
/* STM32F10x 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_stm32f10x_xx.s). */
/******************************************************************************/
void LCD_MASTER_DMA_IRQHandler(void)
{
if(DMA_GetITStatus(LCD_MASTER_DMA_IT_TC))
{
DMA_ClearITPendingBit(LCD_MASTER_DMA_IT_TC);
FLAG_LCD_MASTER_DMA_TRANSMITTING = RESET;
DMA_Cmd(LCD_MASTER_DMA_CHN, DISABLE);
}
}
void SIG_GEN_TIMER_IRQHandler(void)
{
if (TIM_GetITStatus(SIG_GEN_TIMER, TIM_IT_Update) != RESET)
{
// 10 pules of sonar have been sent out
TIM_ClearITPendingBit(SIG_GEN_TIMER, TIM_IT_Update);
TIM_CtrlPWMOutputs(SIG_GEN_TIMER, DISABLE);
TIM_Cmd(SIG_GEN_TIMER, DISABLE);
// Contact the relay
// #ifdef TESTPIN_ENABLE
// if (SIG_In_Relay_CNT < SIG_IN_RELAY_SW_THRE)
// {
// SIG_In_Relay_CNT++;
// TEST_PIN_3_HIGH;
// }
// else if (SIG_In_Relay_CNT < SIG_IN_RELAY_SW_THRE + SIG_IN_RELAY_SW_THRE)
// {
// SIG_In_Relay_CNT++;
// //TEST_PIN_3_LOW;
// }
// else
// {
// SIG_In_Relay_CNT = 0;
// }
// #endif
/* -------========= Test to see if keep releasing is still connected ===========-------- */
/* -------========= No, the raw signal is clear, but after OP there is some sonar signal ===========-------- */
RECV_RELAY_CONTACT;
// Get CNT from SIG_DETECT_TIMER which will be used to judge if relay has fully contact without bounce
gRelayStartCloseCNT = TIM_GetCounter(SIG_DETECT_TIMER);
FLAG_SIG_TX_FINISHED = SET;
}
}
void SIG_DETECT_TIMER_IRQHandler(void)
{
// Max receiving time reached
if (TIM_GetITStatus(SIG_DETECT_TIMER, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(SIG_DETECT_TIMER, TIM_IT_Update);
TIM_Cmd(SIG_DETECT_TIMER, DISABLE);
FLAG_SIG_RECV_TIME_REACH = SET;
// Disable SIG input interrupt
DISABLE_SIG_EXTI;
// Release the relay
OUTPUT_RELAY_RELEASE;
// #ifdef TESTPIN_ENABLE
// //TEST_PIN_3_LOW;
// TEST_PIN_1_LOW;
// #endif
}
}
// Sonar's circle period is 5us,
// So after receive the first interrupt, next should happen in 5us
void SIG_IN_EXTI_IRQHandler(void)
{
static uint16_t sta_LastTimeSIGIn;
uint16_t temp_ThisTimeSIGIn;
if(EXTI_GetITStatus(SIG_RECV_EXTI_LINE) != RESET)
{
if (0 == gReceivedHop)
{ // The first time receive SIG after relay contact
gReceivedHop++;
sta_LastTimeSIGIn = TIM_GetCounter(SIG_DETECT_TIMER);
}
else
{
temp_ThisTimeSIGIn = TIM_GetCounter(SIG_DETECT_TIMER);
// If in 4us ~ 6us range
if (abs(temp_ThisTimeSIGIn - sta_LastTimeSIGIn - SIG_200K_PULSE_DUTY_HM) <= SIG_IN_PERIOD_SHIFT_THR)
{
gReceivedHop++;
sta_LastTimeSIGIn = temp_ThisTimeSIGIn;
}
else
{
gReceivedHop = 0;
}
if (SIG_IN_SUCC_RECV_THR == gReceivedHop)
{ // If successfully received 3 times of normal waveform
// ------======!!!!!! CONGRATULATION !!!!!!======------
gReceivedHop = 0;
gSIGDetectRawCNT = temp_ThisTimeSIGIn - 10; // 2 or 2.5 circles, who care
FLAG_SIG_SUCC_RECVEIVED = SET;
}
}
/* Clear the EXTI line 0 pending bit */
EXTI_ClearITPendingBit(SIG_RECV_EXTI_LINE);
}
}
#ifdef DEBUG
void UART_DEBUG_DMA_IRQHandler(void)
{
if(DMA_GetITStatus(UART_DEBUG_DMA_IT_TC))
{
DMA_ClearITPendingBit(UART_DEBUG_DMA_IT_TC);
FLAG_UART_DEBUG_DMA_TRANSMITTING = RESET;
DMA_Cmd(UART_DEBUG_DMA_CHN, DISABLE);
}
}
#endif
/**
* @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/
/**
* @}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -