ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
hal.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <cstdint>
4#include "gpio.h"
8
9// Per-platform HAL bits (IRAM_ATTR / PROGMEM macros, in_isr_context(),
10// inline yield/delay/micros/millis/millis_64 wrappers, ESP8266 progmem
11// helpers) live next to each platform component as components/<platform>/hal.h
12// and are dispatched here based on the active USE_* platform define. Each
13// header guards its body with the matching #ifdef USE_<platform> and re-enters
14// namespace esphome {} so it is safe to be re-included.
15#if defined(USE_ESP32)
17#elif defined(USE_ESP8266)
19#elif defined(USE_LIBRETINY)
21#elif defined(USE_RP2040)
23#elif defined(USE_HOST)
25#elif defined(USE_ZEPHYR)
27#else
28#error "hal.h: not implemented for this platform"
29#endif
30
31namespace esphome {
32
33// Cross-platform declarations. delayMicroseconds(), arch_feed_wdt(),
34// arch_get_cpu_cycle_count(), arch_init(), arch_get_cpu_freq_hz() vary
35// per platform (some inline, some out-of-line) so they live in
36// components/<platform>/hal.h.
37void __attribute__((noreturn)) arch_restart();
38
39#ifndef USE_ESP8266
40// All non-ESP8266 platforms: PROGMEM is a no-op, so these are direct dereferences.
41// ESP8266's out-of-line declarations live in components/esp8266/hal.h.
42inline uint8_t progmem_read_byte(const uint8_t *addr) { return *addr; }
43inline const char *progmem_read_ptr(const char *const *addr) { return *addr; }
44inline uint16_t progmem_read_uint16(const uint16_t *addr) { return *addr; }
45#endif
46
47} // namespace esphome
struct @65::@66 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:32
const char * progmem_read_ptr(const char *const *addr)
Definition hal.h:43
uint16_t progmem_read_uint16(const uint16_t *addr)
Definition hal.h:44
void arch_restart()
Definition hal.cpp:39
uint8_t progmem_read_byte(const uint8_t *addr)
Definition hal.h:42