You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

main.c 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * (c) 2015 flabberast <[email protected]>
  3. *
  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
  13. *
  14. * Since some GPL'd code is used, this work is licensed under
  15. * GPL v2 or later.
  16. */
  17. #include "ch.h"
  18. #include "hal.h"
  19. #include "usb_main.h"
  20. /* TMK includes */
  21. #include "report.h"
  22. #include "host.h"
  23. #include "host_driver.h"
  24. #include "keyboard.h"
  25. #include "action.h"
  26. #include "led.h"
  27. #include "sendchar.h"
  28. #include "debug.h"
  29. #ifdef SLEEP_LED_ENABLE
  30. #include "sleep_led.h"
  31. #endif
  32. #include "suspend.h"
  33. /* -------------------------
  34. * TMK host driver defs
  35. * -------------------------
  36. */
  37. host_driver_t chibios_driver = {
  38. keyboard_leds,
  39. send_keyboard,
  40. send_mouse,
  41. send_system,
  42. send_consumer
  43. };
  44. /* Main thread
  45. */
  46. int main(void) {
  47. /* ChibiOS/RT init */
  48. halInit();
  49. chSysInit();
  50. palSetPad(GPIOC, GPIOC_LED_BLUE);
  51. chThdSleepMilliseconds(400);
  52. palClearPad(GPIOC, GPIOC_LED_BLUE);
  53. /* Init USB */
  54. init_usb_driver(&USB_DRIVER);
  55. /* init printf */
  56. init_printf(NULL,sendchar_pf);
  57. /* Wait until the USB is active */
  58. while(USB_DRIVER.state != USB_ACTIVE)
  59. chThdSleepMilliseconds(50);
  60. print("USB configured.\n");
  61. /* init TMK modules */
  62. keyboard_init();
  63. host_set_driver(&chibios_driver);
  64. #ifdef SLEEP_LED_ENABLE
  65. sleep_led_init();
  66. #endif
  67. print("Keyboard start.\n");
  68. /* Main loop */
  69. while(true) {
  70. /* TODO: check for suspended event */
  71. keyboard_task();
  72. chThdSleepMilliseconds(5);
  73. }
  74. }