Add target voltage adjustment for Curiosity Nano boards

in Avrdude terminal mode
This commit is contained in:
MCUdude 2022-01-03 18:49:55 +01:00
parent 4c3530e199
commit ecca860972
2 changed files with 37 additions and 2 deletions

View File

@ -2305,6 +2305,31 @@ int jtag3_read_sib(PROGRAMMER * pgm, AVRPART * p, char * sib)
return 0; return 0;
} }
static int jtag3_set_vtarget(PROGRAMMER * pgm, double v)
{
unsigned uaref, utarg;
unsigned char buf[2];
utarg = (unsigned)(v * 1000);
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0) {
avrdude_message(MSG_INFO, "%s: jtag3_set_vtarget(): cannot obtain V[aref]\n",
progname);
return -1;
}
uaref = b2_to_u16(buf);
u16_to_b2(buf, utarg);
avrdude_message(MSG_INFO, "%s: jtag3_set_vtarget(): changing V[target] from %.1f to %.1f\n",
progname, uaref / 1000.0, v);
if (jtag3_setparm(pgm, SCOPE_GENERAL, 1, PARM3_VADJUST, buf, sizeof(buf)) < 0)
return -1;
return 0;
}
static void jtag3_display(PROGRAMMER * pgm, const char * p) static void jtag3_display(PROGRAMMER * pgm, const char * p)
{ {
unsigned char parms[5]; unsigned char parms[5];
@ -2564,5 +2589,12 @@ void jtag3_updi_initpgm(PROGRAMMER * pgm)
pgm->flag = PGM_FL_IS_UPDI; pgm->flag = PGM_FL_IS_UPDI;
pgm->unlock = jtag3_unlock_erase_key; pgm->unlock = jtag3_unlock_erase_key;
pgm->read_sib = jtag3_read_sib; pgm->read_sib = jtag3_read_sib;
/*
* enable target voltage adjustment for PKOB/nEDBG boards
*/
if (matches(ldata(lfirst(pgm->id)), "pkobn_updi")) {
pgm->set_vtarget = jtag3_set_vtarget;
}
} }

View File

@ -189,8 +189,11 @@
#define PARM3_FW_RELEASE 0x03 /* section 0, generic scope, 1 byte; #define PARM3_FW_RELEASE 0x03 /* section 0, generic scope, 1 byte;
* always asked for by Atmel Studio, * always asked for by Atmel Studio,
* but never displayed there */ * but never displayed there */
#define PARM3_VTARGET 0x00 /* section 1, generic scope, 2 bytes, #define PARM3_VTARGET 0x00 /* section 1, generic scope, 2 bytes, in millivolts */
* in millivolts */ #define PARM3_VBUF 0x01 /* section 1, generic scope, 2 bytes, bufferred target voltage reference */
#define PARM3_VUSB 0x02 /* section 1, generic scope, 2 bytes, USB voltage */
#define PARM3_VADJUST 0x20 /* section 1, generic scope, 2 bytes, set voltage */
#define PARM3_DEVICEDESC 0x00 /* section 2, memory etc. configuration, #define PARM3_DEVICEDESC 0x00 /* section 2, memory etc. configuration,
* 31 bytes for tiny/mega AVR, 47 bytes * 31 bytes for tiny/mega AVR, 47 bytes
* for Xmega; is also used in command * for Xmega; is also used in command