ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
hal.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_HOST
4
5#include <cstdint>
6#include <pthread.h>
7#include <sched.h>
8
9#define IRAM_ATTR
10#define PROGMEM
11
12namespace esphome::host {}
13
14namespace esphome {
15
18__attribute__((always_inline)) inline bool in_isr_context() { return false; }
19
20inline pthread_t &main_loop_thread() {
21 static pthread_t thread{};
22 return thread;
23}
24
26__attribute__((always_inline)) inline bool is_main_loop_thread() {
27 return pthread_equal(pthread_self(), main_loop_thread()) != 0;
28}
29
30__attribute__((always_inline)) inline void yield() { ::sched_yield(); }
31
32void delay(uint32_t ms);
35uint64_t millis_64();
36void delayMicroseconds(uint32_t us); // NOLINT(readability-identifier-naming)
38
39__attribute__((always_inline)) inline void arch_init() { main_loop_thread() = pthread_self(); }
40__attribute__((always_inline)) inline void arch_feed_wdt() {}
41__attribute__((always_inline)) inline uint32_t arch_get_cpu_freq_hz() { return 1000000000U; }
42
43} // namespace esphome
44
45#endif // USE_HOST
struct @66::@67 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:45
void yield(void)
uint32_t arch_get_cpu_cycle_count()
Definition hal.cpp:71
void arch_init()
Definition hal.cpp:44
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
Definition hal.cpp:48
pthread_t & main_loop_thread()
Definition hal.h:20
uint32_t arch_get_cpu_freq_hz()
Definition hal.cpp:55
uint64_t millis_64()
Definition hal.cpp:29
uint32_t IRAM_ATTR HOT micros()
Definition hal.cpp:43
void arch_feed_wdt()
Definition hal.cpp:58
void HOT delay(uint32_t ms)
Definition hal.cpp:85
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:25
static void uint32_t