diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-12-11 04:04:34 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-12-11 04:04:34 +0000 |
commit | 66201a05e9d5793880b27519affff7132f6630ea (patch) | |
tree | 3e93502cd9169a4c3b66190d0ff9a805c4d46863 /Projects/AVRISP/Lib/PDIProtocol.c | |
parent | 7e5966c1a88bf670c2f4962e8a52fcfc3528e82a (diff) | |
download | lufa-66201a05e9d5793880b27519affff7132f6630ea.tar.gz lufa-66201a05e9d5793880b27519affff7132f6630ea.tar.bz2 lufa-66201a05e9d5793880b27519affff7132f6630ea.zip |
Fix PDI code - must send NVM enable key least significant byte first, need to make sure Tx and Rx is switched correctly including disabling the output on the Tx line when receiving.
Diffstat (limited to 'Projects/AVRISP/Lib/PDIProtocol.c')
-rw-r--r-- | Projects/AVRISP/Lib/PDIProtocol.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Projects/AVRISP/Lib/PDIProtocol.c b/Projects/AVRISP/Lib/PDIProtocol.c index 28bd54071..32a74c586 100644 --- a/Projects/AVRISP/Lib/PDIProtocol.c +++ b/Projects/AVRISP/Lib/PDIProtocol.c @@ -111,18 +111,20 @@ static void PDIProtocol_EnterXPROGMode(void) /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */
PDITarget_SendByte(PDI_CMD_KEY);
- for (uint8_t i = 0; i < sizeof(PDI_NVMENABLE_KEY); i++)
- PDITarget_SendByte(PDI_NVMENABLE_KEY[i]);
+ for (uint8_t i = sizeof(PDI_NVMENABLE_KEY); i > 0; i--)
+ PDITarget_SendByte(PDI_NVMENABLE_KEY[i - 1]);
/* Poll the STATUS register to check to see if NVM access has been enabled */
- uint8_t NVMAttemptsRemaining = 200;
- while (NVMAttemptsRemaining--)
+ uint8_t NVMAttemptsRemaining = 150;
+ while (NVMAttemptsRemaining)
{
_delay_ms(1);
- PDITarget_SendByte(PDI_CMD_LDCS | PD_STATUS_REG);
+ PDITarget_SendByte(PDI_CMD_LDCS | PD_STATUS_REG);
if (PDITarget_ReceiveByte() & PDI_STATUS_NVM)
break;
+
+ NVMAttemptsRemaining--;
}
Endpoint_Write_Byte(CMD_XPROG);
|