Improve pgm->id detection handling

This commit is contained in:
MCUdude 2022-10-02 10:41:40 +02:00
parent e05aa16510
commit ffabab1fb2
1 changed files with 92 additions and 73 deletions

View File

@ -2416,76 +2416,79 @@ void jtag3_print_parms1(const PROGRAMMER *pgm, const char *p) {
verbose ? "" : " ", b2_to_u16(buf) / 1000.0); verbose ? "" : " ", b2_to_u16(buf) / 1000.0);
// Print features unique to the Power Debugger // Print features unique to the Power Debugger
if (strncmp("powerdebugger", ldata(lfirst(pgm->id)), strlen("powerdebugger")) == 0) { for(LNODEID ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
short analog_raw_data; if(matches(ldata(ln), "powerdebugger")) {
short analog_raw_data;
// Read generator set voltage value (VOUT) // Read generator set voltage value (VOUT)
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VADJUST, buf, 2) < 0) if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VADJUST, buf, 2) < 0)
return; return;
analog_raw_data = b2_to_u16(buf); analog_raw_data = b2_to_u16(buf);
avrdude_message(MSG_INFO, "%sVout set %s: %.2f V\n", p, avrdude_message(MSG_INFO, "%sVout set %s: %.2f V\n", p,
verbose ? "" : " ", analog_raw_data / 1000.0); verbose ? "" : " ", analog_raw_data / 1000.0);
// Read measured generator voltage value (VOUT) // Read measured generator voltage value (VOUT)
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_TSUP_VOLTAGE_MEAS, buf, 2) < 0) if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_TSUP_VOLTAGE_MEAS, buf, 2) < 0)
return; return;
analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1]; analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1];
if ((buf[0] & 0xF0) != 0x30) if ((buf[0] & 0xF0) != 0x30)
avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_TSUP_VOLTAGE_MEAS data packet format\n", progname); avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_TSUP_VOLTAGE_MEAS data packet format\n", progname);
else { else {
if (analog_raw_data & 0x0800) if (analog_raw_data & 0x0800)
analog_raw_data |= 0xF000; analog_raw_data |= 0xF000;
avrdude_message(MSG_INFO, "%sVout measured %s: %.02f V\n", p, avrdude_message(MSG_INFO, "%sVout measured %s: %.02f V\n", p,
verbose ? "" : " ", ((float)analog_raw_data / -200.0)); verbose ? "" : " ", ((float)analog_raw_data / -200.0));
} }
// Read channel A voltage // Read channel A voltage
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_A_VOLTAGE, buf, 2) < 0) if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_A_VOLTAGE, buf, 2) < 0)
return; return;
analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1]; analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1];
if ((buf[0] & 0xF0) != 0x20) if ((buf[0] & 0xF0) != 0x20)
avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_A_VOLTAGE data packet format\n", progname); avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_A_VOLTAGE data packet format\n", progname);
else { else {
if (analog_raw_data & 0x0800) if (analog_raw_data & 0x0800)
analog_raw_data |= 0xF000; analog_raw_data |= 0xF000;
avrdude_message(MSG_INFO, "%sCh A voltage %s: %.03f V\n", p, avrdude_message(MSG_INFO, "%sCh A voltage %s: %.03f V\n", p,
verbose ? "" : " ", ((float)analog_raw_data / -200.0)); verbose ? "" : " ", ((float)analog_raw_data / -200.0));
} }
// Read channel A current // Read channel A current
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_A_CURRENT, buf, 3) < 0) if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_A_CURRENT, buf, 3) < 0)
return; return;
analog_raw_data = (buf[1] << 8) + buf[2]; analog_raw_data = (buf[1] << 8) + buf[2];
if (buf[0] != 0x90) if (buf[0] != 0x90)
avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_A_CURRENT data packet format\n", progname); avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_A_CURRENT data packet format\n", progname);
else else
avrdude_message(MSG_INFO, "%sCh A current %s: %.3f mA\n", p, avrdude_message(MSG_INFO, "%sCh A current %s: %.3f mA\n", p,
verbose ? "" : " ", ((float)analog_raw_data * 0.003472)); verbose ? "" : " ", ((float)analog_raw_data * 0.003472));
// Read channel B voltage // Read channel B voltage
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_B_VOLTAGE, buf, 2) < 0) if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_B_VOLTAGE, buf, 2) < 0)
return; return;
analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1]; analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1];
if ((buf[0] & 0xF0) != 0x10) if ((buf[0] & 0xF0) != 0x10)
avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_B_VOLTAGE data packet format\n", progname); avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_B_VOLTAGE data packet format\n", progname);
else { else {
if (analog_raw_data & 0x0800) if (analog_raw_data & 0x0800)
analog_raw_data |= 0xF000; analog_raw_data |= 0xF000;
avrdude_message(MSG_INFO, "%sCh B voltage %s: %.03f V\n", p, avrdude_message(MSG_INFO, "%sCh B voltage %s: %.03f V\n", p,
verbose ? "" : " ", ((float)analog_raw_data / -200.0)); verbose ? "" : " ", ((float)analog_raw_data / -200.0));
} }
// Read channel B current // Read channel B current
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_B_CURRENT, buf, 3) < 0) if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_ANALOG_B_CURRENT, buf, 3) < 0)
return; return;
analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1]; analog_raw_data = ((buf[0] & 0x0F) << 8) + buf[1];
if ((buf[0] & 0xF0) != 0x00) if ((buf[0] & 0xF0) != 0x00)
avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_B_CURRENT data packet format\n", progname); avrdude_message(MSG_INFO, "%s: jtag3_print_parms1(): invalid PARM3_ANALOG_B_CURRENT data packet format\n", progname);
else { else {
if (analog_raw_data & 0x0800) if (analog_raw_data & 0x0800)
analog_raw_data |= 0xF000; analog_raw_data |= 0xF000;
avrdude_message(MSG_INFO, "%sCh B current %s: %.3f mA\n", p, avrdude_message(MSG_INFO, "%sCh B current %s: %.3f mA\n", p,
verbose ? "" : " ", ((float)analog_raw_data * 0.555556)); verbose ? "" : " ", ((float)analog_raw_data * 0.555556));
}
break;
} }
} }
@ -2599,8 +2602,12 @@ void jtag3_initpgm(PROGRAMMER *pgm) {
pgm->page_size = 256; pgm->page_size = 256;
pgm->flag = PGM_FL_IS_JTAG; pgm->flag = PGM_FL_IS_JTAG;
if (matches(ldata(lfirst(pgm->id)), "powerdebugger")) for(LNODEID ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
pgm->set_vtarget = jtag3_set_vtarget; if (matches(ldata(ln), "powerdebugger")) {
pgm->set_vtarget = jtag3_set_vtarget;
break;
}
}
} }
const char jtag3_dw_desc[] = "Atmel JTAGICE3 in debugWire mode"; const char jtag3_dw_desc[] = "Atmel JTAGICE3 in debugWire mode";
@ -2633,8 +2640,12 @@ void jtag3_dw_initpgm(PROGRAMMER *pgm) {
pgm->page_size = 256; pgm->page_size = 256;
pgm->flag = PGM_FL_IS_DW; pgm->flag = PGM_FL_IS_DW;
if (matches(ldata(lfirst(pgm->id)), "powerdebugger_dw")) for(LNODEID ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
pgm->set_vtarget = jtag3_set_vtarget; if (matches(ldata(ln), "powerdebugger")) {
pgm->set_vtarget = jtag3_set_vtarget;
break;
}
}
} }
const char jtag3_pdi_desc[] = "Atmel JTAGICE3 in PDI mode"; const char jtag3_pdi_desc[] = "Atmel JTAGICE3 in PDI mode";
@ -2669,8 +2680,12 @@ void jtag3_pdi_initpgm(PROGRAMMER *pgm) {
pgm->page_size = 256; pgm->page_size = 256;
pgm->flag = PGM_FL_IS_PDI; pgm->flag = PGM_FL_IS_PDI;
if (matches(ldata(lfirst(pgm->id)), "powerdebugger_pdi")) for(LNODEID ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
pgm->set_vtarget = jtag3_set_vtarget; if (matches(ldata(ln), "powerdebugger")) {
pgm->set_vtarget = jtag3_set_vtarget;
break;
}
}
} }
const char jtag3_updi_desc[] = "Atmel JTAGICE3 in UPDI mode"; const char jtag3_updi_desc[] = "Atmel JTAGICE3 in UPDI mode";
@ -2708,8 +2723,12 @@ void jtag3_updi_initpgm(PROGRAMMER *pgm) {
pgm->unlock = jtag3_unlock_erase_key; pgm->unlock = jtag3_unlock_erase_key;
pgm->read_sib = jtag3_read_sib; pgm->read_sib = jtag3_read_sib;
if (matches(ldata(lfirst(pgm->id)), "pkobn_updi") || for(LNODEID ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
matches(ldata(lfirst(pgm->id)), "powerdebugger_updi")) if (matches(ldata(ln), "powerdebugger") ||
pgm->set_vtarget = jtag3_set_vtarget; matches(ldata(ln), "pkob")) {
pgm->set_vtarget = jtag3_set_vtarget;
break;
}
}
} }