?? gpio.c.bak
字號:
#include <pic.h>
#include "..\inc\include.h"
#include "..\lib\GPIO.h"
volatile uchar KeyValue; //
volatile uchar KeyEvent; //
extern void Delay(uchar t);
void Port_Init(void)
{
#if defined(_16F737) || defined(_16F747) || defined(_16F767) || defined(_16F777)
ADCON1 |= 0x0F; //pins config as digital IO instead of anolog input pins
#endif
//---Port A---
//---Port B---
RBPU = 0; //PORTB Pull-up
TRISB |= 0xF0; //RB4~7 input
TRISB &= 0xF0; //RB0~3 output
TRISB0 = 0; //LED(RB0) output
LED = 0;
//---Port C---
TRISC6 = 0; //RC6/TxD output
//---Port D---
}
void KeyScan(void)
{
Delay(4); //延時消抖
if((!KEY_DEC) || (!KEY_INC) || (!KEY_POWER)){ //按下按鍵
//LED2 = !LED2;
LED = OFF; //按鍵時LED閃爍一下(開始)
KeyValue = (uchar)((!KEY_DEC<<2) | (!KEY_INC<<1) | (!KEY_POWER<<0));
KeyEvent = KEY_PRESSED;
}
else if(KeyValue & 0x07) { //松開按鍵
//LED3 = !LED3;
KeyValue = KeyValue; //按鍵值不變,留待處理
KeyEvent = KEY_RELEASED;
} else { //誤觸發
KeyValue = 0;
KeyEvent = KEY_IDLE;
}
PORTB = PORTB;
RBIF = 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -