2 * (c) 2015 flabberast <s3+flabbergast@sdfeu.org>
4 * Based on the following work:
5 * - Guillaume Duc's raw hid example (MIT License)
6 * https://github.com/guiduc/usb-hid-chibios-example
7 * - PJRC Teensy examples (MIT License)
8 * https://www.pjrc.com/teensy/usb_keyboard.html
9 * - hasu's TMK keyboard code (GPL v2 and some code Modified BSD)
10 * https://github.com/tmk/tmk_keyboard/
11 * - ChibiOS demo code (Apache 2.0 License)
12 * http://www.chibios.org
14 * Since some GPL'd code is used, this work is licensed under
26 #include "host_driver.h"
32 #ifdef SLEEP_LED_ENABLE
33 #include "sleep_led.h"
38 /* -------------------------
39 * TMK host driver defs
40 * -------------------------
44 uint8_t keyboard_leds(void);
45 void send_keyboard(report_keyboard_t *report);
46 void send_mouse(report_mouse_t *report);
47 void send_system(uint16_t data);
48 void send_consumer(uint16_t data);
51 host_driver_t chibios_driver = {
61 * Amber LED blinker thread, times are in milliseconds.
63 /* set this variable to non-zero anywhere to blink once */
64 // uint8_t blinkLed = 0;
65 // static THD_WORKING_AREA(waBlinkerThread, 128);
66 // static THD_FUNCTION(blinkerThread, arg) {
68 // chRegSetThreadName("blinkOrange");
72 // palSetPad(GPIOC, GPIOC_LED_ORANGE);
73 // chThdSleepMilliseconds(100);
74 // palClearPad(GPIOC, GPIOC_LED_ORANGE);
76 // chThdSleepMilliseconds(100);
89 palSetPad(GPIOC, GPIOC_LED_BLUE);
90 chThdSleepMilliseconds(400);
91 palClearPad(GPIOC, GPIOC_LED_BLUE);
94 // chThdCreateStatic(waBlinkerThread, sizeof(waBlinkerThread), NORMALPRIO, blinkerThread, NULL);
97 init_usb_driver(&USB_DRIVER);
100 init_printf(NULL,sendchar_pf);
102 /* Wait until the USB is active */
103 while(USB_DRIVER.state != USB_ACTIVE)
104 chThdSleepMilliseconds(50);
106 print("USB configured.\n");
108 /* init TMK modules */
110 host_set_driver(&chibios_driver);
112 #ifdef SLEEP_LED_ENABLE
116 print("Keyboard start.\n");
120 /* TODO: check for suspended event */
123 chThdSleepMilliseconds(5);