2222// using an Uno. (On an Uno this is not needed).
2323//
2424// 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 .
2727//
2828// IMPORTANT: When using an Arduino that is not 5V tolerant (Due, Zero, ...) as
2929// the programmer, make sure to not expose any of the programmer's pins to 5V.
8282
8383#ifdef USE_OLD_STYLE_WIRING
8484
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
8888
8989#endif
9090
100100#endif
101101
102102// 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
105105#endif
106106
107- #ifndef PIN_MISO
108- #define PIN_MISO MISO
107+ #ifndef ARDUINOISP_PIN_MISO
108+ #define ARDUINOISP_PIN_MISO MISO
109109#endif
110110
111- #ifndef PIN_SCK
112- #define PIN_SCK SCK
111+ #ifndef ARDUINOISP_PIN_SCK
112+ #define ARDUINOISP_PIN_SCK SCK
113113#endif
114114
115115// 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)
117117#undef USE_HARDWARE_SPI
118118#endif
119119
@@ -186,11 +186,11 @@ private:
186186class BitBangedSPI {
187187public:
188188 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);
194194 }
195195
196196 void beginTransaction (SPISettings settings) {
@@ -204,11 +204,11 @@ public:
204204
205205 uint8_t transfer (uint8_t b) {
206206 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);
209209 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
212212 delayMicroseconds (pulseWidth);
213213 }
214214 return b;
@@ -408,7 +408,7 @@ void set_parameters() {
408408
409409void start_pmode () {
410410
411- // Reset target before driving PIN_SCK or PIN_MOSI
411+ // Reset target before driving ARDUINOISP_PIN_SCK or ARDUINOISP_PIN_MOSI
412412
413413 // SPI.begin() will configure SS as output, so SPI master mode is selected.
414414 // We have defined RESET as pin 10, which for many Arduinos is not the SS pin.
@@ -421,9 +421,9 @@ void start_pmode() {
421421
422422 // See AVR datasheets, chapter "SERIAL_PRG Programming Algorithm":
423423
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
427427 reset_target (false );
428428 // Pulse must be minimum 2 target CPU clock cycles so 100 usec is ok for CPU
429429 // speeds above 20 KHz
@@ -439,8 +439,8 @@ void start_pmode() {
439439void end_pmode () {
440440 SPI.end ();
441441 // 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);
444444 reset_target (false );
445445 pinMode (RESET, INPUT);
446446 pmode = 0 ;
0 commit comments