38#include "freertos/FreeRTOS.h"
39#include "freertos/task.h"
40#include "freertos/timers.h"
106 static void begin(gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO = GPIO_UNUSED, gpio_num_t port1_datGPIO = GPIO_UNUSED);
127 static bool initialized() {
return s_initDone; }
146 static int getData(
int PS2Port,
int timeOutMS);
181 static void setKeyboard(
Keyboard * value) { s_keyboard = value; }
190 static void setMouse(
Mouse * value) { s_mouse = value; }
199 static bool parityError(
int PS2Port) {
return s_parityError[PS2Port]; }
201 static bool syncError(
int PS2Port) {
return s_syncError[PS2Port]; }
203 static bool CLKTimeOutError(
int PS2Port) {
return s_CLKTimeOutError[PS2Port]; }
213 static bool lock(
int PS2Port,
int timeOutMS);
220 static void unlock(
int PS2Port);
226 static void IRAM_ATTR ULPWakeISR(
void * arg);
228 static PS2Controller * s_instance;
232 static Keyboard * s_keyboard;
233 static Mouse * s_mouse;
235 static bool s_keyboardAllocated;
236 static bool s_mouseAllocated;
238 static bool s_portEnabled[2];
240 static intr_handle_t s_ULPWakeISRHandle;
243 static bool s_parityError[2];
244 static bool s_syncError[2];
245 static bool s_CLKTimeOutError[2];
248 static QueueHandle_t s_dataIn[2];
250 static SemaphoreHandle_t s_portLock[2];
252 static bool s_initDone;
257struct PS2PortAutoDisableRX {
258 PS2PortAutoDisableRX(
int PS2Port) : port(PS2Port) {
261 ~PS2PortAutoDisableRX() {
The PS2 Keyboard controller class.
The PS2 Mouse controller class.
static Mouse * mouse()
Returns the instance of Mouse object automatically created by PS2Controller.
static void sendData(uint8_t data, int PS2Port)
Sends a command to the device.
static bool lock(int PS2Port, int timeOutMS)
Gets exclusive access to the specified PS/2 port.
static void disableRX(int PS2Port)
Disables inputs from PS/2 port driving the CLK line Low.
static Keyboard * keyboard()
Returns the instance of Keyboard object automatically created by PS2Controller.
static void unlock(int PS2Port)
Releases port from exclusive access.
static PS2Controller * instance()
Returns the singleton instance of PS2Controller class.
static void begin(gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO=GPIO_UNUSED, gpio_num_t port1_datGPIO=GPIO_UNUSED)
Initializes PS2 device controller.
static int getData(int PS2Port, int timeOutMS)
Gets a scancode from the queue.
static bool dataAvailable(int PS2Port)
Determines if one byte has been received from the specified port.
static void enableRX(int PS2Port)
Enables inputs from PS/2 port releasing CLK line.
The PS2 device controller class.
This file contains FabGL library configuration settings, like number of supported colors,...
This file contains some utility classes and functions.
KbdMode
This enum defines how handle keyboard virtual keys.
PS2Preset
This enum defines what is connected to PS/2 ports.
@ KeyboardPort0_MousePort1
@ KeyboardPort1_MousePort0