InfiniTime/src/drivers/Spi.h

29 lines
716 B
C
Raw Normal View History

2020-05-07 13:53:51 -04:00
#pragma once
#include <cstdint>
#include <cstddef>
#include "SpiMaster.h"
namespace Pinetime {
namespace Drivers {
class Spi {
public:
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 13:53:51 -04: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 13:53:51 -04:00
private:
SpiMaster& spiMaster;
uint8_t pinCsn;
2020-05-07 13:53:51 -04:00
};
}
}