2020-05-07 17:53:51 +00:00
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
2021-10-13 20:08:35 +00:00
|
|
|
#include "drivers/SpiMaster.h"
|
2020-05-07 17:53:51 +00:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
|
|
|
class Spi {
|
2021-04-24 09:00:45 +00:00
|
|
|
public:
|
2021-04-18 17:28:14 +00:00
|
|
|
Spi(SpiMaster& spiMaster, uint8_t pinCsn);
|
|
|
|
Spi(const Spi&) = delete;
|
|
|
|
Spi& operator=(const Spi&) = delete;
|
|
|
|
Spi(Spi&&) = delete;
|
|
|
|
Spi& operator=(Spi&&) = delete;
|
2020-05-07 17:53:51 +00:00
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
bool Init();
|
|
|
|
bool Write(const uint8_t* data, size_t size);
|
|
|
|
bool Read(uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize);
|
|
|
|
bool WriteCmdAndBuffer(const uint8_t* cmd, size_t cmdSize, const uint8_t* data, size_t dataSize);
|
|
|
|
void Sleep();
|
|
|
|
void Wakeup();
|
2020-05-07 17:53:51 +00:00
|
|
|
|
2021-04-24 09:00:45 +00:00
|
|
|
private:
|
2021-04-18 17:28:14 +00:00
|
|
|
SpiMaster& spiMaster;
|
|
|
|
uint8_t pinCsn;
|
2020-05-07 17:53:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|