mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-01-07 17:23:07 +01:00
#81: restart HWCDC interrupt after 100ms
This commit is contained in:
@@ -4,7 +4,8 @@
|
|||||||
#include "GwLog.h"
|
#include "GwLog.h"
|
||||||
#include "GwBuffer.h"
|
#include "GwBuffer.h"
|
||||||
#include "GwChannelInterface.h"
|
#include "GwChannelInterface.h"
|
||||||
#include "hal/usb_serial_jtag_ll.h"
|
|
||||||
|
#define USBCDC_RESTART_TIME 100
|
||||||
class GwSerialStream;
|
class GwSerialStream;
|
||||||
class GwSerial : public GwChannelInterface{
|
class GwSerial : public GwChannelInterface{
|
||||||
protected:
|
protected:
|
||||||
@@ -71,15 +72,24 @@ template<typename T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
#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 availableForWrite(HWCDC* c){
|
||||||
int rt=c->availableForWrite();
|
int rt=c->availableForWrite();
|
||||||
if (rt > 0) {
|
if (rt > 0) {
|
||||||
lastWritable=millis();
|
lastWritable=millis();
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
if (usb_serial_jtag_ll_txfifo_writable() == 1){
|
unsigned long now=millis();
|
||||||
LOG_INFO("USBserial restart");
|
if (now > (lastWritable+USBCDC_RESTART_TIME)){
|
||||||
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
|
lastWritable=now;
|
||||||
|
LOG_ERROR("***Restart USBCDC***");
|
||||||
|
c->isConnected(); //this seems to retrigger the ISR
|
||||||
}
|
}
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user