Clean up and add more comments to the AVRISP-MKII project. Make sure the SPI_MULTI command handler supports multiple packet responses. Use slightly smaller/faster repeated indirect-load commands when retrieving the PDI target's memory CRCs.
This commit is contained in:
parent
b0ce1eab66
commit
f3d370a777
10 changed files with 87 additions and 47 deletions
|
@ -136,24 +136,18 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
|
|||
if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
|
||||
return false;
|
||||
|
||||
uint32_t MemoryCRC = 0;
|
||||
|
||||
/* Read the first generated CRC byte value */
|
||||
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
|
||||
/* Load the PDI pointer register with the DAT0 register start address */
|
||||
XPROGTarget_SendByte(PDI_CMD_ST | (PDI_POINTER_DIRECT << 2) | PDI_DATSIZE_4BYTES);
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT0);
|
||||
MemoryCRC = XPROGTarget_ReceiveByte();
|
||||
|
||||
/* Read the second generated CRC byte value */
|
||||
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT1);
|
||||
MemoryCRC |= ((uint16_t)XPROGTarget_ReceiveByte() << 8);
|
||||
|
||||
/* Read the third generated CRC byte value */
|
||||
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT2);
|
||||
MemoryCRC |= ((uint32_t)XPROGTarget_ReceiveByte() << 16);
|
||||
/* Send the REPEAT command to grab the CRC bytes */
|
||||
XPROGTarget_SendByte(PDI_CMD_REPEAT | PDI_DATSIZE_1BYTE);
|
||||
XPROGTarget_SendByte(XMEGA_CRC_LENGTH - 1);
|
||||
|
||||
*CRCDest = MemoryCRC;
|
||||
/* Read in the CRC bytes from the target */
|
||||
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
|
||||
for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)
|
||||
((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
#endif
|
||||
|
||||
/* Defines: */
|
||||
#define XMEGA_CRC_LENGTH 3
|
||||
|
||||
#define XMEGA_NVM_REG_ADDR0 0x00
|
||||
#define XMEGA_NVM_REG_ADDR1 0x01
|
||||
#define XMEGA_NVM_REG_ADDR2 0x02
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#if defined(ENABLE_XPROG_PROTOCOL) || defined(__DOXYGEN__)
|
||||
/** Base absolute address for the target's NVM controller for PDI programming */
|
||||
uint32_t XPROG_Param_NVMBase = 0x010001C0;
|
||||
uint32_t XPROG_Param_NVMBase = 0x010001C0;
|
||||
|
||||
/** Size in bytes of the target's EEPROM page */
|
||||
uint16_t XPROG_Param_EEPageSize;
|
||||
|
@ -455,10 +455,10 @@ static void XPROGProtocol_SetParam(void)
|
|||
case XPRG_PARAM_EEPPAGESIZE:
|
||||
XPROG_Param_EEPageSize = Endpoint_Read_Word_BE();
|
||||
break;
|
||||
case XPRG_PARAM_NVMCMD:
|
||||
case XPRG_PARAM_NVMCMD_REG:
|
||||
XPROG_Param_NVMCMDRegAddr = Endpoint_Read_Byte();
|
||||
break;
|
||||
case XPRG_PARAM_NVMCSR:
|
||||
case XPRG_PARAM_NVMCSR_REG:
|
||||
XPROG_Param_NVMCSRRegAddr = Endpoint_Read_Byte();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -98,12 +98,12 @@
|
|||
|
||||
#define XPRG_PARAM_NVMBASE 0x01
|
||||
#define XPRG_PARAM_EEPPAGESIZE 0x02
|
||||
#define XPRG_PARAM_NVMCMD 0x03
|
||||
#define XPRG_PARAM_NVMCSR 0x04
|
||||
#define XPRG_PARAM_NVMCMD_REG 0x03 /* Undocumented, Reverse-engineered */
|
||||
#define XPRG_PARAM_NVMCSR_REG 0x04 /* Undocumented, Reverse-engineered */
|
||||
|
||||
#define XPRG_PROTOCOL_PDI 0x00
|
||||
#define XPRG_PROTOCOL_JTAG 0x01
|
||||
#define XPRG_PROTOCOL_TPI 0x02
|
||||
#define XPRG_PROTOCOL_TPI 0x02 /* Undocumented, Reverse-engineered */
|
||||
|
||||
#define XPRG_PAGEMODE_WRITE (1 << 1)
|
||||
#define XPRG_PAGEMODE_ERASE (1 << 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue