22
22
// using an Uno. (On an Uno this is not needed).
23
23
//
24
24
// Alternatively you can use any other digital pin by configuring
25
- // software ('BitBanged') SPI and having appropriate defines for PIN_MOSI ,
26
- // PIN_MISO and PIN_SCK .
25
+ // software ('BitBanged') SPI and having appropriate defines for ARDUINOISP_PIN_MOSI ,
26
+ // ARDUINOISP_PIN_MISO and ARDUINOISP_PIN_SCK .
27
27
//
28
28
// IMPORTANT: When using an Arduino that is not 5V tolerant (Due, Zero, ...) as
29
29
// the programmer, make sure to not expose any of the programmer's pins to 5V.
82
82
83
83
#ifdef USE_OLD_STYLE_WIRING
84
84
85
- #define PIN_MOSI 11
86
- #define PIN_MISO 12
87
- #define PIN_SCK 13
85
+ #define ARDUINOISP_PIN_MOSI 11
86
+ #define ARDUINOISP_PIN_MISO 12
87
+ #define ARDUINOISP_PIN_SCK 13
88
88
89
89
#endif
90
90
100
100
#endif
101
101
102
102
// By default, use hardware SPI pins:
103
- #ifndef PIN_MOSI
104
- #define PIN_MOSI MOSI
103
+ #ifndef ARDUINOISP_PIN_MOSI
104
+ #define ARDUINOISP_PIN_MOSI MOSI
105
105
#endif
106
106
107
- #ifndef PIN_MISO
108
- #define PIN_MISO MISO
107
+ #ifndef ARDUINOISP_PIN_MISO
108
+ #define ARDUINOISP_PIN_MISO MISO
109
109
#endif
110
110
111
- #ifndef PIN_SCK
112
- #define PIN_SCK SCK
111
+ #ifndef ARDUINOISP_PIN_SCK
112
+ #define ARDUINOISP_PIN_SCK SCK
113
113
#endif
114
114
115
115
// Force bitbanged SPI if not using the hardware SPI pins:
116
- #if (PIN_MISO != MISO) || (PIN_MOSI != MOSI) || (PIN_SCK != SCK)
116
+ #if (ARDUINOISP_PIN_MISO != MISO) || (ARDUINOISP_PIN_MOSI != MOSI) || (ARDUINOISP_PIN_SCK != SCK)
117
117
#undef USE_HARDWARE_SPI
118
118
#endif
119
119
@@ -186,11 +186,11 @@ private:
186
186
class BitBangedSPI {
187
187
public:
188
188
void begin () {
189
- digitalWrite (PIN_SCK , LOW);
190
- digitalWrite (PIN_MOSI , LOW);
191
- pinMode (PIN_SCK , OUTPUT);
192
- pinMode (PIN_MOSI , OUTPUT);
193
- pinMode (PIN_MISO , INPUT);
189
+ digitalWrite (ARDUINOISP_PIN_SCK , LOW);
190
+ digitalWrite (ARDUINOISP_PIN_MOSI , LOW);
191
+ pinMode (ARDUINOISP_PIN_SCK , OUTPUT);
192
+ pinMode (ARDUINOISP_PIN_MOSI , OUTPUT);
193
+ pinMode (ARDUINOISP_PIN_MISO , INPUT);
194
194
}
195
195
196
196
void beginTransaction (SPISettings settings) {
@@ -204,11 +204,11 @@ public:
204
204
205
205
uint8_t transfer (uint8_t b) {
206
206
for (unsigned int i = 0 ; i < 8 ; ++i) {
207
- digitalWrite (PIN_MOSI , (b & 0x80 ) ? HIGH : LOW);
208
- digitalWrite (PIN_SCK , HIGH);
207
+ digitalWrite (ARDUINOISP_PIN_MOSI , (b & 0x80 ) ? HIGH : LOW);
208
+ digitalWrite (ARDUINOISP_PIN_SCK , HIGH);
209
209
delayMicroseconds (pulseWidth);
210
- b = (b << 1 ) | digitalRead (PIN_MISO );
211
- digitalWrite (PIN_SCK , LOW); // slow pulse
210
+ b = (b << 1 ) | digitalRead (ARDUINOISP_PIN_MISO );
211
+ digitalWrite (ARDUINOISP_PIN_SCK , LOW); // slow pulse
212
212
delayMicroseconds (pulseWidth);
213
213
}
214
214
return b;
@@ -408,7 +408,7 @@ void set_parameters() {
408
408
409
409
void start_pmode () {
410
410
411
- // Reset target before driving PIN_SCK or PIN_MOSI
411
+ // Reset target before driving ARDUINOISP_PIN_SCK or ARDUINOISP_PIN_MOSI
412
412
413
413
// SPI.begin() will configure SS as output, so SPI master mode is selected.
414
414
// We have defined RESET as pin 10, which for many Arduinos is not the SS pin.
@@ -421,9 +421,9 @@ void start_pmode() {
421
421
422
422
// See AVR datasheets, chapter "SERIAL_PRG Programming Algorithm":
423
423
424
- // Pulse RESET after PIN_SCK is low:
425
- digitalWrite (PIN_SCK , LOW);
426
- delay (20 ); // discharge PIN_SCK , value arbitrarily chosen
424
+ // Pulse RESET after ARDUINOISP_PIN_SCK is low:
425
+ digitalWrite (ARDUINOISP_PIN_SCK , LOW);
426
+ delay (20 ); // discharge ARDUINOISP_PIN_SCK , value arbitrarily chosen
427
427
reset_target (false );
428
428
// Pulse must be minimum 2 target CPU clock cycles so 100 usec is ok for CPU
429
429
// speeds above 20 KHz
@@ -439,8 +439,8 @@ void start_pmode() {
439
439
void end_pmode () {
440
440
SPI.end ();
441
441
// We're about to take the target out of reset so configure SPI pins as input
442
- pinMode (PIN_MOSI , INPUT);
443
- pinMode (PIN_SCK , INPUT);
442
+ pinMode (ARDUINOISP_PIN_MOSI , INPUT);
443
+ pinMode (ARDUINOISP_PIN_SCK , INPUT);
444
444
reset_target (false );
445
445
pinMode (RESET, INPUT);
446
446
pmode = 0 ;
0 commit comments