intermediate: try special handling for USBCDC
This commit is contained in:
parent
40c4089f86
commit
18b9946b62
|
@ -4,6 +4,7 @@
|
||||||
#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"
|
||||||
class GwSerialStream;
|
class GwSerialStream;
|
||||||
class GwSerial : public GwChannelInterface{
|
class GwSerial : public GwChannelInterface{
|
||||||
protected:
|
protected:
|
||||||
|
@ -39,6 +40,7 @@ class GwSerial : public GwChannelInterface{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class GwSerialImpl : public GwSerial{
|
class GwSerialImpl : public GwSerial{
|
||||||
private:
|
private:
|
||||||
|
unsigned long lastWritable=0;
|
||||||
template<class C>
|
template<class C>
|
||||||
void beginImpl(C *s,unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1){}
|
void beginImpl(C *s,unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1){}
|
||||||
void beginImpl(HardwareSerial *s,unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1){
|
void beginImpl(HardwareSerial *s,unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1){
|
||||||
|
@ -59,7 +61,29 @@ template<typename T>
|
||||||
#endif
|
#endif
|
||||||
template<class C>
|
template<class C>
|
||||||
long getFlushTimeoutImpl(const C*){return 2000;}
|
long getFlushTimeoutImpl(const C*){return 2000;}
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
||||||
long getFlushTimeoutImpl(HWCDC *){return 200;}
|
long getFlushTimeoutImpl(HWCDC *){return 200;}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<class C>
|
||||||
|
int availableForWrite(C* c){
|
||||||
|
return c->availableForWrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
T *serial;
|
T *serial;
|
||||||
protected:
|
protected:
|
||||||
|
@ -67,7 +91,7 @@ template<typename T>
|
||||||
return getFlushTimeoutImpl(serial);
|
return getFlushTimeoutImpl(serial);
|
||||||
}
|
}
|
||||||
virtual int availableForWrite(){
|
virtual int availableForWrite(){
|
||||||
return serial->availableForWrite();
|
return availableForWrite(serial);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
GwSerialImpl(GwLog* logger,T* s,int i,int type,bool allowRead=true): GwSerial(logger,s,i,type,allowRead),serial(s){}
|
GwSerialImpl(GwLog* logger,T* s,int i,int type,bool allowRead=true): GwSerial(logger,s,i,type,allowRead),serial(s){}
|
||||||
|
|
Loading…
Reference in New Issue