Add SPI NOR Flash driver, WIP.

This commit is contained in:
JF
2020-05-07 19:53:51 +02:00
parent f96c048deb
commit 0b8e6c3fa2
14 changed files with 212 additions and 30 deletions

29
src/drivers/Spi.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include <hal/nrf_gpio.h>
#include "Spi.h"
using namespace Pinetime::Drivers;
Spi::Spi(SpiMaster& spiMaster, uint8_t pinCsn) :
spiMaster{spiMaster}, pinCsn{pinCsn} {
}
bool Spi::Write(const uint8_t *data, size_t size) {
return spiMaster.Write(pinCsn, data, size);
}
bool Spi::Read(uint8_t *data, size_t size) {
return spiMaster.Read(pinCsn, data, size);
}
void Spi::Sleep() {
// TODO sleep spi
nrf_gpio_cfg_default(pinCsn);
}
bool Spi::Init() {
nrf_gpio_pin_set(pinCsn); /* disable Set slave select (inactive high) */
return true;
}