Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
TivaUsbKeyboardDev.hxx
Go to the documentation of this file.
1
34#ifndef _FREERTOS_DRIVERS_TI_TIVAUSBKEYBOARDDEV_HXX_
35#define _FREERTOS_DRIVERS_TI_TIVAUSBKEYBOARDDEV_HXX_
36
37#ifndef gcc
38#define gcc
39#endif
40
41#include <stdint.h>
42
43#include "driverlib/interrupt.h"
44#include "driverlib/rom.h"
45#include "driverlib/rom_map.h"
46#include "usblib/usblib.h"
47#include "usblib/usbhid.h"
48#include "usblib/device/usbdevice.h"
49#include "usblib/device/usbdhid.h"
50#include "usblib/device/usbdhidkeyb.h"
51#include "usblib/usb-ids.h"
52
54#include "utils/Singleton.hxx"
55
60class TivaUsbKeyboardDev : public Serial, public Singleton<TivaUsbKeyboardDev>
61{
62public:
63 TivaUsbKeyboardDev(const char *name, uint32_t interrupt);
64
65 void tx_char() override;
66
67 void enable() override {}
68 void disable() override {}
69
71 uint32_t keyboard_handler(
72 uint32_t ui32Event, uint32_t ui32MsgData, void *pvMsgData);
73
74private:
78 bool send_next_event();
80 unsigned errorCount_{0};
82 tUSBDHIDKeyboardDevice tivaKeyboardDevice_;
83
85 uint8_t isConnected_ : 1;
88 uint8_t isSuspended_ : 1;
90 uint8_t txPending_ : 1;
92 uint8_t keyUpPending_ : 1;
93};
94
95#endif // _FREERTOS_DRIVERS_TI_TIVAUSBKEYBOARDDEV_HXX_
const char * name
device name
Definition Devtab.hxx:266
Private data for a serial device.
Definition Serial.hxx:46
Singleton class.
Definition Singleton.hxx:65
This device driver appears as a virtual serial port to the OpenMRN application, and appears as an USB...
void enable() override
This will be called once when reference-count goes from 0 to positive.
tUSBDHIDKeyboardDevice tivaKeyboardDevice_
Keyboard driver structure.
void disable() override
This will be called when reference count goes from non-zero to 0.
uint8_t isConnected_
Whether the USB host has connected to this device.
uint8_t isSuspended_
Whether the USB bus is suspended.
void tx_char() override
Function to try and transmit a character.
bool send_next_event()
Internal implementation that sends a single keyboard event, from a critical section or in an interrup...
unsigned errorCount_
Number of transmission errors. These occur in the USB device stack.
uint8_t txPending_
Whether we have a pending unfinished send.
uint8_t keyUpPending_
Whether we need to send a key up command still.
uint32_t keyboard_handler(uint32_t ui32Event, uint32_t ui32MsgData, void *pvMsgData)
Callback from the keyboard driver. Called in an interrupt context.