summaryrefslogtreecommitdiff
path: root/src/drivers/SpiMaster.h
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-01-26 13:37:10 +0100
committerJF <jf@codingfield.com>2020-01-26 13:37:10 +0100
commit5fa4f5abe0b752bb2d990378e02d6424a1d1b661 (patch)
treebc2e731c488573d678aec1d388a00f754b24fb02 /src/drivers/SpiMaster.h
parenteb7a1b3ac9cbacb74afb7fcd1d40c51a18c90060 (diff)
Better integration of SPI with DMA and IRQ. Using only 'End' IRQ. Perf could be improved by using 'Started' IRQ to prepare the next buffer while the current one is beeing sent.
Diffstat (limited to 'src/drivers/SpiMaster.h')
-rw-r--r--src/drivers/SpiMaster.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/drivers/SpiMaster.h b/src/drivers/SpiMaster.h
index ee03186c..7dac747a 100644
--- a/src/drivers/SpiMaster.h
+++ b/src/drivers/SpiMaster.h
@@ -3,6 +3,8 @@
#include <cstddef>
#include <array>
#include <atomic>
+
+#include "BufferProvider.h"
namespace Pinetime {
namespace Drivers {
class SpiMaster {
@@ -23,20 +25,17 @@ namespace Pinetime {
SpiMaster(const SpiModule spi, const Parameters& params);
bool Init();
- bool Write(const uint8_t* data, size_t size, size_t r = 0);
- void setup_workaround_for_ftpan_58(NRF_SPIM_Type *spim, uint32_t ppi_channel, uint32_t gpiote_channel);
- void Wait();
+ bool Write(const uint8_t* data, size_t size);
+
+ void OnStartedEvent(BufferProvider& provider);
+ void OnEndEvent(BufferProvider& provider);
void Sleep();
void Wakeup();
- bool GetStatusEnd();
- bool GetStatusStarted();
-
- void irqEnd();
- void irqStarted();
-
private:
+ void setup_workaround_for_ftpan_58(NRF_SPIM_Type *spim, uint32_t ppi_channel, uint32_t gpiote_channel);
+
NRF_SPIM_Type * spiBaseAddress;
uint8_t pinCsn;
@@ -44,12 +43,8 @@ namespace Pinetime {
SpiMaster::Parameters params;
volatile bool busy = false;
-
- uint32_t bufferAddr = 0;
volatile uint32_t currentBufferAddr = 0;
- size_t bufferSize = 0;
volatile size_t currentBufferSize = 0;
- volatile uint32_t repeat = 0;
};
}
}