???
This commit is contained in:
22
io/SoftSPI.h
22
io/SoftSPI.h
@@ -347,10 +347,10 @@ public:
|
||||
|
||||
private:
|
||||
void init() {
|
||||
debugMod(NAME, "init()");
|
||||
GPIO::setInput(PIN_MISO);
|
||||
GPIO::setOutput(PIN_MOSI);
|
||||
GPIO::setOutput(PIN_CLK);
|
||||
debugMod3(NAME, "init() MISO:%d MOSI:%d CLK:%d", PIN_MISO, PIN_MOSI, PIN_CLK);
|
||||
if (PIN_MISO) {MyGPIO::setInput(PIN_MISO);}
|
||||
if (PIN_MOSI) {MyGPIO::setOutput(PIN_MOSI);}
|
||||
MyGPIO::setOutput(PIN_CLK);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -363,12 +363,12 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
inline void clkLo() { GPIO::clear(PIN_CLK); }
|
||||
inline void clkHi() { GPIO::set(PIN_CLK); }
|
||||
inline void clkLo() { MyGPIO::clear(PIN_CLK); }
|
||||
inline void clkHi() { MyGPIO::set(PIN_CLK); }
|
||||
|
||||
/** write one bit to the bus */
|
||||
inline void writeBit(const bool out) {
|
||||
if(out) {GPIO::set(PIN_MOSI);} else {GPIO::clear(PIN_MOSI);}
|
||||
if(out) {MyGPIO::set(PIN_MOSI);} else {MyGPIO::clear(PIN_MOSI);}
|
||||
wait();
|
||||
clkHi();
|
||||
wait();
|
||||
@@ -380,7 +380,7 @@ private:
|
||||
inline uint8_t readBit() {
|
||||
clkHi();
|
||||
wait();
|
||||
const bool val = GPIO::get(PIN_MISO);
|
||||
const bool val = MyGPIO::get(PIN_MISO);
|
||||
wait();
|
||||
clkLo();
|
||||
wait();
|
||||
@@ -388,11 +388,11 @@ private:
|
||||
}
|
||||
|
||||
inline uint8_t readWriteBit(const bool out) {
|
||||
if(out) {GPIO::set(PIN_MOSI);} else {GPIO::clear(PIN_MOSI);}
|
||||
if(out) {MyGPIO::set(PIN_MOSI);} else {MyGPIO::clear(PIN_MOSI);}
|
||||
wait();
|
||||
clkHi();
|
||||
wait();
|
||||
const bool inp = GPIO::get(PIN_MISO);
|
||||
const bool inp = MyGPIO::get(PIN_MISO);
|
||||
wait();
|
||||
clkLo();
|
||||
wait();
|
||||
@@ -474,7 +474,7 @@ public:
|
||||
|
||||
/** read 8 bits */
|
||||
uint8_t readByte() {
|
||||
GPIO::clear(PIN_MOSI);
|
||||
MyGPIO::clear(PIN_MOSI);
|
||||
return
|
||||
(readBit() << 7) |
|
||||
(readBit() << 6) |
|
||||
|
||||
Reference in New Issue
Block a user