⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsp_exception.c

📁 基于 ST 公司的 ARM-7 使用之 uC/OS-II 作业系统,此例程是移植于 STR-750 上的应用,有支援 OS_View 观察器功能,于 IAR EWARM V4.41A 工程编译,而 u
💻 C
字号:
/*
*********************************************************************************************************
*
*                                     MICIRUM BOARD SUPPORT PACKAGE
*
*                          (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
*               All rights reserved.  Protected by international copyright laws.
*
*               Knowledge of the source code may NOT be used to develop a similar product.
*
*               Please help us continue to provide the Embedded community with the finest
*               software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*                                BOARD SUPPORT PACKAGE (BSP) FUNCTIONS
*
*                                         EXCEPTION MANAGEMENT
*
*                                      ST Microelectronics STR750
*                                    on the IAR STR750-SK EvalBoard
*
* Filename      : bsp_exception.c
* Version       : V1.00
* Programmer(s) : Brian Nagel
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                             INCLUDE FILES
*********************************************************************************************************
*/

#include  <includes.h>
#include  <os_cpu.h>

/*
*********************************************************************************************************
*                                               DATA TYPES
*********************************************************************************************************
*/

typedef  void  (*BSP_FNCT_PTR)(void);


/*
*********************************************************************************************************
*                                           LOCAL VARIABLES
*********************************************************************************************************
*/

static  BSP_FNCT_PTR   BSP_ISR_Table[BSP_NBR_INT];


/*
*********************************************************************************************************
*                                          EXCEPTION HANDLER
*
* Arguments   : None.
*********************************************************************************************************
*/

void  OS_CPU_ExceptHndlr (CPU_DATA  except_id)
{
    BSP_FNCT_PTR    pfnct;
    CPU_INT08U      idx;


    if (except_id == OS_CPU_ARM_EXCEPT_IRQ) {
        idx   = (CPU_INT16U)((EIC->IVR) & 0x0000FFFF);          /* Get the index corresponding to the device's handler      */
        pfnct = BSP_ISR_Table[idx];                             /* Read the interrupt vector from the table                 */
        if (pfnct != (BSP_FNCT_PTR)0) {                         /* Make sure we don't have a NULL pointer                   */
            (*pfnct)();                                         /* Execute the ISR for the interrupting device              */
        } else {
            EIC->IPR = (CPU_INT32U)(1 << idx);
        }
    }
}


/*
*********************************************************************************************************
*                                       SET INTERRUPT VECTOR
*
* Description : This function sets the Interrut Vector Register for the device to the device's
*               interrupt channel number.  This number is then used as an index into a table of interrupt
*               handlers.
*
* Arguments   : device    corresponds to the device's interrupt channel number
*               handler   the function to be used as the device's interrupt handler
*
* Returns     : 0 if the handler was added to the table, 1 otherwise
*********************************************************************************************************
*/

CPU_INT08U  BSP_VectSet (CPU_INT16U device, BSP_FNCT_PTR handler)
{
#if OS_CRITICAL_METHOD == 3                                     /* Allocate storage for CPU status register                 */
    OS_CPU_SR  cpu_sr = 0;
#endif

    if (device < BSP_NBR_INT) {                                 /* Make sure there is a space for the device in the table   */

        OS_ENTER_CRITICAL();
        BSP_ISR_Table[device] = handler;                        /* Add the device's handler to the table                    */
        OS_EXIT_CRITICAL();

        return (DEF_TRUE);
    } else {
        return (DEF_FALSE);
    }
}


/*
*********************************************************************************************************
*                                INITIALIZE THE INTERRUPT VECTOR TABLE
*
* Description : This function initializes the interrupt vector table and the EIC_SIR registers
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/

void  BSP_IntInit(void)
{
    CPU_INT32U  i;

    for (i = 0; i < BSP_NBR_INT; i++) {
        EIC_SIR(i) |= EIC_SIR_SIV(i);
    }

    for (i = 0; i < BSP_NBR_INT; i++) {
        BSP_ISR_Table[i] = 0;
    }
}


/*
*********************************************************************************************************
*                                      DISABLE ALL INTERRUPTS
*
* Description : This function disables all interrupts from the interrupt controller.
*
* Arguments   : none
*********************************************************************************************************
*/

void  BSP_IntDisAll (void)
{
    EIC->ICR &= ~EIC_ICR_IRQ_EN;                                 /* Disable interrupts                                       */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -