mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 23:28:13 +00:00
fix
This commit is contained in:
parent
9dc38ea5e3
commit
292d0259d9
@ -22,6 +22,7 @@
|
|||||||
#endif // USE_ESP_IDF
|
#endif // USE_ESP_IDF
|
||||||
|
|
||||||
#ifdef USE_ZEPHYR
|
#ifdef USE_ZEPHYR
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
struct device;
|
struct device;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
15
esphome/components/zephyr/helpers.cpp
Normal file
15
esphome/components/zephyr/helpers.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "esphome/core/helpers.h"
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
Mutex::Mutex() {
|
||||||
|
auto mutex = new k_mutex();
|
||||||
|
this->handle_ = mutex;
|
||||||
|
k_mutex_init(mutex);
|
||||||
|
}
|
||||||
|
Mutex::~Mutex() { delete static_cast<k_mutex *>(this->handle_); }
|
||||||
|
void Mutex::lock() { k_mutex_lock(static_cast<k_mutex *>(this->handle_), K_FOREVER); }
|
||||||
|
bool Mutex::try_lock() { return k_mutex_lock(static_cast<k_mutex *>(this->handle_), K_NO_WAIT) == 0; }
|
||||||
|
void Mutex::unlock() { k_mutex_unlock(static_cast<k_mutex *>(this->handle_)); }
|
||||||
|
uint32_t random_uint32() { return rand(); }
|
||||||
|
} // namespace esphome
|
@ -1,5 +1,6 @@
|
|||||||
#ifdef USE_ZEPHYR
|
#ifdef USE_ZEPHYR
|
||||||
|
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
#include "esphome/core/preferences.h"
|
#include "esphome/core/preferences.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include <zephyr/settings/settings.h>
|
#include <zephyr/settings/settings.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user