00001
00031 #ifndef __bootloaderconfig_h_included__
00032 #define __bootloaderconfig_h_included__
00033
00034
00035
00039 #define USB_CFG_IOPORTNAME D
00040
00043 #define USB_CFG_DMINUS_BIT 0
00044
00048 #define USB_CFG_DPLUS_BIT 2
00049
00055 #define USB_CFG_CLOCK_KHZ (F_CPU/1000)
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00081 #define HAVE_EEPROM_PAGED_ACCESS 1
00082
00087 #define HAVE_EEPROM_BYTE_ACCESS 1
00088
00091 #define BOOTLOADER_CAN_EXIT 1
00092
00097 #define SIGNATURE_BYTES 0x1e, 0x95, 0x02, 0
00098
00099
00100
00101
00102
00103
00104 #if USE_AUTOCONFIG
00105 # undef HAVE_EEPROM_PAGED_ACCESS
00106 # define HAVE_EEPROM_PAGED_ACCESS (USB_CFG_CLOCK_KHZ >= 16000)
00107 # undef HAVE_EEPROM_BYTE_ACCESS
00108 # define HAVE_EEPROM_BYTE_ACCESS 1
00109 # undef BOOTLOADER_CAN_EXIT
00110 # define BOOTLOADER_CAN_EXIT 1
00111 # undef SIGNATURE_BYTES
00112 #endif
00113
00114
00115
00116 #ifndef __ASSEMBLER__
00117
00118 uint8_t ledcounter = 0;
00119 uint8_t ledstate = 0;
00120
00125 static inline void bootLoaderInit(void) {
00126
00127 DDRD |= (1 << PIND4) | (1 << PIND5) | (1 << PIND6);
00128 PORTD &= ~((1 << PIND4) | (1 << PIND5) | (1 << PIND6));
00129
00130
00131 DDRA = 0x00;
00132 PORTA = 0xff;
00133 DDRC = (1 << DDC2);
00134 PORTC = ~(1 << PINC2);
00135 }
00136
00140 static inline void bootLoaderExit(void) {
00141
00142 PORTD |= (1 << PIND4) | (1 << PIND5) | (1 << PIND6);
00143 }
00144
00151 static inline uint8_t bootLoaderCondition() {
00152
00153 if (!(PINB & (1 << PINB7))) {
00154
00155 _delay_ms(1);
00156 ledcounter++;
00157 if (ledcounter == 127) {
00158 switch (ledstate) {
00159 case 0:
00160 PORTD &= ~(1 << PIND6);
00161 PORTD |= (1 << PIND4) | (1 << PIND5);
00162 ledstate = 1;
00163 break;
00164 case 1:
00165 PORTD &= ~(1 << PIND5);
00166 PORTD |= (1 << PIND4) | (1 << PIND6);
00167 ledstate = 2;
00168 break;
00169 case 2:
00170 PORTD &= ~(1 << PIND4);
00171 PORTD |= (1 << PIND5) | (1 << PIND6);
00172 ledstate = 0;
00173 break;
00174 default:
00175 ledstate = 0;
00176 }
00177 ledcounter = 0;
00178 }
00179 return 1;
00180 } else {
00181
00182 return 0;
00183 }
00184 }
00185
00186 #endif
00187
00188
00189
00190 #endif