mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 17:05:21 +01:00
Implement InterruptLock for RP2040 (#3945)
This commit is contained in:
parent
f2c4f018de
commit
f97252b93a
2 changed files with 7 additions and 4 deletions
|
@ -392,13 +392,16 @@ void hsv_to_rgb(int hue, float saturation, float value, float &red, float &green
|
||||||
// System APIs
|
// System APIs
|
||||||
|
|
||||||
#if defined(USE_ESP8266)
|
#if defined(USE_ESP8266)
|
||||||
IRAM_ATTR InterruptLock::InterruptLock() { xt_state_ = xt_rsil(15); }
|
IRAM_ATTR InterruptLock::InterruptLock() { state_ = xt_rsil(15); }
|
||||||
IRAM_ATTR InterruptLock::~InterruptLock() { xt_wsr_ps(xt_state_); }
|
IRAM_ATTR InterruptLock::~InterruptLock() { xt_wsr_ps(state_); }
|
||||||
#elif defined(USE_ESP32)
|
#elif defined(USE_ESP32)
|
||||||
// only affects the executing core
|
// only affects the executing core
|
||||||
// so should not be used as a mutex lock, only to get accurate timing
|
// so should not be used as a mutex lock, only to get accurate timing
|
||||||
IRAM_ATTR InterruptLock::InterruptLock() { portDISABLE_INTERRUPTS(); }
|
IRAM_ATTR InterruptLock::InterruptLock() { portDISABLE_INTERRUPTS(); }
|
||||||
IRAM_ATTR InterruptLock::~InterruptLock() { portENABLE_INTERRUPTS(); }
|
IRAM_ATTR InterruptLock::~InterruptLock() { portENABLE_INTERRUPTS(); }
|
||||||
|
#elif defined(USE_RP2040)
|
||||||
|
IRAM_ATTR InterruptLock::InterruptLock() { state_ = save_and_disable_interrupts(); }
|
||||||
|
IRAM_ATTR InterruptLock::~InterruptLock() { restore_interrupts(state_); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t HighFrequencyLoopRequester::num_requests = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
uint8_t HighFrequencyLoopRequester::num_requests = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
|
|
@ -542,8 +542,8 @@ class InterruptLock {
|
||||||
~InterruptLock();
|
~InterruptLock();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef USE_ESP8266
|
#if defined(USE_ESP8266) || defined(USE_RP2040)
|
||||||
uint32_t xt_state_;
|
uint32_t state_;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue