mirror of
https://github.com/esphome/esphome.git
synced 2026-11-09 14:45:57 +00:00
[core] Inline InterruptLock on ESP8266 (#22455)
This commit is contained in:
1 parent
935befcbe5
commit
be0550b1e8
2 files changed
+7
-5
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user