ESPHome 2026.2.3
Loading...
Searching...
No Matches
core.cpp
Go to the documentation of this file.
1#ifdef USE_ESP8266
2
3#include "core.h"
5#include "esphome/core/hal.h"
7#include "preferences.h"
8#include <Arduino.h>
9#include <core_esp8266_features.h>
10
11extern "C" {
12#include <user_interface.h>
13}
14
15namespace esphome {
16
17void IRAM_ATTR HOT yield() { ::yield(); }
18uint32_t IRAM_ATTR HOT millis() { return ::millis(); }
19void IRAM_ATTR HOT delay(uint32_t ms) { ::delay(ms); }
20uint32_t IRAM_ATTR HOT micros() { return ::micros(); }
21void IRAM_ATTR HOT delayMicroseconds(uint32_t us) { delay_microseconds_safe(us); }
22void arch_restart() {
23 system_restart();
24 // restart() doesn't always end execution
25 while (true) { // NOLINT(clang-diagnostic-unreachable-code)
26 yield();
27 }
28}
29void arch_init() {}
30void IRAM_ATTR HOT arch_feed_wdt() { system_soft_wdt_feed(); }
31
32uint8_t progmem_read_byte(const uint8_t *addr) {
33 return pgm_read_byte(addr); // NOLINT
34}
35uint32_t IRAM_ATTR HOT arch_get_cpu_cycle_count() { return esp_get_cycle_count(); }
36uint32_t arch_get_cpu_freq_hz() { return F_CPU; }
37
39 // Tasmota uses magic bytes in the binary to check if an OTA firmware is compatible
40 // with their settings - ESPHome uses a different settings system (that can also survive
41 // erases). So set magic bytes indicating all tasmota versions are supported.
42 // This only adds 12 bytes of binary size, which is an acceptable price to pay for easier support
43 // for Tasmota.
44 // https://github.com/arendst/Tasmota/blob/b05301b1497942167a015a6113b7f424e42942cd/tasmota/settings.ino#L346-L380
45 // https://github.com/arendst/Tasmota/blob/b05301b1497942167a015a6113b7f424e42942cd/tasmota/i18n.h#L652-L654
46 const static uint32_t TASMOTA_MAGIC_BYTES[] PROGMEM = {0x5AA55AA5, 0xFFFFFFFF, 0xA55AA55A};
47 // Force link symbol by using a volatile integer (GCC attribute used does not work because of LTO)
48 volatile int x = 0;
49 x = TASMOTA_MAGIC_BYTES[x];
50}
51
52extern "C" void resetPins() { // NOLINT
53 // Added in framework 2.7.0
54 // usually this sets up all pins to be in INPUT mode
55 // however, not strictly needed as we set up the pins properly
56 // ourselves and this causes pins to toggle during reboot.
58
59#ifdef USE_ESP8266_EARLY_PIN_INIT
60 for (int i = 0; i < 16; i++) {
63 if (mode != 255)
64 pinMode(i, mode); // NOLINT
65 if (level != 255)
66 digitalWrite(i, level); // NOLINT
67 }
68#endif
69}
70
71} // namespace esphome
72
73#endif // USE_ESP8266
BedjetMode mode
BedJet operating mode.
const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[16]
const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_MODE[16]
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint32_t arch_get_cpu_cycle_count()
Definition core.cpp:50
void arch_init()
Definition core.cpp:37
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
Definition core.cpp:28
void IRAM_ATTR HOT yield()
Definition core.cpp:24
uint32_t arch_get_cpu_freq_hz()
Definition core.cpp:51
uint32_t IRAM_ATTR HOT micros()
Definition core.cpp:27
void IRAM_ATTR HOT delay_microseconds_safe(uint32_t us)
Delay for the given amount of microseconds, possibly yielding to other processes during the wait.
Definition helpers.cpp:845
void IRAM_ATTR HOT arch_feed_wdt()
Definition core.cpp:47
void resetPins()
Definition core.cpp:52
void IRAM_ATTR HOT delay(uint32_t ms)
Definition core.cpp:26
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:25
void arch_restart()
Definition core.cpp:29
void force_link_symbols()
Definition core.cpp:38
uint8_t progmem_read_byte(const uint8_t *addr)
Definition core.cpp:49
uint16_t x
Definition tt21100.cpp:5
const uint8_t ESPHOME_WEBSERVER_INDEX_HTML[] PROGMEM
Definition web_server.h:27