summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Keller <geekboy1011@gmail.com>2021-10-19 19:15:41 +0000
committerTim Keller <geekboy1011@gmail.com>2021-12-10 01:18:57 +0000
commita5a64800eda02358aebe4d0f23d43ee33f363c56 (patch)
treee91a334ced602ad08c697501e528d8c7a907b1ad /src
parentd89e38d3bf9e84e69635f0cb10cc42f0071fa038 (diff)
Revert "Workaround for SPI bus being asleep."
This reverts commit 1edeb5cb65489707c26b7a65f3b54520086d363a.
Diffstat (limited to 'src')
-rw-r--r--src/drivers/SpiMaster.cpp16
-rw-r--r--src/drivers/SpiMaster.h2
2 files changed, 3 insertions, 15 deletions
diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp
index 4492e899..747dbc84 100644
--- a/src/drivers/SpiMaster.cpp
+++ b/src/drivers/SpiMaster.cpp
@@ -10,7 +10,7 @@ SpiMaster::SpiMaster(const SpiMaster::SpiModule spi, const SpiMaster::Parameters
}
bool SpiMaster::Init() {
- if (mutex == nullptr) {
+ if(mutex == nullptr) {
mutex = xSemaphoreCreateBinary();
ASSERT(mutex != nullptr);
}
@@ -179,10 +179,6 @@ void SpiMaster::PrepareRx(const volatile uint32_t cmdAddress,
bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size) {
if (data == nullptr)
return false;
-
- if (!active) {
- Wakeup();
- }
auto ok = xSemaphoreTake(mutex, portMAX_DELAY);
ASSERT(ok == true);
taskToNotify = xTaskGetCurrentTaskHandle();
@@ -219,9 +215,7 @@ bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size) {
bool SpiMaster::Read(uint8_t pinCsn, uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize) {
xSemaphoreTake(mutex, portMAX_DELAY);
- if (!active) {
- Wakeup();
- }
+
taskToNotify = nullptr;
this->pinCsn = pinCsn;
@@ -259,16 +253,12 @@ void SpiMaster::Sleep() {
nrf_gpio_cfg_default(params.pinSCK);
nrf_gpio_cfg_default(params.pinMOSI);
nrf_gpio_cfg_default(params.pinMISO);
- active = false;
+
NRF_LOG_INFO("[SPIMASTER] sleep")
}
void SpiMaster::Wakeup() {
- if (active) {
- return;
- }
Init();
- active = true;
NRF_LOG_INFO("[SPIMASTER] Wakeup");
}
diff --git a/src/drivers/SpiMaster.h b/src/drivers/SpiMaster.h
index f5d2b125..5ea624f2 100644
--- a/src/drivers/SpiMaster.h
+++ b/src/drivers/SpiMaster.h
@@ -60,8 +60,6 @@ namespace Pinetime {
volatile size_t currentBufferSize = 0;
volatile TaskHandle_t taskToNotify;
SemaphoreHandle_t mutex = nullptr;
-
- bool active;
};
}
}