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

📄 intc.c

📁 dm270 source code
💻 C
字号:
/*
    DM270 ARM Evaluation Software

    (c)Texas Instruments 2003
*/

/**
    \file intc.c
    \brief Interrupt Controller User APIs
*/
#include <system/intc270.h>
#include <system/swi270.h>
#include <user/intc.h>


INTC_ISR isr_tab[INT_MAX];

/**
    \brief  Initialize interrupt controller

    This routine clears and disables all interupts, initializes interrupt table and enables ARM IRQ, ARM FIQ interrupts \n
    This routine \b must be called atleast once during system initialization

    \return if success, \c E_PASS, else error code
*/
STATUS INTCInit() {
    Uint16 i;
    extern Uint32 IRQ_Entry;

    // disable ARM IRQ, FIQ interrupt
    DisableIRQ();
    DisableFIQ();

    // disable all interrupts
    INTC_RSET( EINT0, 0 );
    INTC_RSET( EINT1, 0 );
    INTC_RSET( EINT2, 0 );

    // clear all FIQ, IRQ interrupts
    INTC_RSET( FIQ0, 0xFFFF );
    INTC_RSET( FIQ1, 0xFFFF );
    INTC_RSET( FIQ2, 0xFFFF );

    INTC_RSET( IRQ0, 0xFFFF );
    INTC_RSET( IRQ1, 0xFFFF );
    INTC_RSET( IRQ2, 0xFFFF );

    // set all interrupts as IRQ
    INTC_RSET( FISEL0, 0 );
    INTC_RSET( FISEL1, 0 );
    INTC_RSET( FISEL2, 0 );

    // set interrupt table base address
    INTC_setIntTableAddress( (char*)&IRQ_Entry, 4);

    // clear interrupt address table
    for(i=0; i<INT_MAX; i++)
        isr_tab[i]=NULL;

    // enable ARM IRQ, FIQ interrupt
    EnableIRQ();
    EnableFIQ();


    return E_PASS;
}

/**
    \brief Attach user ISR to interrupt source

    The user ISR is invoked when interrupt 'intID' occurs.  \n
    The user ISR need not clear interupt status.    \n
    This routine does not enable the interrupt. Use INTC_enable() to enable the interrupt \n

    \param intID    interrupt ID
    \param isr      user ISR

    \return if success, \c E_PASS, else error code
*/
STATUS INTCAttachISR( INT_ID intID, INTC_ISR isr) {

    if(isr==NULL || intID >= INT_MAX)
        return E_INVALID_INPUT;

    isr_tab[intID]=isr;
    return E_PASS;
}


/**
    \brief Detach/Remove user ISR from interrupt source

    This routine does not disable the interrupt, it only detaches the user ISR. \n

    \param intID interrupt ID

    \return if success, \c E_PASS, else error code
*/
STATUS INTCDetachISR( INT_ID intID ) {
    if(intID >= INT_MAX)
        return E_INVALID_INPUT;

    isr_tab[intID]=NULL;
    return E_PASS;
}

⌨️ 快捷键说明

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