add delayMicroseconds (and other functions in esphome/core/hal.h

This commit is contained in:
Tomasz Duda 2024-07-22 11:57:41 +02:00
parent 9d57c9897c
commit 487cf39101

View file

@ -1,4 +1,4 @@
#ifdef USE_ZEPHYR
#if 1
#include <zephyr/kernel.h>
#include <zephyr/drivers/watchdog.h>
@ -11,8 +11,9 @@ const device *wdt = nullptr;
void yield() { ::k_yield(); }
uint32_t millis() { return k_ticks_to_ms_floor32(k_uptime_ticks()); }
void delay(uint32_t ms) { ::k_msleep(ms); }
uint32_t micros() { return k_ticks_to_us_floor32(k_uptime_ticks()); }
void delayMicroseconds(uint32_t us) { ::k_usleep(us); }
void delay(uint32_t ms) { ::k_msleep(ms); }
void arch_init() {
wdt = DEVICE_DT_GET(DT_ALIAS(watchdog0));
@ -35,6 +36,9 @@ void arch_feed_wdt() {
}
void arch_restart() { sys_reboot(SYS_REBOOT_COLD); }
uint32_t arch_get_cpu_cycle_count() { return k_cycle_get_32(); }
uint32_t arch_get_cpu_freq_hz() { return sys_clock_hw_cycles_per_sec(); }
uint8_t progmem_read_byte(const uint8_t *addr) { return *addr; }
} // namespace esphome