ref: 45e65b66b11b6b8533b225067ce4c2a4b5eac653
src/drivers/Spi.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#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); 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(); private: SpiMaster& spiMaster; uint8_t pinCsn; }; } } |