qmk-keychron-q3-colemak-dh/tmk_core/protocol/chibios/usb_main.h
fredizzimo 53ff8a31b6 Merge ChibiOS and LUFA descriptor support (#2362)
* Move lufa descriptor to protocol/usb_descriptor

* Try to compile usb_descriptor on ChibiOS

* Add lufa_utils for ChibiOS

Lufa USB descriptors for ChibiOS

* More lufa_util compatibility fixes

* First compiling version of shared USB descriptor

* Send the usb descriptors

* Fix the CONSOLE output on ChibiOS

* Add errors for unsupported interfaces

* Enable support for vitual serial port USB descriptors

* Implement virtual serial port for ChibiOS

* Cleanup the lufa_utils

Use the default lufa header files

* Add raw hid support for ChibiOS

This is completely untested

* Enable midi compilation on ChibiOS

* Move midi functionality out of lufa.c

* Don't register sysex callback when not needed

* ChibiOS compilation fixes

* Update ChibiOS submodule

* Fix the Midi USB descriptor

It didn't work properly when both Midi and Virtual serial port was enabled.

* Add MIDI support for ChibiOS

* Fix USB descriptor strings on ChibiOS

* Use serial usb driver for raw hid

* Generalize the ChibiOS stream like drivers

This makes the initialization much more simple and eliminates a lot of
the code duplication.

* Convert console output to chibios stream driver

* Fixes for ChibiOS update

* Update the ChibiOS contrib submodule

To include the usb data toggle synchronization fixes

* Fix duplicate reset enumeration on ChibiOS

* Add missing include

* Add number of endpoints check for ChibiOS

* Enable serial USB driver on all keyboards

* Add missing includes when API is enabled withot midi

* Add another missing inlcude
2018-02-08 15:07:46 -05:00

103 lines
2.1 KiB
C

/*
* (c) 2015 flabberast <s3+flabbergast@sdfeu.org>
*
* Based on the following work:
* - Guillaume Duc's raw hid example (MIT License)
* https://github.com/guiduc/usb-hid-chibios-example
* - PJRC Teensy examples (MIT License)
* https://www.pjrc.com/teensy/usb_keyboard.html
* - hasu's TMK keyboard code (GPL v2 and some code Modified BSD)
* https://github.com/tmk/tmk_keyboard/
* - ChibiOS demo code (Apache 2.0 License)
* http://www.chibios.org
*
* Since some GPL'd code is used, this work is licensed under
* GPL v2 or later.
*/
#ifndef _USB_MAIN_H_
#define _USB_MAIN_H_
// TESTING
// extern uint8_t blinkLed;
#include "ch.h"
#include "hal.h"
/* -------------------------
* General USB driver header
* -------------------------
*/
/* The USB driver to use */
#define USB_DRIVER USBD1
/* Initialize the USB driver and bus */
void init_usb_driver(USBDriver *usbp);
/* ---------------
* Keyboard header
* ---------------
*/
/* extern report_keyboard_t keyboard_report_sent; */
/* keyboard IN request callback handler */
void kbd_in_cb(USBDriver *usbp, usbep_t ep);
/* start-of-frame handler */
void kbd_sof_cb(USBDriver *usbp);
#ifdef NKRO_ENABLE
/* nkro IN callback hander */
void nkro_in_cb(USBDriver *usbp, usbep_t ep);
#endif /* NKRO_ENABLE */
/* ------------
* Mouse header
* ------------
*/
#ifdef MOUSE_ENABLE
/* mouse IN request callback handler */
void mouse_in_cb(USBDriver *usbp, usbep_t ep);
#endif /* MOUSE_ENABLE */
/* ---------------
* Extrakey header
* ---------------
*/
#ifdef EXTRAKEY_ENABLE
/* extrakey IN request callback handler */
void extra_in_cb(USBDriver *usbp, usbep_t ep);
/* extra report structure */
typedef struct {
uint8_t report_id;
uint16_t usage;
} __attribute__ ((packed)) report_extra_t;
#endif /* EXTRAKEY_ENABLE */
/* --------------
* Console header
* --------------
*/
#ifdef CONSOLE_ENABLE
/* Putchar over the USB console */
int8_t sendchar(uint8_t c);
/* Flush output (send everything immediately) */
void console_flush_output(void);
#endif /* CONSOLE_ENABLE */
void sendchar_pf(void *p, char c);
#endif /* _USB_MAIN_H_ */