Merge pull request #2297 from neilt6/spi-mutex-fix

[HAL] Modified SPI to use shared mutex
pull/2318/head
Martin Kojtal 2016-07-29 17:30:38 +02:00 committed by GitHub
commit ac34f29f66
2 changed files with 5 additions and 3 deletions

View File

@ -22,6 +22,7 @@
#include "PlatformMutex.h"
#include "spi_api.h"
#include "SingletonPtr.h"
#if DEVICE_SPI_ASYNCH
#include "CThunk.h"
@ -247,7 +248,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