| 81 | } |
| 82 | |
| 83 | bool 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) \ |