Skip to content

[HAL] Modified SPI to use shared mutex #2297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hal/api/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#if DEVICE_SPI

#include "spi_api.h"
#include "SingletonPtr.h"

#if DEVICE_SPI_ASYNCH
#include "CThunk.h"
Expand Down Expand Up @@ -246,7 +247,7 @@ class SPI {

void aquire(void);
static SPI *_owner;
PlatformMutex _mutex;
static SingletonPtr<PlatformMutex> _mutex;
int _bits;
int _mode;
int _hz;
Expand Down
5 changes: 3 additions & 2 deletions hal/common/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down