aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/lufa/lufa.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/lufa/lufa.c')
-rw-r--r--tmk_core/protocol/lufa/lufa.c106
1 files changed, 100 insertions, 6 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index a1cab98a6..cb918d3dc 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -141,6 +141,10 @@ USB_ClassInfo_CDC_Device_t cdc_device =
141 141
142#ifdef RAW_ENABLE 142#ifdef RAW_ENABLE
143 143
144/** \brief Raw HID Send
145 *
146 * FIXME: Needs doc
147 */
144void raw_hid_send( uint8_t *data, uint8_t length ) 148void raw_hid_send( uint8_t *data, uint8_t length )
145{ 149{
146 // TODO: implement variable size packet 150 // TODO: implement variable size packet
@@ -172,6 +176,10 @@ void raw_hid_send( uint8_t *data, uint8_t length )
172 Endpoint_SelectEndpoint(ep); 176 Endpoint_SelectEndpoint(ep);
173} 177}
174 178
179/** \brief Raw HID Receive
180 *
181 * FIXME: Needs doc
182 */
175__attribute__ ((weak)) 183__attribute__ ((weak))
176void raw_hid_receive( uint8_t *data, uint8_t length ) 184void raw_hid_receive( uint8_t *data, uint8_t length )
177{ 185{
@@ -180,6 +188,10 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
180 // so users can opt to not handle data coming in. 188 // so users can opt to not handle data coming in.
181} 189}
182 190
191/** \brief Raw HID Task
192 *
193 * FIXME: Needs doc
194 */
183static void raw_hid_task(void) 195static void raw_hid_task(void)
184{ 196{
185 // Create a temporary buffer to hold the read in data from the host 197 // Create a temporary buffer to hold the read in data from the host
@@ -218,6 +230,10 @@ static void raw_hid_task(void)
218 * Console 230 * Console
219 ******************************************************************************/ 231 ******************************************************************************/
220#ifdef CONSOLE_ENABLE 232#ifdef CONSOLE_ENABLE
233/** \brief Console Task
234 *
235 * FIXME: Needs doc
236 */
221static void Console_Task(void) 237static void Console_Task(void)
222{ 238{
223 /* Device must be connected and configured for the task to run */ 239 /* Device must be connected and configured for the task to run */
@@ -282,6 +298,10 @@ static void Console_Task(void)
282 * 2) EVENT_USB_Device_Reset 298 * 2) EVENT_USB_Device_Reset
283 * 3) EVENT_USB_Device_Wake 299 * 3) EVENT_USB_Device_Wake
284*/ 300*/
301/** \brief Event USB Device Connect
302 *
303 * FIXME: Needs doc
304 */
285void EVENT_USB_Device_Connect(void) 305void EVENT_USB_Device_Connect(void)
286{ 306{
287 print("[C]"); 307 print("[C]");
@@ -293,6 +313,10 @@ void EVENT_USB_Device_Connect(void)
293 } 313 }
294} 314}
295 315
316/** \brief Event USB Device Connect
317 *
318 * FIXME: Needs doc
319 */
296void EVENT_USB_Device_Disconnect(void) 320void EVENT_USB_Device_Disconnect(void)
297{ 321{
298 print("[D]"); 322 print("[D]");
@@ -307,11 +331,19 @@ void EVENT_USB_Device_Disconnect(void)
307*/ 331*/
308} 332}
309 333
334/** \brief Event USB Device Connect
335 *
336 * FIXME: Needs doc
337 */
310void EVENT_USB_Device_Reset(void) 338void EVENT_USB_Device_Reset(void)
311{ 339{
312 print("[R]"); 340 print("[R]");
313} 341}
314 342
343/** \brief Event USB Device Connect
344 *
345 * FIXME: Needs doc
346 */
315void EVENT_USB_Device_Suspend() 347void EVENT_USB_Device_Suspend()
316{ 348{
317 print("[S]"); 349 print("[S]");
@@ -320,6 +352,10 @@ void EVENT_USB_Device_Suspend()
320#endif 352#endif
321} 353}
322 354
355/** \brief Event USB Device Connect
356 *
357 * FIXME: Needs doc
358 */
323void EVENT_USB_Device_WakeUp() 359void EVENT_USB_Device_WakeUp()
324{ 360{
325 print("[W]"); 361 print("[W]");
@@ -342,7 +378,11 @@ static bool console_flush = false;
342 } \ 378 } \
343} while (0) 379} while (0)
344 380
345// called every 1ms 381/** \brief Event USB Device Start Of Frame
382 *
383 * FIXME: Needs doc
384 * called every 1ms
385 */
346void EVENT_USB_Device_StartOfFrame(void) 386void EVENT_USB_Device_StartOfFrame(void)
347{ 387{
348 static uint8_t count; 388 static uint8_t count;
@@ -356,11 +396,12 @@ void EVENT_USB_Device_StartOfFrame(void)
356 396
357#endif 397#endif
358 398
359/** Event handler for the USB_ConfigurationChanged event. 399/** \brief Event handler for the USB_ConfigurationChanged event.
400 *
360 * This is fired when the host sets the current configuration of the USB device after enumeration. 401 * This is fired when the host sets the current configuration of the USB device after enumeration.
361 * 402 *
362 * ATMega32u2 supports dual bank(ping-pong mode) only on endpoint 3 and 4, 403 * ATMega32u2 supports dual bank(ping-pong mode) only on endpoint 3 and 4,
363 * it is safe to use singl bank for all endpoints. 404 * it is safe to use single bank for all endpoints.
364 */ 405 */
365void EVENT_USB_Device_ConfigurationChanged(void) 406void EVENT_USB_Device_ConfigurationChanged(void)
366{ 407{
@@ -418,7 +459,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
418#endif 459#endif
419} 460}
420 461
421/* 462/* FIXME: Expose this table in the docs somehow
422Appendix G: HID Request Support Requirements 463Appendix G: HID Request Support Requirements
423 464
424The following table enumerates the requests that need to be supported by various types of HID class devices. 465The following table enumerates the requests that need to be supported by various types of HID class devices.
@@ -431,7 +472,8 @@ Boot Keyboard Required Optional Required Required Required Requ
431Non-Boot Keybrd Required Optional Required Required Optional Optional 472Non-Boot Keybrd Required Optional Required Required Optional Optional
432Other Device Required Optional Optional Optional Optional Optional 473Other Device Required Optional Optional Optional Optional Optional
433*/ 474*/
434/** Event handler for the USB_ControlRequest event. 475/** \brief Event handler for the USB_ControlRequest event.
476 *
435 * This is fired before passing along unhandled control requests to the library for processing internally. 477 * This is fired before passing along unhandled control requests to the library for processing internally.
436 */ 478 */
437void EVENT_USB_Device_ControlRequest(void) 479void EVENT_USB_Device_ControlRequest(void)
@@ -546,11 +588,19 @@ void EVENT_USB_Device_ControlRequest(void)
546/******************************************************************************* 588/*******************************************************************************
547 * Host driver 589 * Host driver
548 ******************************************************************************/ 590 ******************************************************************************/
591/** \brief Keyboard LEDs
592 *
593 * FIXME: Needs doc
594 */
549static uint8_t keyboard_leds(void) 595static uint8_t keyboard_leds(void)
550{ 596{
551 return keyboard_led_stats; 597 return keyboard_led_stats;
552} 598}
553 599
600/** \brief Send Keyboard
601 *
602 * FIXME: Needs doc
603 */
554static void send_keyboard(report_keyboard_t *report) 604static void send_keyboard(report_keyboard_t *report)
555{ 605{
556 uint8_t timeout = 255; 606 uint8_t timeout = 255;
@@ -612,7 +662,11 @@ static void send_keyboard(report_keyboard_t *report)
612 662
613 keyboard_report_sent = *report; 663 keyboard_report_sent = *report;
614} 664}
615 665
666/** \brief Send Mouse
667 *
668 * FIXME: Needs doc
669 */
616static void send_mouse(report_mouse_t *report) 670static void send_mouse(report_mouse_t *report)
617{ 671{
618#ifdef MOUSE_ENABLE 672#ifdef MOUSE_ENABLE
@@ -657,6 +711,10 @@ static void send_mouse(report_mouse_t *report)
657#endif 711#endif
658} 712}
659 713
714/** \brief Send System
715 *
716 * FIXME: Needs doc
717 */
660static void send_system(uint16_t data) 718static void send_system(uint16_t data)
661{ 719{
662 uint8_t timeout = 255; 720 uint8_t timeout = 255;
@@ -678,6 +736,10 @@ static void send_system(uint16_t data)
678 Endpoint_ClearIN(); 736 Endpoint_ClearIN();
679} 737}
680 738
739/** \brief Send Consumer
740 *
741 * FIXME: Needs doc
742 */
681static void send_consumer(uint16_t data) 743static void send_consumer(uint16_t data)
682{ 744{
683 uint8_t timeout = 255; 745 uint8_t timeout = 255;
@@ -739,6 +801,10 @@ static void send_consumer(uint16_t data)
739 ******************************************************************************/ 801 ******************************************************************************/
740#ifdef CONSOLE_ENABLE 802#ifdef CONSOLE_ENABLE
741#define SEND_TIMEOUT 5 803#define SEND_TIMEOUT 5
804/** \brief Send Char
805 *
806 * FIXME: Needs doc
807 */
742int8_t sendchar(uint8_t c) 808int8_t sendchar(uint8_t c)
743{ 809{
744 // Not wait once timeouted. 810 // Not wait once timeouted.
@@ -842,18 +908,30 @@ bool recv_midi_packet(MIDI_EventPacket_t* const event) {
842 ******************************************************************************/ 908 ******************************************************************************/
843 909
844#ifdef VIRTSER_ENABLE 910#ifdef VIRTSER_ENABLE
911/** \brief Virtual Serial Init
912 *
913 * FIXME: Needs doc
914 */
845void virtser_init(void) 915void virtser_init(void)
846{ 916{
847 cdc_device.State.ControlLineStates.DeviceToHost = CDC_CONTROL_LINE_IN_DSR ; 917 cdc_device.State.ControlLineStates.DeviceToHost = CDC_CONTROL_LINE_IN_DSR ;
848 CDC_Device_SendControlLineStateChange(&cdc_device); 918 CDC_Device_SendControlLineStateChange(&cdc_device);
849} 919}
850 920
921/** \brief Virtual Serial Receive
922 *
923 * FIXME: Needs doc
924 */
851void virtser_recv(uint8_t c) __attribute__ ((weak)); 925void virtser_recv(uint8_t c) __attribute__ ((weak));
852void virtser_recv(uint8_t c) 926void virtser_recv(uint8_t c)
853{ 927{
854 // Ignore by default 928 // Ignore by default
855} 929}
856 930
931/** \brief Virtual Serial Task
932 *
933 * FIXME: Needs doc
934 */
857void virtser_task(void) 935void virtser_task(void)
858{ 936{
859 uint16_t count = CDC_Device_BytesReceived(&cdc_device); 937 uint16_t count = CDC_Device_BytesReceived(&cdc_device);
@@ -864,6 +942,10 @@ void virtser_task(void)
864 virtser_recv(ch); 942 virtser_recv(ch);
865 } 943 }
866} 944}
945/** \brief Virtual Serial Send
946 *
947 * FIXME: Needs doc
948 */
867void virtser_send(const uint8_t byte) 949void virtser_send(const uint8_t byte)
868{ 950{
869 uint8_t timeout = 255; 951 uint8_t timeout = 255;
@@ -896,6 +978,10 @@ void virtser_send(const uint8_t byte)
896/******************************************************************************* 978/*******************************************************************************
897 * main 979 * main
898 ******************************************************************************/ 980 ******************************************************************************/
981/** \brief Setup MCU
982 *
983 * FIXME: Needs doc
984 */
899static void setup_mcu(void) 985static void setup_mcu(void)
900{ 986{
901 /* Disable watchdog if enabled by bootloader/fuses */ 987 /* Disable watchdog if enabled by bootloader/fuses */
@@ -909,6 +995,10 @@ static void setup_mcu(void)
909 CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); 995 CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);
910} 996}
911 997
998/** \brief Setup USB
999 *
1000 * FIXME: Needs doc
1001 */
912static void setup_usb(void) 1002static void setup_usb(void)
913{ 1003{
914 // Leonardo needs. Without this USB device is not recognized. 1004 // Leonardo needs. Without this USB device is not recognized.
@@ -921,6 +1011,10 @@ static void setup_usb(void)
921 print_set_sendchar(sendchar); 1011 print_set_sendchar(sendchar);
922} 1012}
923 1013
1014/** \brief Main
1015 *
1016 * FIXME: Needs doc
1017 */
924int main(void) __attribute__ ((weak)); 1018int main(void) __attribute__ ((weak));
925int main(void) 1019int main(void)
926{ 1020{