mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-31 02:45:41 +00:00
remove unnecessary lock
This commit is contained in:
parent
802c2fa7ae
commit
1d2a5c0692
@ -1,57 +1,12 @@
|
|||||||
#include "SPILock.h"
|
#include "SPILock.h"
|
||||||
#include "PowerFSM.h"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "sleep.h"
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
concurrency::Lock *spiLock;
|
concurrency::Lock *spiLock;
|
||||||
|
|
||||||
class SPILock : public concurrency::Lock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SPILock();
|
|
||||||
~SPILock();
|
|
||||||
|
|
||||||
void lock() override;
|
|
||||||
void unlock() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool locked;
|
|
||||||
|
|
||||||
int preflightSleepCb(void *unused = NULL) { return locked ? 1 : 0; }
|
|
||||||
|
|
||||||
CallbackObserver<SPILock, void *> preflightSleepObserver =
|
|
||||||
CallbackObserver<SPILock, void *>(this, &SPILock::preflightSleepCb);
|
|
||||||
};
|
|
||||||
|
|
||||||
SPILock::SPILock() : Lock()
|
|
||||||
{
|
|
||||||
locked = false;
|
|
||||||
preflightSleepObserver.observe(&preflightSleep);
|
|
||||||
}
|
|
||||||
|
|
||||||
SPILock::~SPILock()
|
|
||||||
{
|
|
||||||
preflightSleepObserver.unobserve(&preflightSleep);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SPILock::lock()
|
|
||||||
{
|
|
||||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
|
||||||
|
|
||||||
Lock::lock();
|
|
||||||
locked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SPILock::unlock()
|
|
||||||
{
|
|
||||||
locked = false;
|
|
||||||
Lock::unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void initSPI()
|
void initSPI()
|
||||||
{
|
{
|
||||||
assert(!spiLock);
|
assert(!spiLock);
|
||||||
spiLock = new SPILock();
|
spiLock = new concurrency::Lock();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user