Skip to content

Commit 59a6800

Browse files
committed
Enable clocks for UART1 and 2
Recent change in IDF disables those clocks at boot. This change should help with that. Fixes: espressif/esp-idf#975
1 parent 9edf65d commit 59a6800

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cores/esp32/esp32-hal-uart.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "soc/uart_struct.h"
2727
#include "soc/io_mux_reg.h"
2828
#include "soc/gpio_sig_map.h"
29+
#include "soc/dport_reg.h"
2930

3031
#define ETS_UART_INUM 5
3132
#define ETS_UART2_INUM ETS_UART_INUM
@@ -190,7 +191,13 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
190191
return NULL;
191192
}
192193
}
193-
194+
if(uart_nr == 1){
195+
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_UART1_CLK_EN);
196+
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_UART1_RST);
197+
} else if(uart_nr == 2){
198+
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_UART2_CLK_EN);
199+
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_UART2_RST);
200+
}
194201
uartFlush(uart);
195202
uartSetBaudRate(uart, baudrate);
196203
UART_MUTEX_LOCK();

0 commit comments

Comments
 (0)