|
@@ -197,10 +197,24 @@ void EVENT_USB_Device_WakeUp()
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+#ifdef CONSOLE_ENABLE
|
|
|
+static bool console_flush = false;
|
|
|
+#define CONSOLE_FLUSH_SET(b) do { \
|
|
|
+ uint8_t sreg = SREG; cli(); console_flush = b; SREG = sreg; \
|
|
|
+} while (0)
|
|
|
+
|
|
|
+
|
|
|
void EVENT_USB_Device_StartOfFrame(void)
|
|
|
{
|
|
|
+ static uint8_t count;
|
|
|
+ if (++count % 50) return;
|
|
|
+ count = 0;
|
|
|
+
|
|
|
+ if (!console_flush) return;
|
|
|
Console_Task();
|
|
|
+ console_flush = false;
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
* 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)
|
|
|
|
|
|
static bool timeouted = false;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ CONSOLE_FLUSH_SET(false);
|
|
|
+
|
|
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
|
|
return -1;
|
|
|
|
|
@@ -524,8 +542,12 @@ int8_t sendchar(uint8_t c)
|
|
|
Endpoint_Write_8(c);
|
|
|
|
|
|
|
|
|
- if (!Endpoint_IsReadWriteAllowed())
|
|
|
+ if (!Endpoint_IsReadWriteAllowed()) {
|
|
|
+ while (!(Endpoint_IsINReady()));
|
|
|
Endpoint_ClearIN();
|
|
|
+ } else {
|
|
|
+ CONSOLE_FLUSH_SET(true);
|
|
|
+ }
|
|
|
|
|
|
Endpoint_SelectEndpoint(ep);
|
|
|
return 0;
|