aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/lufa
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/lufa')
-rw-r--r--tmk_core/protocol/lufa/lufa.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index f1908b3d0..85d71d083 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -829,9 +829,10 @@ static void send_consumer(uint16_t data) {
829 * FIXME: Needs doc 829 * FIXME: Needs doc
830 */ 830 */
831int8_t sendchar(uint8_t c) { 831int8_t sendchar(uint8_t c) {
832 // Not wait once timeouted. 832 // Do not wait if the previous write has timed_out.
833 // Because sendchar() is called so many times, waiting each call causes big lag. 833 // Because sendchar() is called so many times, waiting each call causes big lag.
834 static bool timeouted = false; 834 // The `timed_out` state is an approximation of the ideal `is_listener_disconnected?` state.
835 static bool timed_out = false;
835 836
836 // prevents Console_Task() from running during sendchar() runs. 837 // prevents Console_Task() from running during sendchar() runs.
837 // or char will be lost. These two function is mutually exclusive. 838 // or char will be lost. These two function is mutually exclusive.
@@ -845,11 +846,11 @@ int8_t sendchar(uint8_t c) {
845 goto ERROR_EXIT; 846 goto ERROR_EXIT;
846 } 847 }
847 848
848 if (timeouted && !Endpoint_IsReadWriteAllowed()) { 849 if (timed_out && !Endpoint_IsReadWriteAllowed()) {
849 goto ERROR_EXIT; 850 goto ERROR_EXIT;
850 } 851 }
851 852
852 timeouted = false; 853 timed_out = false;
853 854
854 uint8_t timeout = SEND_TIMEOUT; 855 uint8_t timeout = SEND_TIMEOUT;
855 while (!Endpoint_IsReadWriteAllowed()) { 856 while (!Endpoint_IsReadWriteAllowed()) {
@@ -860,7 +861,7 @@ int8_t sendchar(uint8_t c) {
860 goto ERROR_EXIT; 861 goto ERROR_EXIT;
861 } 862 }
862 if (!(timeout--)) { 863 if (!(timeout--)) {
863 timeouted = true; 864 timed_out = true;
864 goto ERROR_EXIT; 865 goto ERROR_EXIT;
865 } 866 }
866 _delay_ms(1); 867 _delay_ms(1);