2424// Version 1.15: Remembers last file name uploaded in EEPROM
2525// Version 1.16: Allowed for running on the Leonardo, Micro, etc.
2626// Version 1.17: Added timed writing for Atmega8
27+ // Version 1.18: Added support for running on an Atmega2560
2728
2829const bool allowTargetToRun = true ; // if true, programming lines are freed when not programming
2930
@@ -72,10 +73,19 @@ const bool allowTargetToRun = true; // if true, programming lines are freed whe
7273const char Version [] = " 1.17" ;
7374
7475// bit banged SPI pins
75- const byte MSPIM_SCK = 4 ; // port D bit 4
76- const byte MSPIM_SS = 5 ; // port D bit 5
77- const byte BB_MISO = 6 ; // port D bit 6
78- const byte BB_MOSI = 7 ; // port D bit 7
76+ #ifdef __AVR_ATmega2560__
77+ // Atmega2560
78+ const byte MSPIM_SCK = 4 ; // port G bit 5
79+ const byte MSPIM_SS = 5 ; // port E bit 3
80+ const byte BB_MISO = 6 ; // port H bit 3
81+ const byte BB_MOSI = 7 ; // port H bit 4
82+ #else
83+ // Atmega328
84+ const byte MSPIM_SCK = 4 ; // port D bit 4
85+ const byte MSPIM_SS = 5 ; // port D bit 5
86+ const byte BB_MISO = 6 ; // port D bit 6
87+ const byte BB_MOSI = 7 ; // port D bit 7
88+ #endif
7989
8090// 8 MHz clock on this pin
8191const byte CLOCKOUT = 9 ;
@@ -102,13 +112,24 @@ Both SD card and target processor will need +5V and Gnd connected.
102112
103113*/
104114
105- // for fast port access (Atmega328)
106- #define BB_MISO_PORT PIND
107- #define BB_MOSI_PORT PORTD
108- #define BB_SCK_PORT PORTD
109- const byte BB_SCK_BIT = 4 ;
110- const byte BB_MISO_BIT = 6 ;
111- const byte BB_MOSI_BIT = 7 ;
115+ // for fast port access
116+ #ifdef __AVR_ATmega2560__
117+ // Atmega2560
118+ #define BB_MISO_PORT PINH
119+ #define BB_MOSI_PORT PORTH
120+ #define BB_SCK_PORT PORTG
121+ const byte BB_SCK_BIT = 5 ;
122+ const byte BB_MISO_BIT = 3 ;
123+ const byte BB_MOSI_BIT = 4 ;
124+ #else
125+ // Atmega328
126+ #define BB_MISO_PORT PIND
127+ #define BB_MOSI_PORT PORTD
128+ #define BB_SCK_PORT PORTD
129+ const byte BB_SCK_BIT = 4 ;
130+ const byte BB_MISO_BIT = 6 ;
131+ const byte BB_MOSI_BIT = 7 ;
132+ #endif
112133
113134// control speed of programming
114135const byte BB_DELAY_MICROSECONDS = 4 ;
0 commit comments