summaryrefslogtreecommitdiff
path: root/src/drivers/SpiMaster.cpp
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-06-12 11:02:06 +0200
committerGitHub <noreply@github.com>2021-06-12 11:02:06 +0200
commit0ce98c7ac7ba66acaf504be9bb042796e12f2733 (patch)
tree3f9c7f96f0fab64f581035c72480596a4cc4db43 /src/drivers/SpiMaster.cpp
parent79f0fcb07aa80eb70385223272e29f2ba5657bc8 (diff)
parent6d524ebea2c97e309633d5e01c3a1e37c182f27d (diff)
Merge pull request #415 from JF002/move-heap-to-static
Move dynamically allocated variables to static variables.
Diffstat (limited to 'src/drivers/SpiMaster.cpp')
-rw-r--r--src/drivers/SpiMaster.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp
index 34fcc08a..0d5bb83c 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);
@@ -132,17 +135,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);
}
}