From d7bac619ec0e4ce7cb89d6ff54258e788d280dc4 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 19 Jan 2021 23:34:27 +0100 Subject: [PATCH] freertos: stall systimer while CPU is in debug mode --- components/freertos/port/riscv/port.c | 1 + components/hal/esp32c3/systimer_hal.c | 5 +++++ components/hal/include/hal/systimer_hal.h | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/components/freertos/port/riscv/port.c b/components/freertos/port/riscv/port.c index 82e1d40fa3..718c1c4d8b 100644 --- a/components/freertos/port/riscv/port.c +++ b/components/freertos/port/riscv/port.c @@ -154,6 +154,7 @@ void vPortSetupTimer(void) 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); systimer_hal_set_alarm_period(SYSTIMER_ALARM_0, 1000000UL / CONFIG_FREERTOS_HZ); systimer_hal_select_alarm_mode(SYSTIMER_ALARM_0, SYSTIMER_ALARM_MODE_PERIOD); systimer_hal_enable_alarm_int(SYSTIMER_ALARM_0); diff --git a/components/hal/esp32c3/systimer_hal.c b/components/hal/esp32c3/systimer_hal.c index 9270e0eae0..c01ff909ac 100644 --- a/components/hal/esp32c3/systimer_hal.c +++ b/components/hal/esp32c3/systimer_hal.c @@ -121,3 +121,8 @@ void systimer_hal_connect_alarm_counter(systimer_alarm_id_t alarm_id, systimer_c { systimer_ll_connect_alarm_counter(alarm_id, counter_id); } + +void systimer_hal_counter_can_stall_by_cpu(uint32_t counter_id, uint32_t cpu_id, bool can) +{ + systimer_ll_counter_can_stall_by_cpu(counter_id, cpu_id, can); +} diff --git a/components/hal/include/hal/systimer_hal.h b/components/hal/include/hal/systimer_hal.h index 1c3dba3958..1f4eb5c488 100644 --- a/components/hal/include/hal/systimer_hal.h +++ b/components/hal/include/hal/systimer_hal.h @@ -19,6 +19,7 @@ extern "C" { #endif #include +#include #include "hal/systimer_types.h" /** @@ -81,6 +82,11 @@ void systimer_hal_init(void); */ void systimer_hal_connect_alarm_counter(systimer_alarm_id_t alarm_id, systimer_counter_id_t counter_id); +/** + * @brief set if a counter should be stalled when CPU is halted by the debugger + */ +void systimer_hal_counter_can_stall_by_cpu(uint32_t counter_id, uint32_t cpu_id, bool can); + #ifdef __cplusplus } #endif