SPISoft.h
Go to the documentation of this file.
1 /*
2 Author: ADiea
3 Project: Sming for ESP8266
4 License: MIT
5 Date: 15.07.2015
6 Descr: Implement software SPI for HW configs other than hardware SPI pins(GPIO 12,13,14)
7 */
8 #pragma once
9 
10 #include "SPIBase.h"
11 #include "SPISettings.h"
12 
13 class SPISoft : public SPIBase
14 {
15 public:
16  SPISoft(uint16_t miso, uint16_t mosi, uint16_t sck, uint8_t delay)
17  : mMISO(miso), mMOSI(mosi), mCLK(sck), m_delay(delay)
18  {
19  }
20 
21  bool begin() override;
22 
23  void end() override
24  {
25  }
26 
27  void transfer(uint8_t* buffer, size_t size) override;
28 
32  void setDelay(uint8_t dly)
33  {
34  m_delay = dly;
35  }
36 
37 protected:
38  void prepare(SPISettings& settings) override
39  {
40  }
41 
42 private:
43  uint16_t mMISO, mMOSI, mCLK;
44  uint8_t m_delay;
45 };
Definition: SPISettings.h:66
void transfer(uint8_t *buffer, size_t size) override
Send/receive a variable-length block of data.
void setDelay(uint8_t dly)
Set microsecond delay for the SCK signal. Impacts SPI speed.
Definition: SPISoft.h:32
void delay(uint32_t milliseconds)
Pause execution.
void prepare(SPISettings &settings) override
Prepare/configure with settings.
Definition: SPISoft.h:38
Definition: SPISoft.h:13
SPISoft(uint16_t miso, uint16_t mosi, uint16_t sck, uint8_t delay)
Definition: SPISoft.h:16
bool begin() override
Initialize the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low...
Definition: SPIBase.h:28
void end() override
Disable the SPI bus (leaving pin modes unchanged).
Definition: SPISoft.h:23