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