mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-14 23:02:53 +00:00
* Don't use assert for Lock * Don't use assert for MQTT messages * Split assert in getMacAddr to always run the function --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
39 lines
547 B
C++
39 lines
547 B
C++
#include "Lock.h"
|
|
#include "configuration.h"
|
|
#include <cassert>
|
|
|
|
namespace concurrency
|
|
{
|
|
|
|
#ifdef HAS_FREE_RTOS
|
|
Lock::Lock() : handle(xSemaphoreCreateBinary())
|
|
{
|
|
assert(handle);
|
|
if (xSemaphoreGive(handle) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
|
|
void Lock::lock()
|
|
{
|
|
if (xSemaphoreTake(handle, portMAX_DELAY) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
|
|
void Lock::unlock()
|
|
{
|
|
if (xSemaphoreGive(handle) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
#else
|
|
Lock::Lock() {}
|
|
|
|
void Lock::lock() {}
|
|
|
|
void Lock::unlock() {}
|
|
#endif
|
|
|
|
} // namespace concurrency
|