summaryrefslogtreecommitdiff
path: root/src/drivers/SpiMaster.cpp
diff options
context:
space:
mode:
authorKieran Cawthray <kieranc@gmail.com>2021-06-16 14:33:34 (GMT)
committerKieran Cawthray <kieranc@gmail.com>2021-06-16 14:33:34 (GMT)
commitf5d756928ffef032fb5ac85e73f9a68b7b8f64dc (patch)
tree907608958d0be8a97a3d646c842fde3095cef939 /src/drivers/SpiMaster.cpp
parentf2d01166c380b72ebcb13ef649def88ff4cf2d21 (diff)
parente90e8c7426f9a44e696b208a5b393a60476a3d43 (diff)
Merge remote-tracking branch 'upstream/develop' into pinetimestyle
Diffstat (limited to 'src/drivers/SpiMaster.cpp')
-rw-r--r--src/drivers/SpiMaster.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp
index 34fcc08..c45e129 100644
--- a/src/drivers/SpiMaster.cpp
+++ b/src/drivers/SpiMaster.cpp
@@ -7,11 +7,14 @@
using namespace Pinetime::Drivers;
SpiMaster::SpiMaster(const SpiMaster::SpiModule spi, const SpiMaster::Parameters& params) : spi {spi}, params {params} {
- mutex = xSemaphoreCreateBinary();
- ASSERT(mutex != NULL);
}
bool SpiMaster::Init() {
+ if(mutex == nullptr) {
+ mutex = xSemaphoreCreateBinary();
+ ASSERT(mutex != nullptr);
+ }
+
/* Configure GPIO pins used for pselsck, pselmosi, pselmiso and pselss for SPI0 */
nrf_gpio_pin_set(params.pinSCK);
nrf_gpio_cfg_output(params.pinSCK);
@@ -53,6 +56,7 @@ bool SpiMaster::Init() {
break;
case BitOrder::Lsb_Msb:
regConfig = 1;
+ break;
default:
return false;
}
@@ -132,17 +136,17 @@ void SpiMaster::OnEndEvent() {
spiBaseAddress->TASKS_START = 1;
} else {
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (taskToNotify != nullptr) {
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(taskToNotify, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
nrf_gpio_pin_set(this->pinCsn);
currentBufferAddr = 0;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- xSemaphoreGiveFromISR(mutex, &xHigherPriorityTaskWoken);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ BaseType_t xHigherPriorityTaskWoken2 = pdFALSE;
+ xSemaphoreGiveFromISR(mutex, &xHigherPriorityTaskWoken2);
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken | xHigherPriorityTaskWoken2);
}
}