Browse Source
Merge pull request #234 from fdlamotte/Arduino_serial_using_stream
use Stream abstract interface for serial port in ArduinoSerialInterface
pull/242/head
ripplebiz
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
4 additions and
16 deletions
-
src/helpers/ArduinoSerialInterface.h
|
|
|
@ -8,30 +8,18 @@ class ArduinoSerialInterface : public BaseSerialInterface { |
|
|
|
uint8_t _state; |
|
|
|
uint16_t _frame_len; |
|
|
|
uint16_t rx_len; |
|
|
|
#ifdef LILYGO_T3S3 |
|
|
|
HWCDC* _serial; |
|
|
|
#elif defined(NRF52_PLATFORM) |
|
|
|
Adafruit_USBD_CDC* _serial; |
|
|
|
#else |
|
|
|
HardwareSerial* _serial; |
|
|
|
#endif |
|
|
|
Stream* _serial; |
|
|
|
uint8_t rx_buf[MAX_FRAME_SIZE]; |
|
|
|
|
|
|
|
public: |
|
|
|
ArduinoSerialInterface() { _isEnabled = false; _state = 0; } |
|
|
|
|
|
|
|
#ifdef LILYGO_T3S3 |
|
|
|
void begin(HWCDC& serial) { _serial = &serial; } |
|
|
|
#elif defined(NRF52_PLATFORM) |
|
|
|
void begin(Adafruit_USBD_CDC& serial) { |
|
|
|
_serial = &serial; |
|
|
|
void begin(Stream& serial) { |
|
|
|
_serial = &serial; |
|
|
|
#ifdef RAK_4631 |
|
|
|
pinMode(WB_IO2, OUTPUT); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
#else |
|
|
|
void begin(HardwareSerial& serial) { _serial = &serial; } |
|
|
|
#endif |
|
|
|
|
|
|
|
// BaseSerialInterface methods
|
|
|
|
void enable() override; |
|
|
|
|