move tud cdc write flush to yield(), add yield() to Stream timeRead(), timePeek()
This commit is contained in:
1 parent
36f5be1c52
commit
f5aeb3820d
5 files changed
+13
-18
No files matched your search
@@ -82,11 +82,6 @@ int Adafruit_USBD_CDC::read(void)
|
||||
return (int) tud_cdc_read_char();
|
||||
}
|
||||
|
||||
size_t Adafruit_USBD_CDC::readBytes(char *buffer, size_t length)
|
||||
{
|
||||
return tud_cdc_read(buffer, length);
|
||||
}
|
||||
|
||||
void Adafruit_USBD_CDC::flush(void)
|
||||
{
|
||||
tud_cdc_write_flush();
|
||||
|
||||
@@ -51,9 +51,6 @@ public:
|
||||
return write((const uint8_t *)buffer, size);
|
||||
}
|
||||
operator bool();
|
||||
|
||||
size_t readBytes(char *buffer, size_t length);
|
||||
size_t readBytes(uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
|
||||
};
|
||||
|
||||
extern Adafruit_USBD_CDC Serial;
|
||||
|
||||
@@ -35,6 +35,7 @@ int Stream::timedRead()
|
||||
do {
|
||||
c = read();
|
||||
if (c >= 0) return c;
|
||||
yield(); // running TinyUSB task
|
||||
} while(millis() - _startMillis < _timeout);
|
||||
return -1; // -1 indicates timeout
|
||||
}
|
||||
@@ -47,6 +48,7 @@ int Stream::timedPeek()
|
||||
do {
|
||||
c = peek();
|
||||
if (c >= 0) return c;
|
||||
yield(); // running TinyUSB task
|
||||
} while(millis() - _startMillis < _timeout);
|
||||
return -1; // -1 indicates timeout
|
||||
}
|
||||
|
||||
+1
-4
@@ -56,10 +56,7 @@ static void loop_task(void* arg)
|
||||
while (1)
|
||||
{
|
||||
loop();
|
||||
|
||||
#ifdef USE_TINYUSB
|
||||
tud_cdc_write_flush();
|
||||
#endif
|
||||
yield(); // yield run usb background task
|
||||
|
||||
// Serial events
|
||||
if (serialEvent && serialEventRun) serialEventRun();
|
||||
|
||||
+10
-6
@@ -38,11 +38,6 @@
|
||||
|
||||
SchedulerRTOS Scheduler;
|
||||
|
||||
void yield(void)
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
static void _redirect_task(void* arg)
|
||||
{
|
||||
SchedulerRTOS::taskfunc_t taskfunc = (SchedulerRTOS::taskfunc_t) arg;
|
||||
@@ -81,12 +76,21 @@ bool SchedulerRTOS::startLoop(taskfunc_t task, const char* name, uint32_t stack_
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// FreeRTOS Hooks
|
||||
// Hooks
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void yield(void)
|
||||
{
|
||||
#ifdef USE_TINYUSB
|
||||
tud_cdc_write_flush();
|
||||
#endif
|
||||
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName )
|
||||
{
|
||||
LOG_LV1("RTOS", "%s Stack Overflow !!!", pcTaskName);
|
||||
|
||||
Reference in new issue
Block a user