Skip to content

Commit 6b54a55

Browse files
committed
Update HardwareSerial.cpp
1 parent 2ca5fd8 commit 6b54a55

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

cores/esp32/HardwareSerial.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
5656
end();
5757
}
5858
if(_uart_nr == 0 && rxPin < 0 && txPin < 0) {
59+
#if CONFIG_IDF_TARGET_ESP32
5960
rxPin = 3;
6061
txPin = 1;
62+
#elif CONFIG_IDF_TARGET_ESP32S2
63+
rxPin = 44;
64+
txPin = 43;
65+
#endif
6166
}
6267
if(_uart_nr == 1 && rxPin < 0 && txPin < 0) {
6368
rxPin = RX1;

cores/esp32/esp32-hal-uart.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,21 @@ struct uart_struct_t {
7676
#define UART_MUTEX_UNLOCK()
7777

7878
static uart_t _uart_bus_array[] = {
79-
{(volatile uart_dev_t *)(DR_REG_UART_BASE), 0, NULL, NULL},
80-
{(volatile uart_dev_t *)(DR_REG_UART1_BASE), 1, NULL, NULL},
79+
{&UART0, 0, NULL, NULL},
80+
{&UART1, 1, NULL, NULL},
8181
#if CONFIG_IDF_TARGET_ESP32
82-
{(volatile uart_dev_t *)(DR_REG_UART2_BASE), 2, NULL, NULL}
82+
{&UART2, 2, NULL, NULL}
8383
#endif
8484
};
8585
#else
8686
#define UART_MUTEX_LOCK() do {} while (xSemaphoreTake(uart->lock, portMAX_DELAY) != pdPASS)
8787
#define UART_MUTEX_UNLOCK() xSemaphoreGive(uart->lock)
8888

8989
static uart_t _uart_bus_array[] = {
90-
{(volatile uart_dev_t *)(DR_REG_UART_BASE), NULL, 0, NULL, NULL},
91-
{(volatile uart_dev_t *)(DR_REG_UART1_BASE), NULL, 1, NULL, NULL},
90+
{&UART0, NULL, 0, NULL, NULL},
91+
{&UART1, NULL, 1, NULL, NULL},
9292
#if CONFIG_IDF_TARGET_ESP32
93-
{(volatile uart_dev_t *)(DR_REG_UART2_BASE), NULL, 2, NULL, NULL}
93+
{&UART2, NULL, 2, NULL, NULL}
9494
#endif
9595
};
9696
#endif
@@ -116,7 +116,7 @@ static void IRAM_ATTR _uart_isr(void *arg)
116116
c = uart->dev->fifo.rw_byte;
117117
#else
118118
while(uart->dev->status.rxfifo_cnt) {
119-
c = uart->dev->ahb_fifo.rw_byte;
119+
c = READ_PERI_REG(UART_FIFO_AHB_REG(i));
120120
#endif
121121
if(uart->queue != NULL) {
122122
xQueueSendFromISR(uart->queue, &c, &xHigherPriorityTaskWoken);

0 commit comments

Comments
 (0)