forked from galak/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esp32s2: drivers: serial: add minimal uart driver
based on uart rom functions, also enable console driver on top of this driver, which enables logging Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
- Loading branch information
Showing
9 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config UART_ROM_ESP32S2 | ||
bool "ESP32S2 ROM UART driver" | ||
default y | ||
select SERIAL_HAS_DRIVER | ||
depends on SOC_ESP32S2 | ||
help | ||
Enable the ESP32S2 UART using ROM routines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#define DT_DRV_COMPAT espressif_esp32s2_uart | ||
|
||
/* Include esp-idf headers first to avoid redefining BIT() macro */ | ||
#include <soc.h> | ||
#include <esp_attr.h> | ||
#include <device.h> | ||
#include <drivers/uart.h> | ||
#include <drivers/clock_control.h> | ||
|
||
static int uart_rom_esp32s2_poll_in(const struct device *dev, unsigned char *p_char) | ||
{ | ||
ARG_UNUSED(dev); | ||
return (int)esp_rom_uart_rx_one_char(p_char); | ||
} | ||
|
||
static IRAM_ATTR void uart_rom_esp32s2_poll_out(const struct device *dev, | ||
unsigned char c) | ||
{ | ||
ARG_UNUSED(dev); | ||
esp_rom_uart_tx_one_char(c); | ||
} | ||
|
||
static int uart_rom_esp32s2_poll_err_check(const struct device *dev) | ||
{ | ||
ARG_UNUSED(dev); | ||
return 0; | ||
} | ||
|
||
static int uart_rom_esp32s2_init(const struct device *dev) | ||
{ | ||
ARG_UNUSED(dev); | ||
return 0; | ||
} | ||
|
||
static const DRAM_ATTR struct uart_driver_api uart_rom_esp32s2_api = { | ||
.poll_in = uart_rom_esp32s2_poll_in, | ||
.poll_out = uart_rom_esp32s2_poll_out, | ||
.err_check = uart_rom_esp32s2_poll_err_check, | ||
}; | ||
|
||
#define ESP32S2_ROM_UART_INIT(idx) \ | ||
DEVICE_DT_DEFINE(DT_NODELABEL(uart##idx), \ | ||
&uart_rom_esp32s2_init, \ | ||
NULL, \ | ||
NULL, \ | ||
NULL, \ | ||
PRE_KERNEL_1, \ | ||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ | ||
&uart_rom_esp32s2_api); \ | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(ESP32S2_ROM_UART_INIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
description: ESP32S2 UART | ||
|
||
compatible: "espressif,esp32s2-uart" | ||
|
||
include: uart-controller.yaml | ||
|
||
properties: | ||
reg: | ||
required: true | ||
|
||
interrupts: | ||
required: false | ||
|
||
tx-pin: | ||
type: int | ||
description: TX pin | ||
required: false | ||
|
||
rx-pin: | ||
type: int | ||
description: RX pin | ||
required: false | ||
|
||
rts-pin: | ||
type: int | ||
description: RTS pin | ||
required: false | ||
|
||
cts-pin: | ||
type: int | ||
description: CTS pin | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters