@@ -79,7 +79,7 @@ void serialEvent(void) {}
7979#define TX1 19
8080#elif CONFIG_IDF_TARGET_ESP32S3
8181#define TX1 16
82- #elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
82+ #elif CONFIG_IDF_TARGET_ESP32C6
8383#define TX1 4
8484#elif CONFIG_IDF_TARGET_ESP32H2
8585#define TX1 1
@@ -95,7 +95,7 @@ void serialEvent1(void) {}
9595#if CONFIG_IDF_TARGET_ESP32
9696#define RX2 16
9797#elif CONFIG_IDF_TARGET_ESP32S3
98- #define RX2 19
98+ #define RX2 19
9999#endif
100100#endif
101101
@@ -144,16 +144,16 @@ void serialEventRun(void)
144144#define HSERIAL_MUTEX_LOCK () do {} while (xSemaphoreTake(_lock, portMAX_DELAY) != pdPASS)
145145#define HSERIAL_MUTEX_UNLOCK () xSemaphoreGive(_lock)
146146#else
147- #define HSERIAL_MUTEX_LOCK ()
148- #define HSERIAL_MUTEX_UNLOCK ()
147+ #define HSERIAL_MUTEX_LOCK ()
148+ #define HSERIAL_MUTEX_UNLOCK ()
149149#endif
150150
151- HardwareSerial::HardwareSerial (int uart_nr) :
152- _uart_nr(uart_nr),
151+ HardwareSerial::HardwareSerial (int uart_nr) :
152+ _uart_nr(uart_nr),
153153_uart(NULL ),
154154_rxBufferSize(256 ),
155- _txBufferSize(0 ),
156- _onReceiveCB(NULL ),
155+ _txBufferSize(0 ),
156+ _onReceiveCB(NULL ),
157157_onReceiveErrorCB(NULL ),
158158_onReceiveTimeout(false ),
159159_rxTimeout(2 ),
@@ -202,10 +202,10 @@ void HardwareSerial::_destroyEventTask(void)
202202 }
203203}
204204
205- void HardwareSerial::onReceiveError (OnReceiveErrorCb function)
205+ void HardwareSerial::onReceiveError (OnReceiveErrorCb function)
206206{
207207 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
209209 _onReceiveErrorCB = function;
210210 // this can be called after Serial.begin(), therefore it shall create the event task
211211 if (function != NULL && _uart != NULL && _eventTask == NULL ) {
@@ -217,7 +217,7 @@ void HardwareSerial::onReceiveError(OnReceiveErrorCb function)
217217void HardwareSerial::onReceive (OnReceiveCb function, bool onlyOnTimeout)
218218{
219219 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
221221 _onReceiveCB = function;
222222
223223 // setting the callback to NULL will just disable it
@@ -265,14 +265,14 @@ bool HardwareSerial::setRxFIFOFull(uint8_t fifoBytes)
265265bool HardwareSerial::setRxTimeout (uint8_t symbols_timeout)
266266{
267267 HSERIAL_MUTEX_LOCK ();
268-
268+
269269 // 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
273273
274274 bool retCode = uartSetRxTimeout (_uart, _rxTimeout); // Set new timeout
275-
275+
276276 HSERIAL_MUTEX_UNLOCK ();
277277 return retCode;
278278}
@@ -281,7 +281,7 @@ void HardwareSerial::eventQueueReset()
281281{
282282 QueueHandle_t uartEventQueue = NULL ;
283283 if (_uart == NULL ) {
284- return ;
284+ return ;
285285 }
286286 uartGetEventQueue (_uart, &uartEventQueue);
287287 if (uartEventQueue != NULL ) {
@@ -302,8 +302,8 @@ void HardwareSerial::_uartEventTask(void *args)
302302 hardwareSerial_error_t currentErr = UART_NO_ERROR;
303303 switch (event.type ) {
304304 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 ) )
307307 uart->_onReceiveCB ();
308308 break ;
309309 case UART_FIFO_OVF:
@@ -410,18 +410,18 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
410410 }
411411 }
412412 // 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()
414414 if (_uart != NULL && (_onReceiveCB != NULL || _onReceiveErrorCB != NULL ) && _eventTask == NULL ) {
415415 _createEventTask (this );
416416 }
417417
418418 // Set UART RX timeout
419419 uartSetRxTimeout (_uart, _rxTimeout);
420420
421- // Set UART FIFO Full depending on the baud rate.
421+ // Set UART FIFO Full depending on the baud rate.
422422 // Lower baud rates will force to emulate byte-by-byte reading
423423 // 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
425425 if (!_rxFIFOFull) { // it has not being changed before calling begin()
426426 // set a default FIFO Full value for the IDF driver
427427 uint8_t fifoFull = 1 ;
@@ -437,23 +437,23 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
437437
438438void HardwareSerial::updateBaudRate (unsigned long baud)
439439{
440- uartSetBaudRate (_uart, baud);
440+ uartSetBaudRate (_uart, baud);
441441}
442442
443443void HardwareSerial::end (bool fullyTerminate)
444444{
445- // default Serial.end() will completely disable HardwareSerial,
445+ // default Serial.end() will completely disable HardwareSerial,
446446 // including any tasks or debug message channel (log_x()) - but not for IDF log messages!
447447 if (fullyTerminate) {
448448 _onReceiveCB = NULL ;
449449 _onReceiveErrorCB = NULL ;
450450 if (uartGetDebug () == _uart_nr) {
451451 uartSetDebug (0 );
452452 }
453- _rxFIFOFull = 0 ;
453+ _rxFIFOFull = 0 ;
454454 uartEnd (_uart); // fully detach all pins and delete the UART driver
455455 } else {
456- // do not invalidate callbacks, detach pins, invalidate DBG output
456+ // do not invalidate callbacks, detach pins, invalidate DBG output
457457 uart_driver_delete (_uart_nr);
458458 }
459459 _uart = 0 ;
@@ -540,7 +540,7 @@ size_t HardwareSerial::write(const uint8_t *buffer, size_t size)
540540uint32_t HardwareSerial::baudRate ()
541541
542542{
543- return uartGetBaudRate (_uart);
543+ return uartGetBaudRate (_uart);
544544}
545545HardwareSerial::operator bool () const
546546{
0 commit comments