-#endif
- // Not wait once timeouted.
- // Because sendchar() is called so many times, waiting each call causes big lag.
- static bool timeouted = false;
-
- // prevents Console_Task() from running during sendchar() runs.
- // or char will be lost. These two function is mutually exclusive.
- CONSOLE_FLUSH_SET(false);
-
- if (USB_DeviceState != DEVICE_STATE_Configured)
- return -1;
-
- uint8_t ep = Endpoint_GetCurrentEndpoint();
- Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
- if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
- goto ERROR_EXIT;
- }
-
- if (timeouted && !Endpoint_IsReadWriteAllowed()) {
- goto ERROR_EXIT;
- }