mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
rp2040: Use fake Mutex lock (#4602)
This commit is contained in:
parent
a3875af4b4
commit
db5988bbe1
2 changed files with 3 additions and 6 deletions
|
@ -393,13 +393,13 @@ 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) || defined(USE_RP2040)
|
||||||
// ESP8266 doesn't have mutexes, but that shouldn't be an issue as it's single-core and non-preemptive OS.
|
// ESP8266 doesn't have mutexes, but that shouldn't be an issue as it's single-core and non-preemptive OS.
|
||||||
Mutex::Mutex() {}
|
Mutex::Mutex() {}
|
||||||
void Mutex::lock() {}
|
void Mutex::lock() {}
|
||||||
bool Mutex::try_lock() { return true; }
|
bool Mutex::try_lock() { return true; }
|
||||||
void Mutex::unlock() {}
|
void Mutex::unlock() {}
|
||||||
#elif defined(USE_ESP32) || defined(USE_RP2040)
|
#elif defined(USE_ESP32)
|
||||||
Mutex::Mutex() { handle_ = xSemaphoreCreateMutex(); }
|
Mutex::Mutex() { handle_ = xSemaphoreCreateMutex(); }
|
||||||
void Mutex::lock() { xSemaphoreTake(this->handle_, portMAX_DELAY); }
|
void Mutex::lock() { xSemaphoreTake(this->handle_, portMAX_DELAY); }
|
||||||
bool Mutex::try_lock() { return xSemaphoreTake(this->handle_, 0) == pdTRUE; }
|
bool Mutex::try_lock() { return xSemaphoreTake(this->handle_, 0) == pdTRUE; }
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
#if defined(USE_ESP32)
|
#if defined(USE_ESP32)
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/semphr.h>
|
#include <freertos/semphr.h>
|
||||||
#elif defined(USE_RP2040)
|
|
||||||
#include <FreeRTOS.h>
|
|
||||||
#include <semphr.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HOT __attribute__((hot))
|
#define HOT __attribute__((hot))
|
||||||
|
@ -539,7 +536,7 @@ class Mutex {
|
||||||
Mutex &operator=(const Mutex &) = delete;
|
Mutex &operator=(const Mutex &) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(USE_ESP32) || defined(USE_RP2040)
|
#if defined(USE_ESP32)
|
||||||
SemaphoreHandle_t handle_;
|
SemaphoreHandle_t handle_;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue