FabGL
ESP32 VGA Controller and Graphics Library
ps2controller.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6  This file is part of FabGL Library.
7 
8  FabGL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  FabGL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #pragma once
24 
25 
26 
34 #include "freertos/FreeRTOS.h"
35 #include "freertos/task.h"
36 
37 #include "fabglconf.h"
38 
39 
40 namespace fabgl {
41 
42 
43 
51 
52 public:
53 
64  void begin(gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO = GPIO_NUM_39, gpio_num_t port1_datGPIO = GPIO_NUM_39);
65 
73  int dataAvailable(int PS2Port);
74 
75  bool waitData(int timeOutMS, int PS2Port);
76 
84  int getData(int PS2Port);
85 
92  void sendData(uint8_t data, int PS2Port);
93 
102  void injectInRXBuffer(int value, int PS2Port);
103 
104 private:
105 
106  void warmInit();
107 
108  static void IRAM_ATTR rtc_isr(void * arg);
109 
110  // address of next word to read in the circular buffer
111  int m_readPos[2];
112 
113  // task that is waiting for TX ends
114  volatile TaskHandle_t m_TXWaitTask[2];
115 
116  // task that is waiting for RX event
117  volatile TaskHandle_t m_RXWaitTask[2];
118 
119 };
120 
121 
122 
123 
124 
125 } // end of namespace
126 
127 
128 
129 extern fabgl::PS2ControllerClass PS2Controller;
130 
131 
void sendData(uint8_t data, int PS2Port)
Sends a command to the device.
Definition: ps2controller.cpp:950
Definition: canvas.cpp:47
The PS2 device controller class.
Definition: ps2controller.h:50
void injectInRXBuffer(int value, int PS2Port)
Injects a byte into the RX buffer.
Definition: ps2controller.cpp:928
This file contains FabGL library configuration settings, like number of supported colors...
void begin(gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO=GPIO_NUM_39, gpio_num_t port1_datGPIO=GPIO_NUM_39)
Initializes PS2 device controller.
Definition: ps2controller.cpp:825
int getData(int PS2Port)
Gets a scancode from the queue.
Definition: ps2controller.cpp:877
int dataAvailable(int PS2Port)
Gets the number of scancodes available in the controller buffer.
Definition: ps2controller.cpp:862