diff options
Diffstat (limited to 'tmk_core/protocol/lufa/lufa.c')
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 391064c9b..85fdeabdd 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -197,10 +197,24 @@ void EVENT_USB_Device_WakeUp() | |||
| 197 | #endif | 197 | #endif |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | #ifdef CONSOLE_ENABLE | ||
| 201 | static bool console_flush = false; | ||
| 202 | #define CONSOLE_FLUSH_SET(b) do { \ | ||
| 203 | uint8_t sreg = SREG; cli(); console_flush = b; SREG = sreg; \ | ||
| 204 | } while (0) | ||
| 205 | |||
| 206 | // called every 1ms | ||
| 200 | void EVENT_USB_Device_StartOfFrame(void) | 207 | void EVENT_USB_Device_StartOfFrame(void) |
| 201 | { | 208 | { |
| 209 | static uint8_t count; | ||
| 210 | if (++count % 50) return; | ||
| 211 | count = 0; | ||
| 212 | |||
| 213 | if (!console_flush) return; | ||
| 202 | Console_Task(); | 214 | Console_Task(); |
| 215 | console_flush = false; | ||
| 203 | } | 216 | } |
| 217 | #endif | ||
| 204 | 218 | ||
| 205 | /** Event handler for the USB_ConfigurationChanged event. | 219 | /** Event handler for the USB_ConfigurationChanged event. |
| 206 | * This is fired when the host sets the current configuration of the USB device after enumeration. | 220 | * This is fired when the host sets the current configuration of the USB device after enumeration. |
| @@ -491,6 +505,10 @@ int8_t sendchar(uint8_t c) | |||
| 491 | // Because sendchar() is called so many times, waiting each call causes big lag. | 505 | // Because sendchar() is called so many times, waiting each call causes big lag. |
| 492 | static bool timeouted = false; | 506 | static bool timeouted = false; |
| 493 | 507 | ||
| 508 | // prevents Console_Task() from running during sendchar() runs. | ||
| 509 | // or char will be lost. These two function is mutually exclusive. | ||
| 510 | CONSOLE_FLUSH_SET(false); | ||
| 511 | |||
| 494 | if (USB_DeviceState != DEVICE_STATE_Configured) | 512 | if (USB_DeviceState != DEVICE_STATE_Configured) |
| 495 | return -1; | 513 | return -1; |
| 496 | 514 | ||
| @@ -524,8 +542,12 @@ int8_t sendchar(uint8_t c) | |||
| 524 | Endpoint_Write_8(c); | 542 | Endpoint_Write_8(c); |
| 525 | 543 | ||
| 526 | // send when bank is full | 544 | // send when bank is full |
| 527 | if (!Endpoint_IsReadWriteAllowed()) | 545 | if (!Endpoint_IsReadWriteAllowed()) { |
| 546 | while (!(Endpoint_IsINReady())); | ||
| 528 | Endpoint_ClearIN(); | 547 | Endpoint_ClearIN(); |
| 548 | } else { | ||
| 549 | CONSOLE_FLUSH_SET(true); | ||
| 550 | } | ||
| 529 | 551 | ||
| 530 | Endpoint_SelectEndpoint(ep); | 552 | Endpoint_SelectEndpoint(ep); |
| 531 | return 0; | 553 | return 0; |
