void main(void) { Init_TMR1(); // 初始化設定Timer1函式 INTCONbits.PEIE = 1; // 開啟周邊中斷功能 INTCONbits.GIE = 1; // 開啟全域中斷控制 TRISD = 0; PORTD = 0; TRISA |= 0x10; while (1) { ButtonProcess(); switch (SystemStep) { case 0: LED_55_AA_Change(); if (ButtonA4Event == 1) { ButtonA4Event = 0; SystemStep++; } break; case 1: PORTD = 0; if (ButtonA4Event == 1) { ButtonA4Event = 0; SystemStep++; PORTD = 1 ; } break; case 2: if (ButtonA4Event == 1) { ButtonA4Event = 0; PORTD++; } break; } }; }
/********************************************************************************************** * Process all the pushbutton in one call. ***********************************************************************************************/ void ButtonProcessAll( void){ ButtonProcess( &Btn0, !PB_STATE); //1 = active btn push ; 0 = idle }