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

📄 bsp.c.2006-04-14.12-44-15.4375

📁 uCOSII 在LPC3180上的移植代码
💻 4375
📖 第 1 页 / 共 4 页
字号:
    }
}

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

void  BSP_IntDisAll (void)
{
    MIC_ER  = 0;                                                            /* Disable ALL interrupts                               */
}

/*
*********************************************************************************************************
*                                           IRQ ISR HANDLER
*
* Description : This function is called by OS_CPU_IRQ_ISR() to determine the source of the interrupt
*               and process it accordingly.
*
* Arguments   : none
*
* Notes       : 1) This function first services MIC interrupts, followed by Sub1IRQn interrupts,
*                  and then Sub2IRQn.
*
*               2) This routine works without 'polling' for set bits by means
*                  of calling BSP_Get_HighOrderBit() which relies on checking byte-wise for set bits and
*                  then using a lookup table in order to find the highest order bit set in the 32 bit status
*                  register.
*********************************************************************************************************
*/

void  OS_CPU_IRQ_ISR_Handler (void)
{
    PFNCT   pfnct;
    INT8U   bit;


    while (MIC_SR > 0) {                                                    /* While at least 1 Master interrupt is still pending   */
        bit     =  BSP_Get_HighOrderBit(MIC_SR);                            /* Get the highest order bit that is set                */
        pfnct   = (PFNCT)BSP_IntVectTbl[0][bit];                            /* Retrieve the interrupt handler function pointer      */
        if (pfnct != (PFNCT)0) {                                            /* If the function pointer is not NULL ...              */
            (*pfnct)();                                                     /* Execute the ISR handler                              */
        }
    }

    while (SIC1_SR > 0) {                                                   /* While at least 1 Secondary-1 Int. is still pending   */
        bit     =  BSP_Get_HighOrderBit(SIC1_SR);                           /* Get the highest order bit that is set                */
        pfnct   = (PFNCT)BSP_IntVectTbl[1][bit];                            /* Retrieve the interrupt handler function pointer      */
        if (pfnct != (PFNCT)0) {                                            /* If the function pointer is not NULL ...              */
            (*pfnct)();                                                     /* Execute the ISR handler                              */
        }
    }

    while (SIC2_SR > 0) {                                                   /* While at least 1 Secondary-2 Int. is still pending   */
        bit     =  BSP_Get_HighOrderBit(SIC2_SR);                           /* Get the highest order bit that is set                */
        pfnct   = (PFNCT)BSP_IntVectTbl[2][bit];                            /* Retrieve the interrupt handler function pointer      */
        if (pfnct != (PFNCT)0) {                                            /* If the function pointer is not NULL ...              */
            (*pfnct)();                                                     /* Execute the ISR handler                              */
        }
    }
}


/*
*********************************************************************************************************
*                                           FIQ ISR HANDLER
*
* Description : This function is called by OS_CPU_FIQ_ISR() to determine the source of the interrupt
*               and process it accordingly.
*
* Arguments   : none
*********************************************************************************************************
*/

void  OS_CPU_FIQ_ISR_Handler (void)
{
    PFNCT   pfnct;
    INT32U  MIC_Status;
    INT32U  SIC1_Status;
    INT32U  SIC2_Status;
    INT8U   bit;


    MIC_Status  =  MIC_SR;                                                  /* Read the interrupt status register                   */
    SIC1_Status =  SIC1_SR;                                                 /* Get the status register for SIC1 Interrupts          */
    SIC2_Status =  SIC2_SR;                                                 /* Get the status register for SIC2 Interrupts          */

    while (MIC_Status > 0) {
        bit     =  BSP_Get_HighOrderBit(MIC_Status);                        /* Get the highest order bit that is set                */
        pfnct   = (PFNCT)BSP_IntVectTbl[0][bit];                            /* Retrieve the interrupt handlers function pointer     */
        if (pfnct != (PFNCT)0) {                                            /* If the function pointer is not NULL ...              */
            (*pfnct)();                                                     /* Execute the ISR handler                              */
        }
        MIC_Status &= ~bit;                                                 /* Clear the recently serviced bit, then check again    */
    }

    while (SIC1_Status > 0) {
        bit     =  BSP_Get_HighOrderBit(SIC1_Status);                       /* Get the highest order bit that is set                */
        pfnct   = (PFNCT)BSP_IntVectTbl[1][bit];                            /* Retrieve the interrupt handlers function pointer     */
        if (pfnct != (PFNCT)0) {                                            /* If the function pointer is not NULL ...              */
            (*pfnct)();                                                     /* Execute the ISR handler                              */
        }
        SIC1_Status &= ~bit;                                                /* Clear the recently serviced bit, then check again    */
    }

    while (SIC2_Status > 0) {
        bit     =  BSP_Get_HighOrderBit(SIC2_Status);                       /* Get the highest order bit that is set                */
        pfnct   = (PFNCT)BSP_IntVectTbl[2][bit];                            /* Retrieve the interrupt handlers function pointer     */
        if (pfnct != (PFNCT)0) {                                            /* If the function pointer is not NULL ...              */
            (*pfnct)();                                                     /* Execute the ISR handler                              */
        }
        SIC2_Status &= ~bit;                                                /* Clear the recently serviced bit, then check again    */
    }
}

/*
*********************************************************************************************************
*
*
* Description : This function returns the bit position of the highest order bit that is set
*               in the 32 bit parameter, reg_val.
*
* Arguments   : reg_val, the 32 bit data value to determine the most significant set bit position from.
*
* Returns     : The highest order bit position that is set in reg_val.
*
* Note        : THIS FUNCTION WILL RETURN 0 (bit 0) IF REG_VAL = 0, AND IF REG_VAL = 1.
*               Be sure to call this function only if reg_val is > 0 to obtain the correct result.
*********************************************************************************************************
*/

static  INT8U BSP_Get_HighOrderBit (INT32U  reg_val)
{
    INT8U  bit;


    if (reg_val > 65535) {
        if (reg_val > 0xFFFFFF) {
            bit = BSP_BitIxTbl[reg_val >> 24] + 24;
        } else {
            bit = BSP_BitIxTbl[(reg_val >> 16) & 0xFF] + 16;
        }
    } else {
        if (reg_val > 255) {
            bit = BSP_BitIxTbl[(reg_val >> 8) & 0xFF] + 8;
        } else {
            bit = BSP_BitIxTbl[reg_val & 0xFF];
        }
    }

    return (bit);
}

/*
*********************************************************************************************************
*                                         BSP INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
*               functions found in this module.
*
* Arguments   : none
*********************************************************************************************************
*/

void  LED_Init (void)
{
    PIO_DIR_SET           =  (LED_1 | LED_2);                               /* Configure LED pins for output                        */
    LED_Off(0);                                                             /* Turn OFF all the LEDs                                */
}

/*
*********************************************************************************************************
*                                             LED ON
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments   : led    is the number of the LED to control
*                      0    indicates that you want ALL the LEDs to be ON
*                      1    turns ON LED1  on the board
*                      2    turns ON LED2  on the board
*********************************************************************************************************
*/

void  LED_On (INT8U led)
{
    switch (led) {
        case 0:
             PIO_OUTP_CLR  = LED_1;                                         /* Turn on LED 1                                        */
             PIO_OUTP_CLR  = LED_2;                                         /* Turn on LED 2                                        */
             break;

        case 1:
             PIO_OUTP_CLR  = LED_1;                                         /* Turn on LED 1                                        */
             break;

        case 2:
             PIO_OUTP_CLR  = LED_2;                                         /* Turn on LED 2                                        */
             break;
    }
}

/*
*********************************************************************************************************
*                                             LED OFF
*
* Description : This function is used to control any or all the LEDs on the board.

⌨️ 快捷键说明

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