- /*
- *********************************************************************************************************
- * MICIRUM BOARD SUPPORT PACKAGE
- *
- * (c) Copyright 2007-2008; Micrium, Inc.; Weston, FL
- *
- * All rights reserved. Protected by international copyright laws.
- * Knowledge of the source code may not be used to write a similar
- * product. This file may only be used in accordance with a license
- * and should not be redistributed in any way.
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- *
- * BOARD SUPPORT PACKAGE
- *
- * ST Microelectronics STM32
- * with the
- * STM3210B-EVAL Evaluation Board
- *
- * Filename : bsp_int.c
- * Version : V1.00
- * Programmer(s) : BAN
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- * INCLUDE FILES
- *********************************************************************************************************
- */
- #define BSP_INT_MODULE
- #include <bsp.h>
- /*
- *********************************************************************************************************
- * LOCAL DEFINES
- *********************************************************************************************************
- */
- #define BSP_INT_SRC_NBR 42
- /*
- *********************************************************************************************************
- * LOCAL CONSTANTS
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- * LOCAL DATA TYPES
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- * LOCAL TABLES
- *********************************************************************************************************
- */
- static CPU_FNCT_VOID BSP_IntVectTbl[BSP_INT_SRC_NBR];
- /*
- *********************************************************************************************************
- * LOCAL GLOBAL VARIABLES
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- * LOCAL FUNCTION PROTOTYPES
- *********************************************************************************************************
- */
- static void BSP_IntHandler (CPU_DATA int_id);
- static void BSP_IntHandlerDummy(void);
- /*
- *********************************************************************************************************
- * LOCAL CONFIGURATION ERRORS
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- * BSP_IntClr()
- *
- * Description : Clear interrupt.
- *
- * Argument(s) : int_id Interrupt to clear.
- *
- * Return(s) : none.
- *
- * Caller(s) : Application.
- *
- * Note(s) : (1) An interrupt does not need to be cleared within the interrupt controller.
- *********************************************************************************************************
- */
- void BSP_IntClr (CPU_DATA int_id)
- {
- }
- /*
- *********************************************************************************************************
- * BSP_IntDis()
- *
- * Description : Disable interrupt.
- *
- * Argument(s) : int_id Interrupt to disable.
- *
- * Return(s) : none.
- *
- * Caller(s) : Application.
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- void BSP_IntDis (CPU_DATA int_id)
- {
- if (int_id < BSP_INT_SRC_NBR) {
- CPU_IntSrcDis(int_id + 16);
- }
- }
- /*
- *********************************************************************************************************
- * BSP_IntDisAll()
- *
- * Description : Disable ALL interrupts.
- *
- * Argument(s) : none.
- *
- * Return(s) : none.
- *
- * Caller(s) : Application.
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- void BSP_IntDisAll (void)
- {
- CPU_IntDis();
- }
- /*
- *********************************************************************************************************
- * BSP_IntEn()
- *
- * Description : Enable interrupt.
- *
- * Argument(s) : int_id Interrupt to enable.
- *
- * Return(s) : none.
- *
- * Caller(s) : Application.
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- void BSP_IntEn (CPU_DATA int_id)
- {
- if (int_id < BSP_INT_SRC_NBR) {
- CPU_IntSrcEn(int_id + 16);
- }
- }
- /*
- *********************************************************************************************************
- * BSP_IntVectSet()
- *
- * Description : Assign ISR handler.
- *
- * Argument(s) : int_id Interrupt for which vector will be set.
- *
- * isr Handler to assign
- *
- * Return(s) : none.
- *
- * Caller(s) : Application.
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- void BSP_IntVectSet (CPU_DATA int_id,
- CPU_FNCT_VOID isr)
- {
- #if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
- CPU_SR cpu_sr;
- #endif
- if (int_id < BSP_INT_SRC_NBR) {
- CPU_CRITICAL_ENTER();
- BSP_IntVectTbl[int_id] = isr;
- CPU_CRITICAL_EXIT();
- }
- }
- /*
- *********************************************************************************************************
- * BSP_IntPrioSet()
- *
- * Description : Assign ISR priority.
- *
- * Argument(s) : int_id Interrupt for which vector will be set.
- *
- * prio Priority to assign
- *
- * Return(s) : none.
- *
- * Caller(s) : Application.
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- void BSP_IntPrioSet (CPU_DATA int_id,
- CPU_INT08U prio)
- {
- #if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
- CPU_SR cpu_sr;
- #endif
- if (int_id < BSP_INT_SRC_NBR) {
- CPU_CRITICAL_ENTER();
- CPU_IntSrcPrioSet(int_id + 16, prio);
- CPU_CRITICAL_EXIT();
- }
- }
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * INTERNAL FUNCTIONS
- *********************************************************************************************************
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- * BSP_IntInit()
- *
- * Description : Initialize interrupts:
- *
- * Argument(s) : none.
- *
- * Return(s) : none.
- *
- * Caller(s) : BSP_Init().
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- void BSP_IntInit (void)
- {
- CPU_DATA int_id;
- for (int_id = 0; int_id < BSP_INT_SRC_NBR; int_id++) {
- BSP_IntVectSet(int_id, BSP_IntHandlerDummy);
- }
- }
- /*
- *********************************************************************************************************
- * BSP_IntHandler####()
- *
- * Description : Handle an interrupt.
- *
- * Argument(s) : none.
- *
- * Return(s) : none.
- *
- * Caller(s) : This is an ISR.
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- void BSP_IntHandlerWWDG (void) { BSP_IntHandler(BSP_INT_ID_WWDG); }
- void BSP_IntHandlerPVD (void) { BSP_IntHandler(BSP_INT_ID_PVD); }
- void BSP_IntHandlerTAMPER (void) { BSP_IntHandler(BSP_INT_ID_TAMPER); }
- void BSP_IntHandlerRTC (void) { BSP_IntHandler(BSP_INT_ID_RTC); }
- void BSP_IntHandlerFLASH (void) { BSP_IntHandler(BSP_INT_ID_FLASH); }
- void BSP_IntHandlerRCC (void) { BSP_IntHandler(BSP_INT_ID_RCC); }
- void BSP_IntHandlerEXTI0 (void) { BSP_IntHandler(BSP_INT_ID_EXTI0); }
- void BSP_IntHandlerEXTI1 (void) { BSP_IntHandler(BSP_INT_ID_EXTI1); }
- void BSP_IntHandlerEXTI2 (void) { BSP_IntHandler(BSP_INT_ID_EXTI2); }
- void BSP_IntHandlerEXTI3 (void) { BSP_IntHandler(BSP_INT_ID_EXTI3); }
- void BSP_IntHandlerEXTI4 (void) { BSP_IntHandler(BSP_INT_ID_EXTI4); }
- void BSP_IntHandlerDMA1_CH1 (void) { BSP_IntHandler(BSP_INT_ID_DMA1_CH1); }
- void BSP_IntHandlerDMA1_CH2 (void) { BSP_IntHandler(BSP_INT_ID_DMA1_CH2); }
- void BSP_IntHandlerDMA1_CH3 (void) { BSP_IntHandler(BSP_INT_ID_DMA1_CH3); }
- void BSP_IntHandlerDMA1_CH4 (void) { BSP_IntHandler(BSP_INT_ID_DMA1_CH4); }
- void BSP_IntHandlerDMA1_CH5 (void) { BSP_IntHandler(BSP_INT_ID_DMA1_CH5); }
- void BSP_IntHandlerDMA1_CH6 (void) { BSP_IntHandler(BSP_INT_ID_DMA1_CH6); }
- void BSP_IntHandlerDMA1_CH7 (void) { BSP_IntHandler(BSP_INT_ID_DMA1_CH7); }
- void BSP_IntHandlerADC1_2 (void) { BSP_IntHandler(BSP_INT_ID_ADC1_2); }
- void BSP_IntHandlerUSB_HP_CAN_TX (void) { BSP_IntHandler(BSP_INT_ID_USB_HP_CAN_TX); }
- void BSP_IntHandlerUSB_LP_CAN_RX0(void) { BSP_IntHandler(BSP_INT_ID_USB_LP_CAN_RX0); }
- void BSP_IntHandlerCAN_RX1 (void) { BSP_IntHandler(BSP_INT_ID_CAN_RX1); }
- void BSP_IntHandlerCAN_SCE (void) { BSP_IntHandler(BSP_INT_ID_CAN_SCE); }
- void BSP_IntHandlerEXTI9_5 (void) { BSP_IntHandler(BSP_INT_ID_EXTI9_5); }
- void BSP_IntHandlerTIM1_BRK (void) { BSP_IntHandler(BSP_INT_ID_TIM1_BRK); }
- void BSP_IntHandlerTIM1_UP (void) { BSP_IntHandler(BSP_INT_ID_TIM1_UP); }
- void BSP_IntHandlerTIM1_TRG_COM (void) { BSP_IntHandler(BSP_INT_ID_TIM1_TRG_COM); }
- void BSP_IntHandlerTIM1_CC (void) { BSP_IntHandler(BSP_INT_ID_TIM1_CC); }
- void BSP_IntHandlerTIM2 (void) { BSP_IntHandler(BSP_INT_ID_TIM2); }
- void BSP_IntHandlerTIM3 (void) { BSP_IntHandler(BSP_INT_ID_TIM3); }
- void BSP_IntHandlerTIM4 (void) { BSP_IntHandler(BSP_INT_ID_TIM4); }
- void BSP_IntHandlerI2C1_EV (void) { BSP_IntHandler(BSP_INT_ID_I2C1_EV); }
- void BSP_IntHandlerI2C1_ER (void) { BSP_IntHandler(BSP_INT_ID_I2C1_ER); }
- void BSP_IntHandlerI2C2_EV (void) { BSP_IntHandler(BSP_INT_ID_I2C2_EV); }
- void BSP_IntHandlerI2C2_ER (void) { BSP_IntHandler(BSP_INT_ID_I2C2_ER); }
- void BSP_IntHandlerSPI1 (void) { BSP_IntHandler(BSP_INT_ID_SPI1); }
- void BSP_IntHandlerSPI2 (void) { BSP_IntHandler(BSP_INT_ID_SPI2); }
- void BSP_IntHandlerUSART1 (void) { BSP_IntHandler(BSP_INT_ID_USART1); }
- void BSP_IntHandlerUSART2 (void) { BSP_IntHandler(BSP_INT_ID_USART2); }
- void BSP_IntHandlerUSART3 (void) { BSP_IntHandler(BSP_INT_ID_USART3); }
- void BSP_IntHandlerEXTI15_10 (void) { BSP_IntHandler(BSP_INT_ID_EXTI15_10); }
- void BSP_IntHandlerRTCAlarm (void) { BSP_IntHandler(BSP_INT_ID_RTCAlarm); }
- void BSP_IntHandlerUSBWakeUp (void) { BSP_IntHandler(BSP_INT_ID_USBWakeUp); }
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * LOCAL FUNCTIONS
- *********************************************************************************************************
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- * BSP_IntHandler()
- *
- * Description : Central interrupt handler.
- *
- * Argument(s) : int_id Interrupt that will be handled.
- *
- * Return(s) : none.
- *
- * Caller(s) : ISR handlers.
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- static void BSP_IntHandler (CPU_DATA int_id)
- {
- #if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
- //CPU_SR cpu_sr;
- #endif
- CPU_FNCT_VOID isr;
- //CPU_CRITICAL_ENTER(); /* Tell uC/OS-II that we are starting an ISR */
- //OSIntNesting++;
- //CPU_CRITICAL_EXIT();
- if (int_id < BSP_INT_SRC_NBR) {
- isr = BSP_IntVectTbl[int_id];
- if (isr != (CPU_FNCT_VOID)0) {
- isr();
- }
- }
- //OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
- }
- /*
- *********************************************************************************************************
- * BSP_IntHandlerDummy()
- *
- * Description : Dummy interrupt handler.
- *
- * Argument(s) : none.
- *
- * Return(s) : none.
- *
- * Caller(s) : BSP_IntHandler().
- *
- * Note(s) : none.
- *********************************************************************************************************
- */
- static void BSP_IntHandlerDummy (void)
- {
- }