From bed7ed38c2f0ccb4180d882eba7dab7d69f8dd6e Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 2 Aug 2024 13:37:26 +0100 Subject: [PATCH] support multiple PS/2 keyboard drivers --- hw/esp8bit.h | 2 +- hw/node32s-example.h | 2 +- hw/stellarpad-example.h | 2 +- hw/ttgo-t7-v14-mini32.h | 2 +- ps2drv.cpp | 8 ++++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/esp8bit.h b/hw/esp8bit.h index fb08602..6a3719b 100644 --- a/hw/esp8bit.h +++ b/hw/esp8bit.h @@ -19,9 +19,9 @@ // PS/2 keyboard #if !defined(USE_OWN_KBD) #define USE_PS2_KBD +#endif #define PS2_KBD_IRQ D3 #define PS2_KBD_DATA D4 -#endif // SPI-RAM #if !defined(NO_SPIRAM) diff --git a/hw/node32s-example.h b/hw/node32s-example.h index 992d954..dd22dc5 100644 --- a/hw/node32s-example.h +++ b/hw/node32s-example.h @@ -26,9 +26,9 @@ // PS/2 keyboard #if !defined(USE_OWN_KBD) #define USE_PS2_KBD +#endif #define PS2_KBD_DATA 34 #define PS2_KBD_IRQ 35 -#endif // Storage #if !defined(NO_STORAGE) diff --git a/hw/stellarpad-example.h b/hw/stellarpad-example.h index 331322f..f95d4eb 100644 --- a/hw/stellarpad-example.h +++ b/hw/stellarpad-example.h @@ -5,9 +5,9 @@ // PS/2 keyboard #if !defined(USE_OWN_KBD) #define USE_PS2_KBD +#endif #define PS2_KBD_DATA PE_4 #define PS2_KBD_IRQ PE_5 -#endif // Storage #if !defined(NO_STORAGE) diff --git a/hw/ttgo-t7-v14-mini32.h b/hw/ttgo-t7-v14-mini32.h index 9256f0d..a495c85 100644 --- a/hw/ttgo-t7-v14-mini32.h +++ b/hw/ttgo-t7-v14-mini32.h @@ -11,9 +11,9 @@ // PS/2 Keyboard #if !defined(USE_OWN_KBD) #define USE_PS2_KBD +#endif #define PS2_KBD_DATA 32 #define PS2_KBD_IRQ 33 -#endif // 64kB RAM #define RAM_SIZE 0x10000u diff --git a/ps2drv.cpp b/ps2drv.cpp index 8539615..e18dca9 100644 --- a/ps2drv.cpp +++ b/ps2drv.cpp @@ -1,4 +1,7 @@ #include +#include "hardware.h" + +#if defined(USE_PS2_KBD) #include "ps2drv.h" #if !defined(KBD_BUFFER) @@ -13,7 +16,7 @@ static uint8_t DataPin; #if defined(ESP32) || defined(ESP8266) IRAM_ATTR #endif -void ps2interrupt(void) +void ps2interrupt_handler(void) { static uint8_t bitcount=0; static uint8_t incoming=0; @@ -86,6 +89,7 @@ void PS2Driver::begin(uint8_t data_pin, uint8_t irq_pin) DataPin = data_pin; pinMode(irq_pin, INPUT_PULLUP); pinMode(data_pin, INPUT_PULLUP); - attachInterrupt(irq_pin, ps2interrupt, FALLING); + attachInterrupt(irq_pin, ps2interrupt_handler, FALLING); head = tail = 0; } +#endif