📄 io.c
字号:
/**********************************************************
*
* Button and LED demo
*
**********************************************************/
#include "global_function.h"
#include "IO.h"
extern _EscFlag;
void IO_demo(void)
{
printf("\n\n\r------------------ IO demo ------------------\n\r");
printf(": push the button and watch the LED\n\r");
printf(":\t\tD4\tD5\tD6\tD7\n\r");
printf(":\t\t|\t|\t|\t|\n\r");
printf(":\t\tK2\tK3\tK4\tK5\n\r");
printf("\n\r: Esc to return");
rPCONG = 0xff55; // GPIOG: EINT4,5,6,7 + output 0,1,2,3
rPDATG = 0xff; // clear LED
rPUPG = 0x0; //enalbel internal pull-up
rEXTINT = 0x0; // Low level trigger
rEXTINTPND = 0xf; // clear pending bit
rI_ISPC = 0xffffffff; // clear pending bit
rF_ISPC = 0xffffffff;
pISR_EINT4567 = (int)ExtInt4567_Serv; // locate the Int_serve function
rINTMSK &= (~BIT_EINT4567); // EINT4567 enable
while(!_EscFlag);
rINTMSK |= BIT_EINT4567; // EINT4567 disable
rPDATG = 0xff; // clear LED
}
void __irq ExtInt4567_Serv(void)
{
B32 IntPendStatus;
B32 ExtInt4, ExtInt5, ExtInt6, ExtInt7;
IntPendStatus = rEXTINTPND & 0x0000000f;
ExtInt4 = 0;
ExtInt5 = 0;
ExtInt6 = 0;
ExtInt7 = 0;
switch (IntPendStatus)
{
case 0x1: ExtInt4 = 1; break;
case 0x2: ExtInt5 = 1; break;
case 0x4: ExtInt6 = 1; break;
case 0x8: ExtInt7 = 1; break;
}
if(ExtInt4)
rPDATG = rPDATG ^ 0x1;
if(ExtInt5)
rPDATG = rPDATG ^ 0x2;
if(ExtInt6)
rPDATG = rPDATG ^ 0x4;
if(ExtInt7)
rPDATG = rPDATG ^ 0x8;
Delay(200);
rEXTINTPND = 0xf; // clear pending bit
rI_ISPC = BIT_EINT4567; // clear pending bit
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -