Merge pull request #234 from fdlamotte/Arduino_serial_using_stream
use Stream abstract interface for serial port in ArduinoSerialInterface
This commit is contained in:
@@ -8,30 +8,18 @@ class ArduinoSerialInterface : public BaseSerialInterface {
|
|||||||
uint8_t _state;
|
uint8_t _state;
|
||||||
uint16_t _frame_len;
|
uint16_t _frame_len;
|
||||||
uint16_t rx_len;
|
uint16_t rx_len;
|
||||||
#ifdef LILYGO_T3S3
|
Stream* _serial;
|
||||||
HWCDC* _serial;
|
|
||||||
#elif defined(NRF52_PLATFORM)
|
|
||||||
Adafruit_USBD_CDC* _serial;
|
|
||||||
#else
|
|
||||||
HardwareSerial* _serial;
|
|
||||||
#endif
|
|
||||||
uint8_t rx_buf[MAX_FRAME_SIZE];
|
uint8_t rx_buf[MAX_FRAME_SIZE];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArduinoSerialInterface() { _isEnabled = false; _state = 0; }
|
ArduinoSerialInterface() { _isEnabled = false; _state = 0; }
|
||||||
|
|
||||||
#ifdef LILYGO_T3S3
|
void begin(Stream& serial) {
|
||||||
void begin(HWCDC& serial) { _serial = &serial; }
|
_serial = &serial;
|
||||||
#elif defined(NRF52_PLATFORM)
|
|
||||||
void begin(Adafruit_USBD_CDC& serial) {
|
|
||||||
_serial = &serial;
|
|
||||||
#ifdef RAK_4631
|
#ifdef RAK_4631
|
||||||
pinMode(WB_IO2, OUTPUT);
|
pinMode(WB_IO2, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void begin(HardwareSerial& serial) { _serial = &serial; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// BaseSerialInterface methods
|
// BaseSerialInterface methods
|
||||||
void enable() override;
|
void enable() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user