summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Bma421.cpp2
-rw-r--r--src/drivers/SpiMaster.cpp16
-rw-r--r--src/drivers/SpiMaster.h3
-rw-r--r--src/drivers/TwiMaster.cpp4
-rw-r--r--src/drivers/TwiMaster.h2
5 files changed, 15 insertions, 12 deletions
diff --git a/src/drivers/Bma421.cpp b/src/drivers/Bma421.cpp
index 925b66c7..35b2c105 100644
--- a/src/drivers/Bma421.cpp
+++ b/src/drivers/Bma421.cpp
@@ -103,8 +103,6 @@ Bma421::Values Bma421::Process() {
uint8_t activity = 0;
bma423_activity_output(&activity, &bma);
- NRF_LOG_INFO("MOTION : %d - %d/%d/%d", steps, data.x, data.y, data.z);
-
// X and Y axis are swapped because of the way the sensor is mounted in the PineTime
return {steps, data.y, data.x, data.z};
}
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);
}
}
diff --git a/src/drivers/SpiMaster.h b/src/drivers/SpiMaster.h
index dfc195b7..5ea624f2 100644
--- a/src/drivers/SpiMaster.h
+++ b/src/drivers/SpiMaster.h
@@ -10,7 +10,6 @@ namespace Pinetime {
namespace Drivers {
class SpiMaster {
public:
- ;
enum class SpiModule : uint8_t { SPI0, SPI1 };
enum class BitOrder : uint8_t { Msb_Lsb, Lsb_Msb };
enum class Modes : uint8_t { Mode0, Mode1, Mode2, Mode3 };
@@ -60,7 +59,7 @@ namespace Pinetime {
volatile uint32_t currentBufferAddr = 0;
volatile size_t currentBufferSize = 0;
volatile TaskHandle_t taskToNotify;
- SemaphoreHandle_t mutex;
+ SemaphoreHandle_t mutex = nullptr;
};
}
}
diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp
index 7b6582dd..fc9edf81 100644
--- a/src/drivers/TwiMaster.cpp
+++ b/src/drivers/TwiMaster.cpp
@@ -9,10 +9,12 @@ using namespace Pinetime::Drivers;
// TODO use DMA/IRQ
TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} {
- mutex = xSemaphoreCreateBinary();
}
void TwiMaster::Init() {
+ if(mutex == nullptr)
+ mutex = xSemaphoreCreateBinary();
+
NRF_GPIO->PIN_CNF[params.pinScl] =
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h
index 1c0648a2..6175b99b 100644
--- a/src/drivers/TwiMaster.h
+++ b/src/drivers/TwiMaster.h
@@ -31,7 +31,7 @@ namespace Pinetime {
ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
void FixHwFreezed();
NRF_TWIM_Type* twiBaseAddress;
- SemaphoreHandle_t mutex;
+ SemaphoreHandle_t mutex = nullptr;
const Modules module;
const Parameters params;
static constexpr uint8_t maxDataSize {16};