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

📄 intc270.c

📁 dm270 source code
💻 C
📖 第 1 页 / 共 2 页
字号:
            break;
        case 10:
            INTC_FSET(INTPRI05, PRI10, intID);
            break;
        case 11:
            INTC_FSET(INTPRI05, PRI11, intID);
            break;
        case 12:
            INTC_FSET(INTPRI06, PRI12, intID);
            break;
        case 13:
            INTC_FSET(INTPRI06, PRI13, intID);
            break;
        case 14:
            INTC_FSET(INTPRI07, PRI14, intID);
            break;
        case 15:
            INTC_FSET(INTPRI07, PRI15, intID);
            break;
        case 16:
            INTC_FSET(INTPRI08, PRI16, intID);
            break;
        case 17:
            INTC_FSET(INTPRI08, PRI17, intID);
            break;
        case 18:
            INTC_FSET(INTPRI09, PRI18, intID);
            break;
        case 19:
            INTC_FSET(INTPRI09, PRI19, intID);
            break;
        case 20:
            INTC_FSET(INTPRI10, PRI20, intID);
            break;
        case 21:
            INTC_FSET(INTPRI10, PRI21, intID);
            break;
        case 22:
            INTC_FSET(INTPRI11, PRI22, intID);
            break;
        case 23:
            INTC_FSET(INTPRI11, PRI23, intID);
            break;
        case 24:
            INTC_FSET(INTPRI12, PRI24, intID);
            break;
        case 25:
            INTC_FSET(INTPRI12, PRI25, intID);
            break;
        case 26:
            INTC_FSET(INTPRI13, PRI26, intID);
            break;
        case 27:
            INTC_FSET(INTPRI13, PRI27, intID);
            break;
        case 28:
            INTC_FSET(INTPRI14, PRI28, intID);
            break;
        case 29:
            INTC_FSET(INTPRI14, PRI29, intID);
            break;
        case 30:
            INTC_FSET(INTPRI15, PRI30, intID);
            break;
        case 31:
            INTC_FSET(INTPRI15, PRI31, intID);
            break;
        case 32:
            INTC_FSET(INTPRI16, PRI32, intID);
            break;
        case 33:
            INTC_FSET(INTPRI16, PRI33, intID);
            break;
        case 34:
            INTC_FSET(INTPRI17, PRI34, intID);
            break;
        case 35:
            INTC_FSET(INTPRI17, PRI35, intID);
            break;
        case 36:
            INTC_FSET(INTPRI18, PRI36, intID);
            break;
        case 37:
            INTC_FSET(INTPRI18, PRI37, intID);
            break;
        case 38:
            INTC_FSET(INTPRI19, PRI38, intID);
            break;
        case 39:
            INTC_FSET(INTPRI19, PRI39, intID);
            break;
    }
    return E_PASS;
}


/**
    \brief  Wait for interrupt to occur

    This routine waits until interrupt 'intID' occurs and returns when the interrupt 'intID' occurs

    \param intID        interrupt ID
    \param timeout      Time-out value

    \warning parameter \c 'timeout' is not used. Please pass \c zero always

    \return if success, \c E_PASS, else error code
*/
STATUS INTC_waitForInt( INT_ID intID, Uint16 timeout ) {
    return INTC_pollForInt( intID, timeout);
}

/**
    \brief  Poll for occurance of interrupt

    This routine waits until interrupt 'intID' occurs and returns when the interrupt 'intID' occurs

    \param intID        interrupt ID
    \param timeout      Time-out value

    \warning parameter \c 'timeout' is not used. Please pass \c zero always

    \return if success, \c E_PASS, else error code
*/
STATUS INTC_pollForInt( INT_ID intID, Uint16 timeout) {
    STATUS status=E_PASS;

    if(intID >= INT_MAX)
        return E_INVALID_INPUT;

    if( INTC_isIntIRQ(intID)==TRUE) {
        // IRQ interrupt

        if(timeout!=0) {
            while( INTC_getIntIRQStatus(intID) && timeout )
                timeout--;
			INTC_clearIRQ(intID);
            if(timeout==0)
                status=E_TIMEOUT;

        } else {
            // no timeout, wait till interrupt  occurs
            while( INTC_getIntIRQStatus(intID) )
                ;
			INTC_clearIRQ(intID);
        }
    } else {
        // FIQ interrupt

        if(timeout!=0) {
            while( INTC_getIntFIQStatus(intID) && timeout )
                timeout--;
			INTC_clearFIQ(intID);
            if(timeout==0)
                status=E_TIMEOUT;

        } else {
            // no timeout, wait till interrupt  occurs

            while( INTC_getIntFIQStatus(intID) )
                ;
			INTC_clearFIQ(intID);
        }
    }
    return status;
}


/**
    \brief Check if interrupt is enabled

    \param intID interrupt ID

    \return TRUE: interrupt is enabled, FALSE:interrupt is not enable
*/
BOOL INTC_isEnabled( INT_ID intID ) {
    Uint16 eint;

    if( intID >= INT_MAX )
        return FALSE;

    if(intID >=32 ) {
        if( INTC_RGET(EINT2) & (1 << ( (Uint16)intID - 32) ) )
            eint=1;
        else
            eint=0;
    } else
    if(intID >=16 ) {
        if( INTC_RGET(EINT1) & (1 << ( (Uint16)intID - 16) ) )
            eint=1;
        else
            eint=0;
    } else {
        if( INTC_RGET(EINT0) & (1 << ( (Uint16)intID ) ) )
            eint=1;
        else
            eint=0;
    }

    return eint==1 ? TRUE : FALSE;


}

/**
    \brief  Get highest priority pending IRQ interrupt address

    \return 32-bit absolute address
*/
Uint32 INTC_getIRQPendIntAddress() {
    return ( (Uint32)INTC_RGET(IRQENTRY1)  << 16 ) | INTC_RGET(IRQENTRY0) ;
}

/**
    \brief  Get highest priority pending FIQ interrupt address

    \return 32-bit absolute address
*/
Uint32 INTC_getFIQPendIntAddress() {
    return ( (Uint32)INTC_RGET(FIQENTRY1)  << 16 ) | INTC_RGET(FIQENTRY0) ;
}

/**
    \brief  Get the number of pending IRQ interrupts

    \return number of pending IRQ interrupts
*/
Uint16 INTC_getIRQPendNum() {
    Uint16 pend, i, value;

    pend=0;

    value=INTC_RGET(IRQ0);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 )
            pend++;
    }

    value=INTC_RGET(IRQ1);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 )
            pend++;
    }

    value=INTC_RGET(IRQ2);
    for(i=0; i<8; i++) {
        if( ( value & (1<<i) ) == 0 )
            pend++;
    }
    return pend;
}

/**
    \brief  Get the number of pending FIQ interrupts

    \return number of pending FIQ interrupts
*/
Uint16 INTC_getFIQPendNum() {
    Uint16 pend, i, value;

    pend=0;

    value=INTC_RGET(FIQ0);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 )
            pend++;
    }

    value=INTC_RGET(FIQ1);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 )
            pend++;
    }

    value=INTC_RGET(FIQ2);
    for(i=0; i<8; i++) {
        if( ( value & (1<<i) ) == 0 )
            pend++;
    }
    return pend;

}

/**
    \brief  Get the number of IRQ interrupts which are enabled and are pending

    \return number of pending and enabled IRQ interrupts
*/
Uint16 INTC_getIRQPendNumEnabled() {
    Uint16 pend, i, value, evalue;

    pend=0;

    value=INTC_RGET(IRQ0);
    evalue=INTC_RGET(EINT0);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 && ( evalue & (1<<i) ) )
            pend++;
    }

    value=INTC_RGET(IRQ1);
    evalue=INTC_RGET(EINT1);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 && ( evalue & (1<<i) ) )
            pend++;
    }

    value=INTC_RGET(IRQ2);
    evalue=INTC_RGET(EINT2);
    for(i=0; i<8; i++) {
        if( ( value & (1<<i) ) == 0 && ( evalue & (1<<i) ) )
            pend++;
    }
    return pend;

}

/**
    \brief  Get the number of FIQ interrupts which are enabled and are pending

    \return number of pending and enabled FIQ interrupts
*/
Uint16 INTC_getFIQPendNumEnabled() {
    Uint16 pend, i, value, evalue;

    pend=0;

    value=INTC_RGET(FIQ0);
    evalue=INTC_RGET(EINT0);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 && ( evalue & (1<<i) ) )
            pend++;
    }

    value=INTC_RGET(FIQ1);
    evalue=INTC_RGET(EINT1);
    for(i=0; i<16; i++) {
        if( ( value & (1<<i) ) == 0 && ( evalue & (1<<i) ) )
            pend++;
    }

    value=INTC_RGET(FIQ2);
    evalue=INTC_RGET(EINT2);
    for(i=0; i<8; i++) {
        if( ( value & (1<<i) ) == 0 && ( evalue & (1<<i) ) )
            pend++;
    }
    return pend;
}

⌨️ 快捷键说明

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