diff --git a/hal/api/SPI.h b/hal/api/SPI.h index c2b04ed3549..d44c3dc693a 100644 --- a/hal/api/SPI.h +++ b/hal/api/SPI.h @@ -21,6 +21,7 @@ #if DEVICE_SPI #include "spi_api.h" +#include "SingletonPtr.h" #if DEVICE_SPI_ASYNCH #include "CThunk.h" @@ -246,7 +247,7 @@ class SPI { void aquire(void); static SPI *_owner; - PlatformMutex _mutex; + static SingletonPtr _mutex; int _bits; int _mode; int _hz; diff --git a/hal/common/SPI.cpp b/hal/common/SPI.cpp index d3feefe3817..8cc919dc2a9 100644 --- a/hal/common/SPI.cpp +++ b/hal/common/SPI.cpp @@ -57,6 +57,7 @@ void SPI::frequency(int hz) { } SPI* SPI::_owner = NULL; +SingletonPtr SPI::_mutex; // ignore the fact there are multiple physical spis, and always update if it wasnt us last void SPI::aquire() { @@ -78,11 +79,11 @@ int SPI::write(int value) { } void SPI::lock() { - _mutex.lock(); + _mutex->lock(); } void SPI::unlock() { - _mutex.unlock(); + _mutex->unlock(); } #if DEVICE_SPI_ASYNCH