File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
build/shared/examples/11.ArduinoISP/ArduinoISP Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,10 @@ class BitBangedSPI {
114
114
}
115
115
116
116
void begin () {
117
+ // slow enough for an attiny85 @ 1MHz
118
+ // (pulseWidth should be > 2 cpu cycles, so take 3 cycles:)
119
+ pulseWidth = 3 ;
120
+
117
121
pinMode (MISO, INPUT);
118
122
pinMode (RESET, OUTPUT);
119
123
pinMode (SCK, OUTPUT);
@@ -126,11 +130,16 @@ class BitBangedSPI {
126
130
for (unsigned int i = 0 ; i < 8 ; ++i) {
127
131
digitalWrite (MOSI, b & 0x80 );
128
132
digitalWrite (SCK, HIGH);
133
+ delayMicroseconds (pulseWidth);
129
134
b = (b << 1 ) | digitalRead (MISO);
130
135
digitalWrite (SCK, LOW); // slow pulse
136
+ delayMicroseconds (pulseWidth);
131
137
}
132
138
return b;
133
139
}
140
+
141
+ private:
142
+ unsigned long pulseWidth; // in microseconds
134
143
};
135
144
136
145
static BitBangedSPI SPI;
You can’t perform that action at this time.
0 commit comments