From 5f22dab17aada4c8213ed1e2140d3b7c7abd534c Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Fri, 15 Sep 2017 16:52:36 -0700 Subject: [PATCH] esp32: Prefix ROM routines with `esp32_rom_` Also provide their prototypes in `soc.h`. This should help readability, since some ROM functions, with their names as provided by Espressif, have sometimes the same prefix as Zephyr APIs. Signed-off-by: Leandro Pereira --- arch/xtensa/soc/esp32/linker.ld | 10 ++++++---- arch/xtensa/soc/esp32/soc.h | 29 +++++++++++++++++++++++++++++ drivers/gpio/gpio_esp32.c | 6 +++--- drivers/serial/uart_esp32.c | 8 ++++---- drivers/watchdog/wdt_esp32.c | 5 +++-- 5 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 arch/xtensa/soc/esp32/soc.h diff --git a/arch/xtensa/soc/esp32/linker.ld b/arch/xtensa/soc/esp32/linker.ld index 970b4b7b6a9..e9e53e6c0e5 100644 --- a/arch/xtensa/soc/esp32/linker.ld +++ b/arch/xtensa/soc/esp32/linker.ld @@ -24,10 +24,12 @@ PROVIDE ( __stack = 0x3ffe3f20 ); -PROVIDE ( uart_tx_one_char = 0x40009200 ); -PROVIDE ( uart_rx_one_char = 0x400092d0 ); -PROVIDE ( uartAttach = 0x40008fd0 ); -PROVIDE ( intr_matrix_set = 0x4000681c ); +PROVIDE ( esp32_rom_uart_tx_one_char = 0x40009200 ); +PROVIDE ( esp32_rom_uart_rx_one_char = 0x400092d0 ); +PROVIDE ( esp32_rom_uart_attach = 0x40008fd0 ); +PROVIDE ( esp32_rom_intr_matrix_set = 0x4000681c ); +PROVIDE ( esp32_rom_gpio_matrix_in = 0x40009edc ); +PROVIDE ( esp32_rom_gpio_matrix_out = 0x40009f0c ); MEMORY { diff --git a/arch/xtensa/soc/esp32/soc.h b/arch/xtensa/soc/esp32/soc.h new file mode 100644 index 00000000000..8fb99b24219 --- /dev/null +++ b/arch/xtensa/soc/esp32/soc.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __SOC_H__ +#define __SOC_H__ + +#include + +#include +#include + +extern int esp32_rom_intr_matrix_set(int cpu_no, + int interrupt_src, + int interrupt_line); + +extern int esp32_rom_gpio_matrix_in(u32_t gpio, u32_t signal_index, + bool inverted); +extern int esp32_rom_gpio_matrix_out(u32_t gpio, u32_t signal_index, + bool out_inverted, + bool out_enabled_inverted); + +extern void esp32_rom_uart_attach(void); +extern STATUS esp32_rom_uart_tx_one_char(u8_t chr); +extern STATUS esp32_rom_uart_rx_one_char(u8_t *chr); + +#endif /* __SOC_H__ */ diff --git a/drivers/gpio/gpio_esp32.c b/drivers/gpio/gpio_esp32.c index d7f8bbf61a5..e925244aed3 100644 --- a/drivers/gpio/gpio_esp32.c +++ b/drivers/gpio/gpio_esp32.c @@ -5,12 +5,12 @@ */ /* Include esp-idf headers first to avoid redefining BIT() macro */ -#include #include #include #include #include +#include #include #include #include @@ -272,8 +272,8 @@ static int gpio_esp32_init(struct device *device) IRQ_CONNECT(CONFIG_GPIO_ESP32_IRQ, 1, gpio_esp32_isr, NULL, 0); - intr_matrix_set(0, ETS_GPIO_INTR_SOURCE, - CONFIG_GPIO_ESP32_IRQ); + esp32_rom_intr_matrix_set(0, ETS_GPIO_INTR_SOURCE, + CONFIG_GPIO_ESP32_IRQ); irq_enable(CONFIG_GPIO_ESP32_IRQ); diff --git a/drivers/serial/uart_esp32.c b/drivers/serial/uart_esp32.c index 58325a865f5..dd93de3e6bc 100644 --- a/drivers/serial/uart_esp32.c +++ b/drivers/serial/uart_esp32.c @@ -5,9 +5,9 @@ */ /* Include esp-idf headers first to avoid redefining BIT() macro */ -#include #include +#include #include #include @@ -16,7 +16,7 @@ static unsigned char esp32_uart_tx(struct device *dev, { ARG_UNUSED(dev); - uart_tx_one_char(c); + esp32_rom_uart_tx_one_char(c); return c; } @@ -25,7 +25,7 @@ static int esp32_uart_rx(struct device *dev, unsigned char *p_char) { ARG_UNUSED(dev); - switch (uart_rx_one_char(p_char)) { + switch (esp32_rom_uart_rx_one_char(p_char)) { case OK: return 0; case PENDING: @@ -43,7 +43,7 @@ static int esp32_uart_init(struct device *dev) { ARG_UNUSED(dev); - uartAttach(); + esp32_rom_uart_attach(); return 0; } diff --git a/drivers/watchdog/wdt_esp32.c b/drivers/watchdog/wdt_esp32.c index 7bf526b2947..2307805bc4e 100644 --- a/drivers/watchdog/wdt_esp32.c +++ b/drivers/watchdog/wdt_esp32.c @@ -5,10 +5,10 @@ */ /* Include esp-idf headers first to avoid redefining BIT() macro */ -#include #include #include +#include #include #include #include @@ -212,7 +212,8 @@ static int wdt_esp32_init(struct device *dev) * located in xtensa_vectors.S. */ irq_disable(CONFIG_WDT_ESP32_IRQ); - intr_matrix_set(0, ETS_TG1_WDT_LEVEL_INTR_SOURCE, CONFIG_WDT_ESP32_IRQ); + esp32_rom_intr_matrix_set(0, ETS_TG1_WDT_LEVEL_INTR_SOURCE, + CONFIG_WDT_ESP32_IRQ); return 0; }