Implement InterruptLock for RP2040 (#3945)

This commit is contained in:
Jesse Hills 2022-10-26 16:41:51 +13:00 committed by GitHub
parent f2c4f018de
commit f97252b93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -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)

View File

@ -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
}; };