#81: restart HWCDC interrupt after 100ms
This commit is contained in:
parent
e3bab58f7e
commit
041b550ae9
lib/serial
|
@ -4,7 +4,8 @@
|
|||
#include "GwLog.h"
|
||||
#include "GwBuffer.h"
|
||||
#include "GwChannelInterface.h"
|
||||
#include "hal/usb_serial_jtag_ll.h"
|
||||
|
||||
#define USBCDC_RESTART_TIME 100
|
||||
class GwSerialStream;
|
||||
class GwSerial : public GwChannelInterface{
|
||||
protected:
|
||||
|
@ -71,15 +72,24 @@ template<typename T>
|
|||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
||||
/**
|
||||
* issue #81
|
||||
* workaround for the HWCDC beeing stuck at some point in time
|
||||
* with availableForWrite == 0 but the ISR being disabled
|
||||
* we simply give a small delay of 100ms for availableForWrite being 0
|
||||
* and afterwards call isConnected that seems to retrigger the ISR
|
||||
*/
|
||||
int availableForWrite(HWCDC* c){
|
||||
int rt=c->availableForWrite();
|
||||
if (rt > 0) {
|
||||
lastWritable=millis();
|
||||
return rt;
|
||||
}
|
||||
if (usb_serial_jtag_ll_txfifo_writable() == 1){
|
||||
LOG_INFO("USBserial restart");
|
||||
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
|
||||
unsigned long now=millis();
|
||||
if (now > (lastWritable+USBCDC_RESTART_TIME)){
|
||||
lastWritable=now;
|
||||
LOG_ERROR("***Restart USBCDC***");
|
||||
c->isConnected(); //this seems to retrigger the ISR
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue