diff options
| author | JF <jf@codingfield.com> | 2020-05-11 16:50:37 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-05-11 16:50:37 (GMT) |
| commit | ee05577dd62c64d0e6a2e497b75710c7a1351557 (patch) | |
| tree | 36d36462bd1c3aaa06df46b0bf6086111c83df2b /src/drivers/SpiMaster.h | |
| parent | 0b8e6c3fa20457bce931b1d289f187e46fc68307 (diff) | |
Fix race conditions on SPI and integrate the SPI NOR Flash driver into DFUService (WIP)
Diffstat (limited to 'src/drivers/SpiMaster.h')
| -rw-r--r-- | src/drivers/SpiMaster.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/drivers/SpiMaster.h b/src/drivers/SpiMaster.h index 24b39b9..7b35dfc 100644 --- a/src/drivers/SpiMaster.h +++ b/src/drivers/SpiMaster.h @@ -5,6 +5,7 @@ #include <array> #include <atomic> #include <task.h> +#include <semphr.h> #include "BufferProvider.h" namespace Pinetime { @@ -32,7 +33,9 @@ namespace Pinetime { bool Init(); bool Write(uint8_t pinCsn, const uint8_t* data, size_t size); - bool Read(uint8_t pinCsn, uint8_t* data, size_t size); + bool Read(uint8_t pinCsn, uint8_t* cmd, size_t cmdSize, uint8_t *data, size_t dataSize); + + bool WriteCmdAndBuffer(uint8_t pinCsn, uint8_t* cmd, size_t cmdSize, uint8_t *data, size_t dataSize); void OnStartedEvent(); void OnEndEvent(); @@ -44,7 +47,7 @@ namespace Pinetime { void SetupWorkaroundForFtpan58(NRF_SPIM_Type *spim, uint32_t ppi_channel, uint32_t gpiote_channel); void DisableWorkaroundForFtpan58(NRF_SPIM_Type *spim, uint32_t ppi_channel, uint32_t gpiote_channel); void PrepareTx(const volatile uint32_t bufferAddress, const volatile size_t size); - void PrepareRx(const volatile uint32_t bufferAddress, const volatile size_t size); + void PrepareRx(const volatile uint32_t cmdAddress, const volatile size_t cmdSize, const volatile uint32_t bufferAddress, const volatile size_t size); NRF_SPIM_Type * spiBaseAddress; uint8_t pinCsn; @@ -52,10 +55,12 @@ namespace Pinetime { SpiMaster::SpiModule spi; SpiMaster::Parameters params; - volatile bool busy = false; +// volatile bool busy = false; volatile uint32_t currentBufferAddr = 0; volatile size_t currentBufferSize = 0; volatile TaskHandle_t taskToNotify; + + SemaphoreHandle_t mutex; }; } } |
