added digitalPinToInterrupt()

This commit is contained in:
Graeme Harker 2022-01-22 17:35:20 +00:00
parent 7624cdc240
commit facdf370a1
1 changed files with 7 additions and 7 deletions

View File

@ -28,7 +28,7 @@
// A5 -> Low-rate clock output for indicating LED connection // A5 -> Low-rate clock output for indicating LED connection
#define PS2KEYBOARDCLOCK_PIN 2 #define PS2KEYBOARDCLOCK_PIN 2
#define CPU_READSKEYBOARD_PIN 3 #define KEYBOARD_RD_PIN 3
#define PS2KEYBOARD_DATA_PIN 4 #define PS2KEYBOARD_DATA_PIN 4
#define KEYBOARD_BIT7_PIN 5 #define KEYBOARD_BIT7_PIN 5
@ -56,11 +56,11 @@ void setup()
pinMode(LORATE_CLOCK_PIN, OUTPUT); pinMode(LORATE_CLOCK_PIN, OUTPUT);
pinMode(LORATE_CLOCK_LED_PIN, OUTPUT); pinMode(LORATE_CLOCK_LED_PIN, OUTPUT);
pinMode(CPU_READSKEYBOARD_PIN, INPUT_PULLUP); pinMode(KEYBOARD_RD_PIN, INPUT_PULLUP);
for (int bit = 0; bit < 8; bit++) { for (int bit = 0; bit < 8; bit++) {
pinMode(KeyboardPort[bit], OUTPUT); pinMode(KeyboardPort[bit], OUTPUT);
}; }
pinMode(KEYBOARD_BIT7_PIN, OUTPUT); pinMode(KEYBOARD_BIT7_PIN, OUTPUT);
KeyboardBIT7_Disable(); KeyboardBIT7_Disable();
@ -73,12 +73,12 @@ void setup()
keyboard.begin(PS2KEYBOARD_DATA_PIN, PS2KEYBOARDCLOCK_PIN); keyboard.begin(PS2KEYBOARD_DATA_PIN, PS2KEYBOARDCLOCK_PIN);
keyboard.echo(); keyboard.echo();
#endif #endif
attachInterrupt(1, cpuReadsKeyboard, FALLING); attachInterrupt(digitalPinToInterrupt(KEYBOARD_RD_PIN), cpuReadsKeyboard, FALLING);
#ifdef _WITH_SERIAL_ #ifdef _WITH_SERIAL_
Serial.begin(9600); Serial.begin(9600);
Serial.println("SmartyKit 1 Serial Keyboard is ready..."); Serial.println("SmartyKit 1 Serial Keyboard is ready...");
#endif #endif
} }
void cpuReadsKeyboard(void) void cpuReadsKeyboard(void)
@ -100,7 +100,7 @@ void KeyboardBIT7_Disable()
void sendCharToKeyboardPort(char c) void sendCharToKeyboardPort(char c)
{ {
while(BIT7flag == true) //wait untill the previous char is read by CPU while (BIT7flag == true) //wait untill the previous char is read by CPU
delay(5); delay(5);
for (int bit = 0; bit < 8 ; bit++) for (int bit = 0; bit < 8 ; bit++)
@ -128,7 +128,7 @@ void loop() {
//check PS2 input //check PS2 input
if (keyboard.available()) { if (keyboard.available()) {
uint16_t scan_code = keyboard.read(); uint16_t scan_code = keyboard.read();
char c = scan_code & 0xff; byte c = scan_code & 0xff;
if (c == PS2_KEY_TAB) if (c == PS2_KEY_TAB)
runCommand(); runCommand();