MCPcopy Create free account
hub / github.com/SmingHub/Sming / begin

Method begin

Sming/Libraries/SPI/src/SPISoft.cpp:83–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83bool SPISoft::begin()
84{
85 assignDefaultPins(defaultPins);
86
87#ifdef ARCH_ESP8266
88 if(16 == pins.miso || 16 == pins.mosi || 16 == pins.sck) {
89 /*To be able to use fast/simple GPIO read/write GPIO16 is not supported*/
90 debug_e("[SPISoft] GPIO 16 not supported\n");
91 return false;
92 }
93#elif defined(ARCH_ESP32)
94 if(pins.sck >= 32 || pins.miso >= 32 || pins.mosi >= 32) {
95 debug_e("[SPISoft] Only bank 0 pins supported");
96 return false;
97 }
98#endif
99
100 pinMode(pins.sck, OUTPUT);
101
102 pinMode(pins.miso, INPUT);
103 digitalWrite(pins.miso, HIGH);
104
105 pinMode(pins.mosi, OUTPUT);
106
107 prepare(SPIDefaultSettings);
108
109 return true;
110}
111
112// Write/read a bit in LSB-first order
113#define CLOCK_LSB(bit, shift) \

Callers 3

initFunction · 0.45
executeMethod · 0.45
sendMethod · 0.45

Calls 2

pinModeFunction · 0.50
digitalWriteFunction · 0.50

Tested by 3

initFunction · 0.36
executeMethod · 0.36
sendMethod · 0.36