Skip to content

Commit ed55ee9

Browse files
Felipe Nevescfriedt
authored andcommitted
boards: riscv: esp32c3: added button support
in samples for esp32c3 devkitm_board using GPIO9 Signed-off-by: Felipe Neves <[email protected]>
1 parent 9768e98 commit ed55ee9

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

boards/riscv/esp32c3_devkitm/esp32c3_devkitm.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
compatible = "gpio-keys";
2727
user_button1: button_1 {
2828
label = "User SW1";
29-
gpios = <&gpio0 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
29+
gpios = <&gpio0 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
3030
};
3131
};
3232
};

boards/riscv/esp32c3_devkitm/esp32c3_devkitm_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ CONFIG_XIP=n
1313
CONFIG_PINMUX=y
1414
CONFIG_PINMUX_ESP32=y
1515
CONFIG_GPIO=y
16-
CONFIG_GPIO_ESP32=y
16+
CONFIG_GPIO_ESP32=y

drivers/gpio/Kconfig.esp32

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ config GPIO_ESP32_0
1717
help
1818
Include support for GPIO pins 0-31 on the ESP32.
1919

20+
if !SOC_ESP32C3
21+
2022
config GPIO_ESP32_1
2123
bool "ESP32 GPIO (pins 32-39)"
22-
default y if SOC_ESP32 || SOC_ESP32S2
23-
default n if SOC_ESP32C3
24+
default y
2425
help
2526
Include support for GPIO pins 32-39 on the ESP32.
2627

28+
endif # SOC_ESP32C3
29+
2730
endif # GPIO_ESP32

drivers/gpio/gpio_esp32.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
#define DT_DRV_COMPAT espressif_esp32_gpio
99

1010
/* Include esp-idf headers first to avoid redefining BIT() macro */
11-
#ifndef CONFIG_SOC_ESP32C3
12-
#include <soc/dport_reg.h>
13-
#endif
1411
#include <soc/gpio_reg.h>
1512
#include <soc/io_mux_reg.h>
1613
#include <soc/soc.h>
1714
#include <hal/gpio_ll.h>
1815
#include <esp_attr.h>
1916

17+
#include <soc.h>
2018
#include <errno.h>
2119
#include <device.h>
2220
#include <drivers/gpio.h>
@@ -37,15 +35,15 @@ LOG_MODULE_REGISTER(gpio_esp32, CONFIG_LOG_DEFAULT_LEVEL);
3735
#define DEV_CFG(_dev) ((struct gpio_esp32_config *const)(_dev)->config)
3836

3937
#ifdef CONFIG_SOC_ESP32C3
40-
/* gpio structs in esp32c3 series are diferent from xtensa ones */
38+
/* gpio structs in esp32c3 series are different from xtensa ones */
4139
#define out out.data
4240
#define in in.data
4341
#define out_w1ts out_w1ts.val
4442
#define out_w1tc out_w1tc.val
4543
/* arch_curr_cpu() is not available for riscv based chips */
4644
#define CPU_ID() 0
4745
#define ISR_HANDLER isr_handler_t
48-
#else
46+
#else
4947
#define CPU_ID() arch_curr_cpu()->id
5048
#define ISR_HANDLER intr_handler_t
5149
#endif
@@ -293,6 +291,7 @@ static int gpio_esp32_pin_interrupt_configure(const struct device *port,
293291

294292
key = irq_lock();
295293
gpio_ll_set_intr_type(cfg->gpio_base, io_pin, intr_trig_mode);
294+
gpio_ll_intr_enable_on_core(cfg->gpio_base, CPU_ID(), io_pin);
296295
irq_unlock(key);
297296

298297
return 0;
@@ -357,7 +356,12 @@ static int gpio_esp32_init(const struct device *dev)
357356
}
358357

359358
if (!isr_connected) {
360-
esp_intr_alloc(DT_IRQN(DT_NODELABEL(gpio0)), 0, (ISR_HANDLER)gpio_esp32_isr, (void *)dev, NULL);
359+
esp_intr_alloc(DT_IRQN(DT_NODELABEL(gpio0)),
360+
0,
361+
(ISR_HANDLER)gpio_esp32_isr,
362+
(void *)dev,
363+
NULL);
364+
361365
isr_connected = true;
362366
}
363367

dts/riscv/espressif/esp32c3.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
pinmux: pinmux@60009000 {
4040
compatible = "espressif,esp32-pinmux";
41-
reg = <0x60009000 0x94>;
41+
reg = <0x60009000 0x800>;
4242
};
4343

4444
intc: interrupt-controller@600c2000 {

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ manifest:
6262
groups:
6363
- hal
6464
- name: hal_espressif
65-
revision: 2f438dfde14900d35bf703ddc4c0f71efc0d065f
65+
revision: 051266aafbd966825bad1d9b5ab98e8bed45b918
6666
path: modules/hal/espressif
6767
west-commands: west/west-commands.yml
6868
groups:

0 commit comments

Comments
 (0)