2020-05-07 17:53:51 +00:00
|
|
|
#pragma once
|
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <array>
|
|
|
|
#include <atomic>
|
|
|
|
#include <task.h>
|
|
|
|
|
|
|
|
#include "BufferProvider.h"
|
|
|
|
#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;
|
|
|
|
|
|
|
|
bool Init();
|
|
|
|
bool Write(const uint8_t* data, size_t size);
|
2020-05-11 16:50:37 +00:00
|
|
|
bool Read(uint8_t* cmd, size_t cmdSize, uint8_t *data, size_t dataSize);
|
|
|
|
bool WriteCmdAndBuffer(uint8_t* cmd, size_t cmdSize, uint8_t *data, size_t dataSize);
|
2020-05-07 17:53:51 +00:00
|
|
|
void Sleep();
|
|
|
|
void Wakeup();
|
|
|
|
|
|
|
|
private:
|
|
|
|
SpiMaster& spiMaster;
|
|
|
|
uint8_t pinCsn;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|