add mega328p, bail out if device not supported

This commit is contained in:
Olaf Rempel 2014-09-29 22:26:41 +02:00
parent 6fd406c3d5
commit d2557e14bb

View File

@ -98,6 +98,7 @@ static const struct _device devices[] PROGMEM = {
{ { 0x1E, 0x94, 0x06 }, 0xFF, 0x3F, POLL_FF }, /* mega168 (no devcode) */ { { 0x1E, 0x94, 0x06 }, 0xFF, 0x3F, POLL_FF }, /* mega168 (no devcode) */
{ { 0x1E, 0x95, 0x02 }, 0x72, 0x3F, POLL_FF }, /* mega32 */ { { 0x1E, 0x95, 0x02 }, 0x72, 0x3F, POLL_FF }, /* mega32 */
{ { 0x1E, 0x95, 0x0F }, 0xFF, 0x3F, POLL_FF }, /* mega328p (no devcode) */
{ { 0x1E, 0x95, 0x87 }, 0xFF, 0x3F, POLL_FF }, /* mega32u4 (no devcode) */ { { 0x1E, 0x95, 0x87 }, 0xFF, 0x3F, POLL_FF }, /* mega32u4 (no devcode) */
{ { 0x1E, 0x96, 0x02 }, 0x45, 0x7F, POLL_FF }, /* mega64 */ { { 0x1E, 0x96, 0x02 }, 0x45, 0x7F, POLL_FF }, /* mega64 */
@ -367,7 +368,7 @@ static void cmdloop(void)
switch (ser_recv()) { switch (ser_recv()) {
/* Enter programming mode */ /* Enter programming mode */
case 'P': { case 'P': {
uint8_t sync, count = 0x20; uint8_t sync, count = 0x20, retval = '!';
led_mode = LED_ON; led_mode = LED_ON;
do { do {
set_reset(1); set_reset(1);
@ -394,12 +395,19 @@ static void cmdloop(void)
for (i = 0; i < ARRAY_SIZE(devices); i++) { for (i = 0; i < ARRAY_SIZE(devices); i++) {
if (memcmp_P(device.sig, devices[i].sig, sizeof(device.sig)) == 0) { if (memcmp_P(device.sig, devices[i].sig, sizeof(device.sig)) == 0) {
memcpy_P(&device, &devices[i], sizeof(struct _device)); memcpy_P(&device, &devices[i], sizeof(struct _device));
retval = '\r';
break; break;
} }
} }
} }
ser_send('\r'); /* device not supported */
if (retval == '!') {
set_reset(1);
led_mode = LED_OFF;
}
ser_send(retval);
break; break;
} }