Skip to content

Commit b82e554

Browse files
committed
SPI mutex lock
1 parent 2ece915 commit b82e554

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

libraries/SPI/SPI.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ void arduino::MbedSPI::beginTransaction(SPISettings settings) {
8181
dev->obj->frequency(settings.getClockFreq());
8282
this->settings = settings;
8383
}
84+
spiLockMutex.lock();
8485
}
8586

8687
void arduino::MbedSPI::endTransaction(void) {
88+
spiLockMutex.unlock();
8789
// spinlock until transmission is over (if using ASYNC transfer)
8890
}
8991

libraries/SPI/SPI.h

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "Arduino.h"
2222
#include "api/HardwareSPI.h"
23+
#include <Mutex.h>
2324

2425
typedef struct _mbed_spi mbed_spi;
2526

@@ -50,6 +51,7 @@ class MbedSPI : public SPIClass
5051
private:
5152
SPISettings settings = SPISettings(0, MSBFIRST, SPI_MODE0);
5253
_mbed_spi* dev = NULL;
54+
rtos::Mutex spiLockMutex;
5355
PinName _miso;
5456
PinName _mosi;
5557
PinName _sck;

0 commit comments

Comments
 (0)