rt-thread-official/bsp/efm32/hdl_interrupt.c

878 lines
23 KiB
C
Raw Normal View History

2013-01-08 22:40:58 +08:00
/***************************************************************************//**
* @file hdl_interrupt.c
* @brief Interrupt handler of RT-Thread RTOS for EFM32
* COPYRIGHT (C) 2012, RT-Thread Development Team
* @author onelife
* @version 1.0
*******************************************************************************
* @section License
* The license and distribution terms for this file may be found in the file
* LICENSE in this distribution or at http://www.rt-thread.org/license/LICENSE
*******************************************************************************
* @section Change Logs
* Date Author Notes
* 2010-12-29 onelife Initial creation for EFM32
* 2011-07-12 onelife Disable interrupts in GPIO handler
2021-03-27 15:16:57 +08:00
* 2011-12-09 onelife Add giant gecko support
2013-01-08 22:40:58 +08:00
* 2011-12-09 onelife Add UART module support
* 2011-12-09 onelife Add LEUART module support
2021-03-27 15:16:57 +08:00
* 2011-12-27 onelife Utilize "XXX_PRESENT" and "XXX_COUNT"
2013-01-08 22:40:58 +08:00
******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "board.h"
#include "hdl_interrupt.h"
/***************************************************************************//**
* @addtogroup efm32
* @{
******************************************************************************/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
#ifdef RT_IRQHDL_DEBUG
2021-03-27 15:16:57 +08:00
#define hdl_debug(format,args...) rt_kprintf(format, ##args)
2013-01-08 22:40:58 +08:00
#else
#define hdl_debug(format,args...)
#endif
/* Private variables ---------------------------------------------------------*/
2021-03-27 15:16:57 +08:00
efm32_irq_hook_t dmaCbTable[DMA_CHAN_COUNT * 2] = {RT_NULL};
efm32_irq_hook_t timerCbTable[TIMER_COUNT] = {RT_NULL};
2013-01-08 22:40:58 +08:00
#if defined(LETIMER_PRESENT)
efm32_irq_hook_t letimerCbTable[LETIMER_COUNT] = {RT_NULL};
#endif
2021-03-27 15:16:57 +08:00
efm32_irq_hook_t rtcCbTable[RTC_COUNT] = {RT_NULL};
efm32_irq_hook_t gpioCbTable[16] = {RT_NULL};
efm32_irq_hook_t acmpCbTable[ACMP_COUNT] = {RT_NULL};
2013-01-08 22:40:58 +08:00
#if defined(USART_PRESENT)
#if defined(UART_PRESENT)
efm32_irq_hook_t usartCbTable[USART_COUNT * 2 + UART_COUNT * 2] = {RT_NULL};
#else
efm32_irq_hook_t usartCbTable[USART_COUNT * 2] = {RT_NULL};
#endif
#endif
#if defined(LEUART_PRESENT)
efm32_irq_hook_t leuartCbTable[LEUART_COUNT] = {RT_NULL};
#endif
#if defined(I2C_PRESENT)
2021-03-27 15:16:57 +08:00
efm32_irq_hook_t iicCbTable[I2C_COUNT] = {RT_NULL};
2013-01-08 22:40:58 +08:00
#endif
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* NMI exception handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
******************************************************************************/
void NMI_Handler(void)
{
2021-03-27 15:16:57 +08:00
hdl_debug("[NMI_Handler: NOP]\n");
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Memory manage exception handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
******************************************************************************/
void MemManage_Handler(void)
{
2021-03-27 15:16:57 +08:00
hdl_debug("[MemManage_Handler: infinite loop]\n");
while (1);
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Bus fault exception handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
******************************************************************************/
void BusFault_Handler(void)
{
2021-03-27 15:16:57 +08:00
hdl_debug("[BusFault_Handler: infinite loop]\n");
while (1);
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Usage fault exception handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
******************************************************************************/
void UsageFault_Handler(void)
{
2021-03-27 15:16:57 +08:00
hdl_debug("[UsageFault_Handler: infinite loop]\n");
while (1);
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Supervisor call exception handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
******************************************************************************/
void SVC_Handler(void)
{
2021-03-27 15:16:57 +08:00
hdl_debug("[SVC_Handler: NOP]\n");
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Debug monitor exception handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
******************************************************************************/
void DebugMon_Handler(void)
{
2021-03-27 15:16:57 +08:00
hdl_debug("[DebugMon_Handler: NOP]\n");
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* System tick timer interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
*
******************************************************************************/
void SysTick_Handler(void)
{
2021-03-27 15:16:57 +08:00
/* enter interrupt */
rt_interrupt_enter();
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
rt_tick_increase();
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* leave interrupt */
rt_interrupt_leave();
2013-01-08 22:40:58 +08:00
}
/*******************************************************************************
* 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).
/******************************************************************************/
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common DMA interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
*
******************************************************************************/
void DMA_IRQHandler_All(rt_uint32_t channel, rt_bool_t primary, void *user)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
/* invoke callback function */
if (dmaCbTable[channel].cbFunc != RT_NULL)
{
(dmaCbTable[channel].cbFunc)(dmaCbTable[channel].userPtr);
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common Timer0 interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles Timer0 counter overflow interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void TIMER0_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (TIMER0->IF & TIMER_IF_OF)
{
/* invoke callback function */
if (timerCbTable[0].cbFunc != RT_NULL)
{
(timerCbTable[0].cbFunc)(timerCbTable[0].userPtr);
}
/* clear interrupt */
BITBAND_Peripheral(&(TIMER0->IFC), _TIMER_IF_OF_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common Timer1 interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles Timer1 counter overflow interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void TIMER1_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (TIMER1->IF & TIMER_IF_OF)
{
/* invoke callback function */
if (timerCbTable[1].cbFunc != RT_NULL)
{
(timerCbTable[1].cbFunc)(timerCbTable[1].userPtr);
}
/* clear interrupt */
BITBAND_Peripheral(&(TIMER1->IFC), _TIMER_IF_OF_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common Timer2 interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles Timer2 counter overflow interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void TIMER2_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (TIMER2->IF & TIMER_IF_OF)
{
/* invoke callback function */
if (timerCbTable[2].cbFunc != RT_NULL)
{
(timerCbTable[2].cbFunc)(timerCbTable[2].userPtr);
}
/* clear interrupt */
BITBAND_Peripheral(&(TIMER2->IFC), _TIMER_IF_OF_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
}
#if defined(LETIMER_PRESENT)
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common Low Energy Timer0 interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles Timer0 counter overflow interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void LETIMER0_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (LETIMER0->IF & LETIMER_IF_UF)
{
2013-01-08 22:40:58 +08:00
/* enter interrupt */
rt_interrupt_enter();
rt_tick_increase();
/* leave interrupt */
rt_interrupt_leave();
2021-03-27 15:16:57 +08:00
/* invoke callback function */
/* if (letimerCbTable[0].cbFunc != RT_NULL)
{
(letimerCbTable[0].cbFunc)(letimerCbTable[0].userPtr);
}
2013-01-08 22:40:58 +08:00
*/
2021-03-27 15:16:57 +08:00
/* clear interrupt */
BITBAND_Peripheral(&(LETIMER0->IFC), _LETIMER_IF_UF_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
}
#endif
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common RTC interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles RTC counter overflow interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void RTC_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
if (RTC->IF & RTC_IF_OF)
{
/* invoke callback function */
if (rtcCbTable[0].cbFunc != RT_NULL)
{
(rtcCbTable[0].cbFunc)(rtcCbTable[0].userPtr);
}
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common even number GPIO interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
*
******************************************************************************/
void GPIO_EVEN_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
rt_uint16_t flag, n;
rt_base_t level;
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* Disable interrupt */
level = rt_hw_interrupt_disable();
2013-01-08 22:40:58 +08:00
/* Enter ISR */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
/* invoke callback function */
flag = (rt_uint16_t)(GPIO->IF & 0xFFFF);
for ( n = 0; flag > 0; flag = flag >> 2, n = n + 2)
{
if ((flag & 0x0001) && (gpioCbTable[n].cbFunc != RT_NULL))
{
(gpioCbTable[n].cbFunc)(gpioCbTable[n].userPtr);
}
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* clear interrupt */
GPIO->IFC = 0x5555UL;
2013-01-08 22:40:58 +08:00
/* Leave ISR */
2021-03-27 15:16:57 +08:00
rt_interrupt_leave();
/* Enable interrupt */
2013-01-08 22:40:58 +08:00
rt_hw_interrupt_enable(level);
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common odd number GPIO interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
*
******************************************************************************/
void GPIO_ODD_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
rt_uint16_t flag, n;
rt_base_t level;
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* Disable interrupt */
level = rt_hw_interrupt_disable();
/* Enter ISR */
2013-01-08 22:40:58 +08:00
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
/* invoke callback function */
flag = (rt_uint16_t)(GPIO->IF & 0xFFFF) >> 1;
for ( n = 1; flag > 0; flag = flag >> 2, n = n + 2)
{
if ((flag & 0x0001) && (gpioCbTable[n].cbFunc != RT_NULL))
{
(gpioCbTable[n].cbFunc)(gpioCbTable[n].userPtr);
}
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* clear interrupt */
GPIO->IFC = 0xAAAAUL;
2013-01-08 22:40:58 +08:00
/* Leave ISR */
2021-03-27 15:16:57 +08:00
rt_interrupt_leave();
/* Enable interrupt */
2013-01-08 22:40:58 +08:00
rt_hw_interrupt_enable(level);
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common ACMP interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles ACMP edge trigger interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void ACMP0_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
if (ACMP0->IF & ACMP_IF_EDGE)
{
/* invoke callback function */
if (acmpCbTable[0].cbFunc != RT_NULL)
{
(acmpCbTable[0].cbFunc)(acmpCbTable[0].userPtr);
}
/* clear interrupt */
BITBAND_Peripheral(&(ACMP0->IFC), _ACMP_IF_EDGE_SHIFT, 0x1UL);
}
if (ACMP1->IF & ACMP_IF_EDGE)
{
/* invoke callback function */
if (acmpCbTable[1].cbFunc != RT_NULL)
{
(acmpCbTable[1].cbFunc)(acmpCbTable[1].userPtr);
}
/* clear interrupt */
BITBAND_Peripheral(&(ACMP1->IFC), _ACMP_IF_EDGE_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
#if defined(USART_PRESENT)
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common USART0 TX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles USART0 TX complete interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void USART0_TX_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
if (USART0->IF & USART_IF_TXC)
{
/* invoke callback function */
if (usartCbTable[0].cbFunc != RT_NULL)
{
(usartCbTable[0].cbFunc)(usartCbTable[0].userPtr);
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* clear interrupt */
BITBAND_Peripheral(&(USART0->IFC), _USART_IF_TXC_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common USART0 RX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles USART0 RX data valid interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void USART0_RX_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (USART0->IF & USART_IF_RXDATAV)
{
/* invoke callback function */
if (usartCbTable[1].cbFunc != RT_NULL)
{
(usartCbTable[1].cbFunc)(usartCbTable[1].userPtr);
}
}
2013-01-08 22:40:58 +08:00
}
#endif
#if (defined(USART_PRESENT) && (USART_COUNT > 1))
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common USART1 TX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles USART1 TX complete interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void USART1_TX_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
if (USART1->IF & USART_IF_TXC)
{
/* invoke callback function */
if (usartCbTable[2].cbFunc != RT_NULL)
{
(usartCbTable[2].cbFunc)(usartCbTable[2].userPtr);
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* clear interrupt */
BITBAND_Peripheral(&(USART1->IFC), _USART_IF_TXC_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common USART1 RX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles USART1 RX data valid interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void USART1_RX_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (USART1->IF & USART_IF_RXDATAV)
{
/* invoke callback function */
if (usartCbTable[3].cbFunc != RT_NULL)
{
(usartCbTable[3].cbFunc)(usartCbTable[3].userPtr);
}
}
2013-01-08 22:40:58 +08:00
}
#endif
#if (defined(USART_PRESENT) && (USART_COUNT > 2))
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common USART2 TX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles USART2 TX complete interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void USART2_TX_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
if (USART2->IF & USART_IF_TXC)
{
/* invoke callback function */
if (usartCbTable[4].cbFunc != RT_NULL)
{
(usartCbTable[4].cbFunc)(usartCbTable[4].userPtr);
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* clear interrupt */
BITBAND_Peripheral(&(USART2->IFC), _USART_IF_TXC_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common USART2 RX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles USART2 RX data valid interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void USART2_RX_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (USART2->IF & USART_IF_RXDATAV)
{
/* invoke callback function */
if (usartCbTable[5].cbFunc != RT_NULL)
{
(usartCbTable[5].cbFunc)(usartCbTable[5].userPtr);
}
}
2013-01-08 22:40:58 +08:00
}
#endif
#if defined(UART_PRESENT)
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common UART0 TX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles UART0 TX complete interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void UART0_TX_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
if (UART0->IF & UART_IF_TXC)
{
/* invoke callback function */
if (usartCbTable[USART_COUNT * 2].cbFunc != RT_NULL)
{
(usartCbTable[USART_COUNT * 2].cbFunc)(usartCbTable[USART_COUNT * 2].userPtr);
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* clear interrupt */
BITBAND_Peripheral(&(UART0->IFC), _UART_IF_TXC_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common UART0 RX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles UART0 RX data valid interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void UART0_RX_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (UART0->IF & UART_IF_RXDATAV)
{
/* invoke callback function */
if (usartCbTable[USART_COUNT * 2 + 1].cbFunc != RT_NULL)
{
(usartCbTable[USART_COUNT * 2 + 1].cbFunc)(usartCbTable[USART_COUNT * 2 + 1].userPtr);
}
}
2013-01-08 22:40:58 +08:00
}
#endif
#if (defined(UART_PRESENT) && (UART_COUNT > 1))
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common UART1 TX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles UART1 TX complete interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void UART1_TX_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
2021-03-27 15:16:57 +08:00
if (UART1->IF & UART_IF_TXC)
{
/* invoke callback function */
if (usartCbTable[USART_COUNT * 2 + 2].cbFunc != RT_NULL)
{
(usartCbTable[USART_COUNT * 2 + 2].cbFunc)(usartCbTable[USART_COUNT * 2 + 2].userPtr);
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
/* clear interrupt */
BITBAND_Peripheral(&(UART1->IFC), _UART_IF_TXC_SHIFT, 0x1UL);
}
2013-01-08 22:40:58 +08:00
/* leave interrupt */
rt_interrupt_leave();
}
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common UART1 RX interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles UART1 RX data valid interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void UART1_RX_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (UART1->IF & UART_IF_RXDATAV)
{
/* invoke callback function */
if (usartCbTable[USART_COUNT * 2 + 3].cbFunc != RT_NULL)
{
(usartCbTable[USART_COUNT * 2 + 3].cbFunc)(usartCbTable[USART_COUNT * 2 + 3].userPtr);
}
}
2013-01-08 22:40:58 +08:00
}
#endif
#if defined(LEUART_PRESENT)
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common LEUART0 interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles LEUART0 interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void LEUART0_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (LEUART0->IF & LEUART_IF_RXDATAV)
{
/* invoke callback function */
if (leuartCbTable[0].cbFunc != RT_NULL)
{
(leuartCbTable[0].cbFunc)(leuartCbTable[0].userPtr);
}
}
2013-01-08 22:40:58 +08:00
}
#endif
#if (defined(LEUART_PRESENT) && (LEUART_COUNT > 1))
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common LEUART1 interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles LEUART1 interrupt request
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void LEUART1_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if (LEUART1->IF & LEUART_IF_RXDATAV)
{
/* invoke callback function */
if (leuartCbTable[1].cbFunc != RT_NULL)
{
(leuartCbTable[1].cbFunc)(leuartCbTable[1].userPtr);
}
}
2013-01-08 22:40:58 +08:00
}
#endif
#if defined(I2C_PRESENT)
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* Common IIC0 interrupt handler
2013-01-08 22:40:58 +08:00
*
* @details
2021-03-27 15:16:57 +08:00
* This function handles IIC0 slave mode interrupt requests
2013-01-08 22:40:58 +08:00
*
* @note
*
******************************************************************************/
void I2C0_IRQHandler(void)
{
2021-03-27 15:16:57 +08:00
if ((I2C0->IF & I2C_IF_ADDR) || \
(I2C0->IF & I2C_IF_RXDATAV) || \
(I2C0->IF & I2C_IF_SSTOP))
{
/* invoke callback function */
if (iicCbTable[0].cbFunc != RT_NULL)
{
(iicCbTable[0].cbFunc)(iicCbTable[0].userPtr);
}
}
I2C_IntClear(I2C0, I2C_IFC_ADDR | I2C_IFC_SSTOP);
2013-01-08 22:40:58 +08:00
}
#endif
/***************************************************************************//**
* @brief
2021-03-27 15:16:57 +08:00
* EFM32 common interrupt handlers register function
2013-01-08 22:40:58 +08:00
*
* @details
*
* @note
*
******************************************************************************/
void efm32_irq_hook_register(efm32_irq_hook_init_t *hook)
{
2021-03-27 15:16:57 +08:00
switch (hook->type)
{
case efm32_irq_type_dma:
dmaCbTable[hook->unit].cbFunc = hook->cbFunc;
dmaCbTable[hook->unit].userPtr = hook->userPtr;
break;
case efm32_irq_type_rtc:
rtcCbTable[hook->unit].cbFunc = hook->cbFunc;
rtcCbTable[hook->unit].userPtr = hook->userPtr;
break;
case efm32_irq_type_timer:
timerCbTable[hook->unit].cbFunc = hook->cbFunc;
timerCbTable[hook->unit].userPtr = hook->userPtr;
break;
case efm32_irq_type_letimer:
letimerCbTable[hook->unit].cbFunc = hook->cbFunc;
letimerCbTable[hook->unit].userPtr = hook->userPtr;
break;
case efm32_irq_type_gpio:
gpioCbTable[hook->unit].cbFunc = hook->cbFunc;
gpioCbTable[hook->unit].userPtr = hook->userPtr;
break;
case efm32_irq_type_acmp:
acmpCbTable[hook->unit].cbFunc = hook->cbFunc;
acmpCbTable[hook->unit].userPtr = hook->userPtr;
break;
2013-01-08 22:40:58 +08:00
#if defined(USART_PRESENT)
2021-03-27 15:16:57 +08:00
case efm32_irq_type_usart:
usartCbTable[hook->unit].cbFunc = hook->cbFunc;
usartCbTable[hook->unit].userPtr = hook->userPtr;
break;
2013-01-08 22:40:58 +08:00
#endif
#if defined(LEUART_PRESENT)
case efm32_irq_type_leuart:
leuartCbTable[hook->unit].cbFunc = hook->cbFunc;
leuartCbTable[hook->unit].userPtr = hook->userPtr;
break;
#endif
#if defined(I2C_PRESENT)
2021-03-27 15:16:57 +08:00
case efm32_irq_type_iic:
iicCbTable[hook->unit].cbFunc = hook->cbFunc;
iicCbTable[hook->unit].userPtr = hook->userPtr;
break;
2013-01-08 22:40:58 +08:00
#endif
2021-03-27 15:16:57 +08:00
default:
break;
}
2013-01-08 22:40:58 +08:00
2021-03-27 15:16:57 +08:00
hdl_debug("Hook Registered: type: %s, unit: %x, cbFunc: %x, userPtr: %x\n", \
hook->type, hook->unit, hook->cbFunc, hook->userPtr);
2013-01-08 22:40:58 +08:00
}
/***************************************************************************//**
* @}
******************************************************************************/