From 39ef904fba764e8cc4d894d70a8f59f0922fcf0c Mon Sep 17 00:00:00 2001 From: Renz Bagaporo Date: Tue, 3 Mar 2020 12:10:38 +0800 Subject: [PATCH] soc: introduce hal function for cpu delay --- components/soc/include/hal/cpu_hal.h | 7 +++++++ components/soc/src/hal/cpu_hal.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/components/soc/include/hal/cpu_hal.h b/components/soc/include/hal/cpu_hal.h index 7584aa407..d5c81f4b6 100644 --- a/components/soc/include/hal/cpu_hal.h +++ b/components/soc/include/hal/cpu_hal.h @@ -107,6 +107,13 @@ void cpu_hal_set_watchpoint(int id, const void* addr, size_t size, watchpoint_tr */ void cpu_hal_clear_watchpoint(int id); +/* + * Insert a delay. + * + * @param delay_us length of delay in microseconds + */ +void cpu_hal_delay_us(uint32_t delay_us); + #endif // SOC_CPU_WATCHPOINTS_NUM > 0 /** diff --git a/components/soc/src/hal/cpu_hal.c b/components/soc/src/hal/cpu_hal.c index 1da4ff29a..98f918f7c 100644 --- a/components/soc/src/hal/cpu_hal.c +++ b/components/soc/src/hal/cpu_hal.c @@ -22,6 +22,14 @@ #include "soc/cpu_caps.h" +#include "sdkconfig.h" + +#if CONFIG_IDF_TARGET_ESP32 +#include "esp32/rom/ets_sys.h" +#elif CONFIG_IDF_TARGET_ESP32S2 +#include "esp32s2/rom/ets_sys.h" +#endif + #if SOC_CPU_BREAKPOINTS_NUM > 0 void cpu_hal_set_breakpoint(int id, const void* addr) { @@ -60,3 +68,8 @@ void cpu_hal_set_vecbase(const void* base) { cpu_ll_set_vecbase(base); } + +void cpu_hal_delay_us(uint32_t delay_us) +{ + ets_delay_us(delay_us); +} \ No newline at end of file