ESPHome
2026.11.0-dev
Loading...
Searching...
No Matches
esphome
components
esp32
hal.h
Go to the documentation of this file.
1
#pragma once
2
3
#ifdef USE_ESP32
4
5
#include <cstdint>
6
#include <esp_attr.h>
7
#include <esp_cpu.h>
8
#include <esp_task_wdt.h>
9
#include <freertos/FreeRTOS.h>
10
#include <freertos/task.h>
11
12
#include "
esphome/core/main_task.h
"
13
#include "
esphome/core/time_conversion.h
"
14
15
#ifndef PROGMEM
16
#define PROGMEM
17
#endif
18
19
namespace
esphome::esp32
{}
20
21
namespace
esphome
{
22
23
// Forward decl from helpers.h (esphome/core/helpers.h) — kept here so this
24
// header does not need to pull the rest of helpers.h.
25
// NOLINTNEXTLINE(readability-redundant-declaration)
26
void
delay_microseconds_safe
(
uint32_t
us);
27
29
__attribute__
((always_inline))
inline
bool
in_isr_context() {
return
xPortInIsrContext() != 0; }
30
31
// Forward decl from <esp_timer.h>.
32
// NOLINTNEXTLINE(readability-redundant-declaration)
33
extern
"C"
int64_t
esp_timer_get_time
(
void
);
34
36
__attribute__
((always_inline))
inline
bool
is_main_loop_thread() {
37
return
xTaskGetCurrentTaskHandle() ==
esphome_main_task_handle
;
38
}
39
__attribute__
((always_inline))
inline
void
yield
() { vPortYield(); }
40
__attribute__
((always_inline))
inline
void
delay
(
uint32_t
ms) { vTaskDelay(ms / portTICK_PERIOD_MS); }
41
__attribute__
((always_inline))
inline
uint32_t
micros
() {
return
static_cast<
uint32_t
>
(
esp_timer_get_time
()); }
42
uint32_t
millis
();
43
__attribute__
((always_inline))
inline
uint64_t
millis_64
() {
44
return
micros_to_millis<uint64_t>(
static_cast<
uint64_t
>
(
esp_timer_get_time
()));
45
}
46
47
// NOLINTNEXTLINE(readability-identifier-naming)
48
__attribute__
((always_inline))
inline
void
delayMicroseconds
(
uint32_t
us) {
delay_microseconds_safe
(us); }
49
__attribute__
((always_inline))
inline
void
arch_feed_wdt
() { esp_task_wdt_reset(); }
50
__attribute__
((always_inline))
inline
uint32_t
arch_get_cpu_cycle_count
() {
return
esp_cpu_get_cycle_count(); }
51
52
void
arch_init
();
53
uint32_t
arch_get_cpu_freq_hz
();
54
55
}
// namespace esphome
56
57
#endif
// USE_ESP32
__attribute__
struct @66::@67 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition
main_task.h:45
yield
void yield(void)
esphome_main_task_handle
TaskHandle_t esphome_main_task_handle
Main loop task handle and wake helpers — shared between wake.h (C++) and lwip_fast_select....
Definition
main_task.c:4
main_task.h
esphome::esp32
Definition
atexit_stubs.cpp:14
esphome
Definition
a01nyub.cpp:7
esphome::arch_get_cpu_cycle_count
uint32_t arch_get_cpu_cycle_count()
Definition
hal.cpp:71
esphome::arch_init
void arch_init()
Definition
hal.cpp:44
esphome::delayMicroseconds
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
Definition
hal.cpp:48
esphome::arch_get_cpu_freq_hz
uint32_t arch_get_cpu_freq_hz()
Definition
hal.cpp:55
esphome::millis_64
uint64_t millis_64()
Definition
hal.cpp:29
esphome::micros
uint32_t IRAM_ATTR HOT micros()
Definition
hal.cpp:43
esphome::delay_microseconds_safe
void delay_microseconds_safe(uint32_t us)
Delay for the given amount of microseconds, possibly yielding to other processes during the wait.
Definition
helpers.cpp:889
esphome::arch_feed_wdt
void arch_feed_wdt()
Definition
hal.cpp:58
esphome::delay
void HOT delay(uint32_t ms)
Definition
hal.cpp:85
esphome::millis
uint32_t IRAM_ATTR HOT millis()
Definition
hal.cpp:25
esphome::esp_timer_get_time
int64_t esp_timer_get_time(void)
uint32_t
static void uint32_t
Definition
crash_handler.cpp:153
time_conversion.h
Generated by
1.12.0