[HAL] Modified SPI to use shared mutex

Modified the SPI class to use a shared mutex for all instances. This is
consistent with I2C and others.
pull/2297/head
neilt6 2016-07-28 08:57:59 -06:00
parent 36468c9acb
commit e80b16628d
2 changed files with 5 additions and 3 deletions

View File

@ -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 @@ protected:
void aquire(void);
static SPI *_owner;
PlatformMutex _mutex;
static SingletonPtr<PlatformMutex> _mutex;
int _bits;
int _mode;
int _hz;

View File

@ -57,6 +57,7 @@ void SPI::frequency(int hz) {
}
SPI* SPI::_owner = NULL;
SingletonPtr<PlatformMutex> 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