diff --git a/arch/risc-v/src/esp32c3/esp32c3_lowputc.c b/arch/risc-v/src/esp32c3/esp32c3_lowputc.c index c38b9737007..69683419c90 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_lowputc.c +++ b/arch/risc-v/src/esp32c3/esp32c3_lowputc.c @@ -666,6 +666,31 @@ void esp32c3_lowputc_rst_rxfifo(const struct esp32c3_uart_s *priv) modifyreg32(UART_CONF0_REG(priv->id), UART_RXFIFO_RST_M, 0); } +/**************************************************************************** + * Name: esp32c3_lowputc_enable_sysclk + * + * Description: + * Enable clock for the UART using the System register. + * + * Parameters: + * priv - Pointer to the private driver struct. + * + ****************************************************************************/ + +void esp32c3_lowputc_enable_sysclk(const struct esp32c3_uart_s *priv) +{ + if (priv->id == 0) + { + modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0, + SYSTEM_UART_CLK_EN_M); + } + else + { + modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0, + SYSTEM_UART1_CLK_EN_M); + } +} + /**************************************************************************** * Name: esp32c3_lowputc_disable_all_uart_int * @@ -836,12 +861,14 @@ void esp32c3_lowsetup(void) #ifdef CONFIG_ESP32C3_UART0 + esp32c3_lowputc_enable_sysclk(&g_uart0_config); esp32c3_lowputc_config_pins(&g_uart0_config); #endif #ifdef CONFIG_ESP32C3_UART1 + esp32c3_lowputc_enable_sysclk(&g_uart1_config); esp32c3_lowputc_config_pins(&g_uart1_config); #endif diff --git a/arch/risc-v/src/esp32c3/esp32c3_lowputc.h b/arch/risc-v/src/esp32c3/esp32c3_lowputc.h index e8455ca5727..18f6a2c474b 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_lowputc.h +++ b/arch/risc-v/src/esp32c3/esp32c3_lowputc.h @@ -409,6 +409,19 @@ void esp32c3_lowputc_rst_txfifo(const struct esp32c3_uart_s *priv); void esp32c3_lowputc_rst_rxfifo(const struct esp32c3_uart_s *priv); +/**************************************************************************** + * Name: esp32c3_lowputc_enable_sysclk + * + * Description: + * Enable clock for the UART using the System register. + * + * Parameters: + * priv - Pointer to the private driver struct. + * + ****************************************************************************/ + +void esp32c3_lowputc_enable_sysclk(const struct esp32c3_uart_s *priv); + /**************************************************************************** * Name: esp32c3_lowputc_disable_all_uart_int * diff --git a/arch/risc-v/src/esp32c3/esp32c3_serial.c b/arch/risc-v/src/esp32c3/esp32c3_serial.c index ce0c85a0bdf..2a462d8c9f1 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_serial.c +++ b/arch/risc-v/src/esp32c3/esp32c3_serial.c @@ -335,6 +335,10 @@ static int esp32c3_setup(struct uart_dev_s *dev) modifyreg32(UART_MEM_CONF_REG(priv->id), UART_TX_SIZE_M | UART_RX_SIZE_M, (1 << UART_TX_SIZE_S) | (1 << UART_RX_SIZE_S)); + /* Enable the UART Clock */ + + esp32c3_lowputc_enable_sysclk(priv); + /* Configure the UART Baud Rate */ esp32c3_lowputc_baud(priv);