[core] Inline InterruptLock on ESP8266 (#22455)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2026-11-09 09:23:06 -05:00
1 parent 935befcbe5
commit be0550b1e8
2 files changed
+7 -5

No files matched your search

-5
View File
@@ -4,8 +4,6 @@
#include <osapi.h>
#include <user_interface.h>
// for xt_rsil()/xt_wsr_ps()
#include <Arduino.h>
namespace esphome {
@@ -15,9 +13,6 @@ bool random_bytes(uint8_t *data, size_t len) { return os_get_random(data, len) =
// ESP8266 Mutex is defined inline as a no-op in helpers.h when USE_ESP8266 (or USE_RP2) is set,
// independent of the ESPHOME_THREAD_SINGLE thread model define.
IRAM_ATTR InterruptLock::InterruptLock() { state_ = xt_rsil(15); }
IRAM_ATTR InterruptLock::~InterruptLock() { xt_wsr_ps(state_); }
// ESP8266 LwIPLock is defined inline as a no-op in helpers.h
void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parameter)
+7
View File
@@ -29,6 +29,7 @@
#ifdef USE_ESP8266
#include <Esp.h>
#include <core_esp8266_features.h> // xt_rsil, xt_wsr_ps
#include <pgmspace.h>
#endif
@@ -2319,8 +2320,14 @@ class LockGuard {
*/
class InterruptLock {
public:
#ifdef USE_ESP8266
// Inline: saves two calls per lock, and the lock sits on bit-banged timing paths
ESPHOME_ALWAYS_INLINE InterruptLock() : state_(xt_rsil(15)) {}
ESPHOME_ALWAYS_INLINE ~InterruptLock() { xt_wsr_ps(this->state_); }
#else
InterruptLock();
~InterruptLock();
#endif
protected:
#if defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_ZEPHYR)