diff options
author | Riku Isokoski <riksu9000@gmail.com> | 2021-07-14 09:59:56 +0300 |
---|---|---|
committer | Riku Isokoski <riksu9000@gmail.com> | 2021-07-14 09:59:56 +0300 |
commit | 95b8a56dd42da067b56e37111577427518d825fb (patch) | |
tree | 2a5d20d061f27e510bd7bd4e1af1621ad8a6d4b0 /src/drivers/SpiMaster.cpp | |
parent | 239b5547eae64d05f5d7544f0e11bfb877a75a02 (diff) | |
parent | a07b6382aef3c30d8ea8f28fcc3cc880d7afd747 (diff) |
Merge branch 'develop' into fix_touchevent_tap
Diffstat (limited to 'src/drivers/SpiMaster.cpp')
-rw-r--r-- | src/drivers/SpiMaster.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp index 34fcc08a..c45e1294 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); } } |