Merge pull request #1164 from MCUdude/hvupdi-type2-fix

Fix Type 2 HV UPDI
This commit is contained in:
Stefan Rueger 2022-11-01 18:17:52 +00:00 committed by GitHub
commit d211c4e5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -1198,23 +1198,22 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
} }
// Generate UPDI high-voltage pulse if user asks for it and hardware supports it // Generate UPDI high-voltage pulse if user asks for it and hardware supports it
LNODEID support;
if (p->prog_modes & PM_UPDI && if (p->prog_modes & PM_UPDI &&
PDATA(pgm)->use_hvupdi == true && PDATA(pgm)->use_hvupdi == true &&
p->hvupdi_variant != HV_UPDI_VARIANT_1) { p->hvupdi_variant != HV_UPDI_VARIANT_1) {
parm[0] = PARM3_UPDI_HV_NONE; parm[0] = PARM3_UPDI_HV_NONE;
for (support = lfirst(pgm->hvupdi_support); support != NULL; support = lnext(support)) { for (LNODEID ln = lfirst(pgm->hvupdi_support); ln; ln = lnext(ln)) {
if(*(int *) ldata(support) == p->hvupdi_variant) { if(*(int *) ldata(ln) == p->hvupdi_variant) {
pmsg_notice("sending HV pulse to targets %s pin\n", pmsg_notice("sending HV pulse to targets %s pin\n",
p->hvupdi_variant == HV_UPDI_VARIANT_0? "UPDI": "RESET"); p->hvupdi_variant == HV_UPDI_VARIANT_0? "UPDI": "RESET");
parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE; parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE;
break; break;
} }
}
if (parm[0] == PARM3_UPDI_HV_NONE) { if (parm[0] == PARM3_UPDI_HV_NONE) {
pmsg_error("%s does not support sending HV pulse to target %s\n", pgm->desc, p->desc); pmsg_error("%s does not support sending HV pulse to target %s\n", pgm->desc, p->desc);
return -1; return -1;
} }
}
if (jtag3_setparm(pgm, SCOPE_AVR, 3, PARM3_OPT_12V_UPDI_ENABLE, parm, 1) < 0) if (jtag3_setparm(pgm, SCOPE_AVR, 3, PARM3_OPT_12V_UPDI_ENABLE, parm, 1) < 0)
return -1; return -1;
} }

View File

@ -209,7 +209,7 @@ typedef struct opcode {
#define HV_UPDI_VARIANT_0 0 /* Shared UPDI/GPIO/RESET pin, HV on UPDI pin (tinyAVR0/1/2)*/ #define HV_UPDI_VARIANT_0 0 /* Shared UPDI/GPIO/RESET pin, HV on UPDI pin (tinyAVR0/1/2)*/
#define HV_UPDI_VARIANT_1 1 /* Dedicated UPDI pin, no HV (megaAVR0/AVR-Dx) */ #define HV_UPDI_VARIANT_1 1 /* Dedicated UPDI pin, no HV (megaAVR0/AVR-Dx) */
#define HV_UPDI_VARIANT_2 2 /* Shared UPDI pin, HV on _RESET (AVR-Ex) */ #define HV_UPDI_VARIANT_2 2 /* Shared UPDI pin, HV on _RESET (AVR-DD/AVR-Ex) */
#define AVR_FAMILYIDLEN 7 #define AVR_FAMILYIDLEN 7
#define AVR_SIBLEN 16 #define AVR_SIBLEN 16