diff --git a/boards/common/esp32.board.cmake b/boards/common/esp32.board.cmake index 5b726d8768..ee5bb0d6c3 100644 --- a/boards/common/esp32.board.cmake +++ b/boards/common/esp32.board.cmake @@ -10,7 +10,7 @@ board_runner_args(openocd --gdb-init "flushregs") board_runner_args(openocd --gdb-init "mon reset halt") board_runner_args(openocd --gdb-init "thb main") -set(ESP_IDF_PATH ${ZEPHYR_ESPRESSIF_MODULE_DIR}) +set(ESP_IDF_PATH ${ZEPHYR_HAL_ESPRESSIF_MODULE_DIR}) assert(ESP_IDF_PATH "ESP_IDF_PATH is not set") board_finalize_runner_args(esp32 "--esp-idf-path=${ESP_IDF_PATH}") diff --git a/drivers/pwm/pwm_mc_esp32.c b/drivers/pwm/pwm_mc_esp32.c index a9920d1323..6412d5f95d 100644 --- a/drivers/pwm/pwm_mc_esp32.c +++ b/drivers/pwm/pwm_mc_esp32.c @@ -8,6 +8,7 @@ #include #include +#include "driver/mcpwm.h" #include #include diff --git a/drivers/spi/spi_esp32_spim.c b/drivers/spi/spi_esp32_spim.c index 43438e1bf0..b69fa95394 100644 --- a/drivers/spi/spi_esp32_spim.c +++ b/drivers/spi/spi_esp32_spim.c @@ -131,24 +131,24 @@ static int spi_esp32_init(const struct device *dev) return 0; } -static inline spi_ll_io_mode_t spi_esp32_get_io_mode(uint16_t operation) +static inline uint8_t spi_esp32_get_line_mode(uint16_t operation) { if (IS_ENABLED(CONFIG_SPI_EXTENDED_MODES)) { switch (operation & SPI_LINES_MASK) { case SPI_LINES_SINGLE: - return SPI_LL_IO_MODE_NORMAL; + return 1; case SPI_LINES_DUAL: - return SPI_LL_IO_MODE_DUAL; + return 2; case SPI_LINES_OCTAL: - return SPI_LL_IO_MODE_QIO; + return 8; case SPI_LINES_QUAD: - return SPI_LL_IO_MODE_QUAD; + return 4; default: break; } } - return SPI_LL_IO_MODE_NORMAL; + return 1; } static int IRAM_ATTR spi_esp32_configure(const struct device *dev, @@ -206,6 +206,7 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev, .duty_cycle = cfg->duty_cycle == 0 ? 128 : cfg->duty_cycle, .input_delay_ns = cfg->input_delay_ns, .use_gpio = !cfg->use_iomux, + }; spi_hal_cal_clock_conf(&timing_param, &freq, &hal_dev->timing_conf); @@ -215,7 +216,14 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev, hal_dev->tx_lsbfirst = spi_cfg->operation & SPI_TRANSFER_LSB ? 1 : 0; hal_dev->rx_lsbfirst = spi_cfg->operation & SPI_TRANSFER_LSB ? 1 : 0; - data->trans_config.io_mode = spi_esp32_get_io_mode(spi_cfg->operation); + data->trans_config.line_mode.data_lines = spi_esp32_get_line_mode(spi_cfg->operation); + + /* multiline for command and address not supported */ + data->trans_config.line_mode.addr_lines = 1; + data->trans_config.line_mode.cmd_lines = 1; + + /* keep cs line after transmission not supported */ + data->trans_config.cs_keep_active = 0; /* SPI mode */ hal_dev->mode = 0; diff --git a/drivers/timer/esp32c3_sys_timer.c b/drivers/timer/esp32c3_sys_timer.c index bc8a7e751e..7fb3e71bcd 100644 --- a/drivers/timer/esp32c3_sys_timer.c +++ b/drivers/timer/esp32c3_sys_timer.c @@ -34,25 +34,30 @@ const int32_t z_sys_timer_irq_for_test = DT_IRQN(DT_NODELABEL(systimer0)); static struct k_spinlock lock; static uint64_t last_count; +/* Systimer HAL layer object */ +static systimer_hal_context_t systimer_hal; + static void set_systimer_alarm(uint64_t time) { - systimer_hal_select_alarm_mode(SYSTIMER_ALARM_0, SYSTIMER_ALARM_MODE_ONESHOT); - systimer_hal_set_alarm_target(SYSTIMER_ALARM_0, time); - systimer_hal_enable_alarm_int(SYSTIMER_ALARM_0); + systimer_hal_select_alarm_mode(&systimer_hal, + SYSTIMER_LL_ALARM_OS_TICK_CORE0, SYSTIMER_ALARM_MODE_ONESHOT); + + systimer_hal_set_alarm_target(&systimer_hal, SYSTIMER_LL_ALARM_OS_TICK_CORE0, time); + systimer_hal_enable_alarm_int(&systimer_hal, SYSTIMER_LL_ALARM_OS_TICK_CORE0); } -static uint64_t systimer_alarm(void) +static uint64_t get_systimer_alarm(void) { - return systimer_hal_get_time(SYSTIMER_COUNTER_1); + return systimer_hal_get_time(&systimer_hal, SYSTIMER_LL_COUNTER_OS_TICK); } static void sys_timer_isr(const void *arg) { ARG_UNUSED(arg); - systimer_ll_clear_alarm_int(SYSTIMER_ALARM_0); + systimer_ll_clear_alarm_int(systimer_hal.dev, SYSTIMER_LL_ALARM_OS_TICK_CORE0); k_spinlock_key_t key = k_spin_lock(&lock); - uint64_t now = systimer_alarm(); + uint64_t now = get_systimer_alarm(); uint32_t dticks = (uint32_t)((now - last_count) / CYC_PER_TICK); @@ -80,7 +85,7 @@ void sys_clock_set_timeout(int32_t ticks, bool idle) ticks = CLAMP(ticks - 1, 0, (int32_t)MAX_TICKS); k_spinlock_key_t key = k_spin_lock(&lock); - uint64_t now = systimer_alarm(); + uint64_t now = get_systimer_alarm(); uint32_t adj, cyc = ticks * CYC_PER_TICK; /* Round up to next tick boundary. */ @@ -108,7 +113,7 @@ uint32_t sys_clock_elapsed(void) } k_spinlock_key_t key = k_spin_lock(&lock); - uint32_t ret = ((uint32_t)systimer_alarm() - (uint32_t)last_count) / CYC_PER_TICK; + uint32_t ret = ((uint32_t)get_systimer_alarm() - (uint32_t)last_count) / CYC_PER_TICK; k_spin_unlock(&lock, key); return ret; @@ -116,12 +121,12 @@ uint32_t sys_clock_elapsed(void) uint32_t sys_clock_cycle_get_32(void) { - return (uint32_t)systimer_alarm(); + return (uint32_t)get_systimer_alarm(); } uint64_t sys_clock_cycle_get_64(void) { - return systimer_alarm(); + return get_systimer_alarm(); } static int sys_clock_driver_init(const struct device *dev) @@ -134,13 +139,14 @@ static int sys_clock_driver_init(const struct device *dev) NULL, NULL); - systimer_hal_init(); - systimer_hal_connect_alarm_counter(SYSTIMER_ALARM_0, SYSTIMER_COUNTER_1); - systimer_hal_enable_counter(SYSTIMER_COUNTER_1); - systimer_hal_counter_can_stall_by_cpu(SYSTIMER_COUNTER_1, 0, true); - last_count = systimer_alarm(); - set_systimer_alarm(last_count + CYC_PER_TICK); + systimer_hal_init(&systimer_hal); + systimer_hal_connect_alarm_counter(&systimer_hal, + SYSTIMER_LL_ALARM_OS_TICK_CORE0, SYSTIMER_LL_COUNTER_OS_TICK); + systimer_hal_enable_counter(&systimer_hal, SYSTIMER_LL_COUNTER_OS_TICK); + systimer_hal_counter_can_stall_by_cpu(&systimer_hal, SYSTIMER_LL_COUNTER_OS_TICK, 0, true); + last_count = get_systimer_alarm(); + set_systimer_alarm(last_count + CYC_PER_TICK); return 0; } diff --git a/west.yml b/west.yml index 2f54953193..e4ea5da409 100644 --- a/west.yml +++ b/west.yml @@ -62,7 +62,7 @@ manifest: groups: - hal - name: hal_espressif - revision: a85cf740929b7537e0bb07572b6c4f3456b04420 + revision: 1e29548e4492807eb18cbaa77d3e78801cc7d07e path: modules/hal/espressif west-commands: west/west-commands.yml groups: