worked on FAT32 stuff
This commit is contained in:
13
io/SoftSPI.h
13
io/SoftSPI.h
@@ -10,9 +10,10 @@
|
||||
|
||||
|
||||
// NOTE: the last template argument has changed from "bool fast" to "int slowdown" where 0 is now fastest!
|
||||
template <int PIN_MISO, int PIN_MOSI, int PIN_CLK, int SLOWDOWN> class SoftSPI {
|
||||
template <int PIN_MISO, int PIN_MOSI, int PIN_CLK> class SoftSPI {
|
||||
|
||||
static constexpr const char* NAME = "softSPI";
|
||||
uint8_t SLOWDOWN = 128;
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(x) (1<<x)
|
||||
@@ -25,6 +26,11 @@ public:
|
||||
init();
|
||||
}
|
||||
|
||||
void setSlowdown(uint8_t sd) {
|
||||
this->SLOWDOWN = sd;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void init() {
|
||||
@@ -34,10 +40,11 @@ private:
|
||||
MyGPIO::setOutput(PIN_CLK);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static inline void wait() {
|
||||
inline void wait() {
|
||||
for (int i = 0; i < SLOWDOWN; ++i) {
|
||||
__asm__ __volatile__("nop");
|
||||
}
|
||||
@@ -67,7 +74,7 @@ private:
|
||||
return (val) ? 1 : 0;
|
||||
}
|
||||
|
||||
static inline uint8_t readWriteBit(const bool out) {
|
||||
inline uint8_t readWriteBit(const bool out) {
|
||||
if(out) {MyGPIO::set(PIN_MOSI);} else {MyGPIO::clear(PIN_MOSI);}
|
||||
wait();
|
||||
clkHi();
|
||||
|
||||
Reference in New Issue
Block a user