west.yml: update hal to v4.4.1 base
west.yml: update hal_espressif to use latest v4.4.1 updates.
This change needs to be insync with esp32c3 timer changes, otherwise it
breaks it.
drivers: timer: update esp32c3 systimer to meet API changes.
Systimer API was refactored in hal v4.4.1, which
requires updates in esp32C3 systimer. Timer behavior is maintained
as is.
mcpwm: add v4.4.1 include reference, which was refactored as well.
driver: spi: esp32: update internal structs to meet API changes.
cmake: updated esp32 board to use HAL_ prefix as from west blobs
requirement.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
diff --git a/drivers/timer/esp32c3_sys_timer.c b/drivers/timer/esp32c3_sys_timer.c
index bc8a7e7..7fb3e71 100644
--- a/drivers/timer/esp32c3_sys_timer.c
+++ b/drivers/timer/esp32c3_sys_timer.c
@@ -34,25 +34,30 @@
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 @@
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 @@
}
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_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 @@
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;
}