@@ -79,7 +79,7 @@ void serialEvent(void) {}
79
79
#define TX1 19
80
80
#elif CONFIG_IDF_TARGET_ESP32S3
81
81
#define TX1 16
82
- #elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
82
+ #elif CONFIG_IDF_TARGET_ESP32C6
83
83
#define TX1 4
84
84
#elif CONFIG_IDF_TARGET_ESP32H2
85
85
#define TX1 1
@@ -95,7 +95,7 @@ void serialEvent1(void) {}
95
95
#if CONFIG_IDF_TARGET_ESP32
96
96
#define RX2 16
97
97
#elif CONFIG_IDF_TARGET_ESP32S3
98
- #define RX2 19
98
+ #define RX2 19
99
99
#endif
100
100
#endif
101
101
@@ -144,16 +144,16 @@ void serialEventRun(void)
144
144
#define HSERIAL_MUTEX_LOCK () do {} while (xSemaphoreTake(_lock, portMAX_DELAY) != pdPASS)
145
145
#define HSERIAL_MUTEX_UNLOCK () xSemaphoreGive(_lock)
146
146
#else
147
- #define HSERIAL_MUTEX_LOCK ()
148
- #define HSERIAL_MUTEX_UNLOCK ()
147
+ #define HSERIAL_MUTEX_LOCK ()
148
+ #define HSERIAL_MUTEX_UNLOCK ()
149
149
#endif
150
150
151
- HardwareSerial::HardwareSerial (int uart_nr) :
152
- _uart_nr(uart_nr),
151
+ HardwareSerial::HardwareSerial (int uart_nr) :
152
+ _uart_nr(uart_nr),
153
153
_uart(NULL ),
154
154
_rxBufferSize(256 ),
155
- _txBufferSize(0 ),
156
- _onReceiveCB(NULL ),
155
+ _txBufferSize(0 ),
156
+ _onReceiveCB(NULL ),
157
157
_onReceiveErrorCB(NULL ),
158
158
_onReceiveTimeout(false ),
159
159
_rxTimeout(2 ),
@@ -202,10 +202,10 @@ void HardwareSerial::_destroyEventTask(void)
202
202
}
203
203
}
204
204
205
- void HardwareSerial::onReceiveError (OnReceiveErrorCb function)
205
+ void HardwareSerial::onReceiveError (OnReceiveErrorCb function)
206
206
{
207
207
HSERIAL_MUTEX_LOCK ();
208
- // function may be NULL to cancel onReceive() from its respective task
208
+ // function may be NULL to cancel onReceive() from its respective task
209
209
_onReceiveErrorCB = function;
210
210
// this can be called after Serial.begin(), therefore it shall create the event task
211
211
if (function != NULL && _uart != NULL && _eventTask == NULL ) {
@@ -217,7 +217,7 @@ void HardwareSerial::onReceiveError(OnReceiveErrorCb function)
217
217
void HardwareSerial::onReceive (OnReceiveCb function, bool onlyOnTimeout)
218
218
{
219
219
HSERIAL_MUTEX_LOCK ();
220
- // function may be NULL to cancel onReceive() from its respective task
220
+ // function may be NULL to cancel onReceive() from its respective task
221
221
_onReceiveCB = function;
222
222
223
223
// setting the callback to NULL will just disable it
@@ -265,14 +265,14 @@ bool HardwareSerial::setRxFIFOFull(uint8_t fifoBytes)
265
265
bool HardwareSerial::setRxTimeout (uint8_t symbols_timeout)
266
266
{
267
267
HSERIAL_MUTEX_LOCK ();
268
-
268
+
269
269
// Zero disables timeout, thus, onReceive callback will only be called when RX FIFO reaches 120 bytes
270
- // Any non-zero value will activate onReceive callback based on UART baudrate with about 11 bits per symbol
271
- _rxTimeout = symbols_timeout;
272
- if (!symbols_timeout) _onReceiveTimeout = false ; // only when RX timeout is disabled, we also must disable this flag
270
+ // Any non-zero value will activate onReceive callback based on UART baudrate with about 11 bits per symbol
271
+ _rxTimeout = symbols_timeout;
272
+ if (!symbols_timeout) _onReceiveTimeout = false ; // only when RX timeout is disabled, we also must disable this flag
273
273
274
274
bool retCode = uartSetRxTimeout (_uart, _rxTimeout); // Set new timeout
275
-
275
+
276
276
HSERIAL_MUTEX_UNLOCK ();
277
277
return retCode;
278
278
}
@@ -281,7 +281,7 @@ void HardwareSerial::eventQueueReset()
281
281
{
282
282
QueueHandle_t uartEventQueue = NULL ;
283
283
if (_uart == NULL ) {
284
- return ;
284
+ return ;
285
285
}
286
286
uartGetEventQueue (_uart, &uartEventQueue);
287
287
if (uartEventQueue != NULL ) {
@@ -302,8 +302,8 @@ void HardwareSerial::_uartEventTask(void *args)
302
302
hardwareSerial_error_t currentErr = UART_NO_ERROR;
303
303
switch (event.type ) {
304
304
case UART_DATA:
305
- if (uart->_onReceiveCB && uart->available () > 0 &&
306
- ((uart->_onReceiveTimeout && event.timeout_flag ) || !uart->_onReceiveTimeout ) )
305
+ if (uart->_onReceiveCB && uart->available () > 0 &&
306
+ ((uart->_onReceiveTimeout && event.timeout_flag ) || !uart->_onReceiveTimeout ) )
307
307
uart->_onReceiveCB ();
308
308
break ;
309
309
case UART_FIFO_OVF:
@@ -410,18 +410,18 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
410
410
}
411
411
}
412
412
// create a task to deal with Serial Events when, for example, calling begin() twice to change the baudrate,
413
- // or when setting the callback before calling begin()
413
+ // or when setting the callback before calling begin()
414
414
if (_uart != NULL && (_onReceiveCB != NULL || _onReceiveErrorCB != NULL ) && _eventTask == NULL ) {
415
415
_createEventTask (this );
416
416
}
417
417
418
418
// Set UART RX timeout
419
419
uartSetRxTimeout (_uart, _rxTimeout);
420
420
421
- // Set UART FIFO Full depending on the baud rate.
421
+ // Set UART FIFO Full depending on the baud rate.
422
422
// Lower baud rates will force to emulate byte-by-byte reading
423
423
// Higher baud rates will keep IDF default of 120 bytes for FIFO FULL Interrupt
424
- // It can also be changed by the application at any time
424
+ // It can also be changed by the application at any time
425
425
if (!_rxFIFOFull) { // it has not being changed before calling begin()
426
426
// set a default FIFO Full value for the IDF driver
427
427
uint8_t fifoFull = 1 ;
@@ -437,23 +437,23 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
437
437
438
438
void HardwareSerial::updateBaudRate (unsigned long baud)
439
439
{
440
- uartSetBaudRate (_uart, baud);
440
+ uartSetBaudRate (_uart, baud);
441
441
}
442
442
443
443
void HardwareSerial::end (bool fullyTerminate)
444
444
{
445
- // default Serial.end() will completely disable HardwareSerial,
445
+ // default Serial.end() will completely disable HardwareSerial,
446
446
// including any tasks or debug message channel (log_x()) - but not for IDF log messages!
447
447
if (fullyTerminate) {
448
448
_onReceiveCB = NULL ;
449
449
_onReceiveErrorCB = NULL ;
450
450
if (uartGetDebug () == _uart_nr) {
451
451
uartSetDebug (0 );
452
452
}
453
- _rxFIFOFull = 0 ;
453
+ _rxFIFOFull = 0 ;
454
454
uartEnd (_uart); // fully detach all pins and delete the UART driver
455
455
} else {
456
- // do not invalidate callbacks, detach pins, invalidate DBG output
456
+ // do not invalidate callbacks, detach pins, invalidate DBG output
457
457
uart_driver_delete (_uart_nr);
458
458
}
459
459
_uart = 0 ;
@@ -540,7 +540,7 @@ size_t HardwareSerial::write(const uint8_t *buffer, size_t size)
540
540
uint32_t HardwareSerial::baudRate ()
541
541
542
542
{
543
- return uartGetBaudRate (_uart);
543
+ return uartGetBaudRate (_uart);
544
544
}
545
545
HardwareSerial::operator bool () const
546
546
{
0 commit comments