configint0.c

来自「Mplab C30编译器」· C语言 代码 · 共 54 行

C
54
字号
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include <ports.h>

/****************************************************************************
Function Prototype : void ConfigINT0(unsigned int config)
 
Include            : ports.h
 
Description        : This function configures the external interrupt 
 
Arguments          : config - Interrupt edge, priority and enable/disable 
                     information as defined below:
					 Interrupt edge selection					
					   RISING_EDGE_INT					
					   FALLING_EDGE_INT					
					 Interrupt enable					
					   EXT_INT_ENABLE					
					   EXT_INT_DISABLE					
					 Interrupt priority					
					   EXT_INT_PRI_0					
					   EXT_INT_PRI_1					
					   EXT_INT_PRI_2					
					   EXT_INT_PRI_3					
					   EXT_INT_PRI_4					
					   EXT_INT_PRI_5					
					   EXT_INT_PRI_6					
					   EXT_INT_PRI_7
 
Return Value       : None
 
Remarks            : This function clears the interrupt flag corresponding 
                     to the INTx pin and then selects the edge detect polarity.
                     It then sets the interrupt priority and enables/disables
                     the interrupt.
********************************************************************************/
#ifdef _INT0

void ConfigINT0(unsigned int config)
{
    IFS0bits.INT0IF = 0;                       /* clear the interrupt flag */
    IPC0bits.INT0IP = config & 0x07;           /* assign interrupt priority */

    INTCON2bits.INT0EP = (config & 0x10) >> 4; /* assign edge selected */

    IEC0bits.INT0IE = (config & 0x08) >> 3;    /* enable/disable interrupt */
}
/* end of function ConfigINT0 */

#else
#warning "Does not build on this target"
#endif

⌨️ 快捷键说明

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