aboutsummaryrefslogtreecommitdiffstats
path: root/Projects
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-10-27 22:36:02 +0100
committerDean Camera <dean@fourwalledcubicle.com>2013-10-27 22:36:02 +0100
commit85141b37f9325b9b02dfffa3319c47f0e57df340 (patch)
tree7eadf83b9af56e08aebf72cf2635ab6a3597833d /Projects
parent560e5f75fb67d43bd3a586aaaa488547dbd90f7e (diff)
downloadlufa-85141b37f9325b9b02dfffa3319c47f0e57df340.tar.gz
lufa-85141b37f9325b9b02dfffa3319c47f0e57df340.tar.bz2
lufa-85141b37f9325b9b02dfffa3319c47f0e57df340.zip
Use non-abbreviated XPROG/PDI/TPI constant names.
Diffstat (limited to 'Projects')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c72
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h3
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c126
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h100
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h8
5 files changed, 155 insertions, 154 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
index da32f03dd..855ff7fcb 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
@@ -97,14 +97,14 @@ bool XMEGANVM_WaitWhileNVMBusBusy(void)
bool XMEGANVM_WaitWhileNVMControllerBusy(void)
{
/* Preload the pointer register with the NVM STATUS register address to check the BUSY flag */
- XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATSIZE_4BYTES));
+ XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATASIZE_4BYTES));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_STATUS);
/* Poll the NVM STATUS register while the NVM controller is busy */
for (;;)
{
/* Fetch the current status value via the pointer register (without auto-increment afterwards) */
- XPROGTarget_SendByte(PDI_CMD_LD(PDI_POINTER_INDIRECT, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_LD(PDI_POINTER_INDIRECT, PDI_DATASIZE_1BYTE));
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
@@ -182,12 +182,12 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand,
return false;
/* Set the NVM command to the correct CRC read command */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(CRCCommand);
/* Set CMDEX bit in NVM CTRLA register to start the CRC generation */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
@@ -200,15 +200,15 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand,
return false;
/* Load the PDI pointer register with the DAT0 register start address */
- XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATSIZE_4BYTES));
+ XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATASIZE_4BYTES));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT0);
/* Send the REPEAT command to grab the CRC bytes */
- XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATASIZE_1BYTE));
XPROGTarget_SendByte(XMEGA_CRC_LENGTH_BYTES - 1);
/* Read in the CRC bytes from the target */
- XPROGTarget_SendByte(PDI_CMD_LD(PDI_POINTER_INDIRECT_PI, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_LD(PDI_POINTER_INDIRECT_PI, PDI_DATASIZE_1BYTE));
for (uint8_t i = 0; i < XMEGA_CRC_LENGTH_BYTES; i++)
((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
@@ -232,29 +232,29 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress,
return false;
/* Send the READNVM command to the NVM controller for reading of an arbitrary location */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(XMEGA_NVM_CMD_READNVM);
if (ReadSize > 1)
{
/* Load the PDI pointer register with the start address we want to read from */
- XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATSIZE_4BYTES));
+ XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATASIZE_4BYTES));
XMEGANVM_SendAddress(ReadAddress);
/* Send the REPEAT command with the specified number of bytes to read */
- XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATASIZE_1BYTE));
XPROGTarget_SendByte(ReadSize - 1);
/* Send a LD command with indirect access and post-increment to read out the bytes */
- XPROGTarget_SendByte(PDI_CMD_LD(PDI_POINTER_INDIRECT_PI, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_LD(PDI_POINTER_INDIRECT_PI, PDI_DATASIZE_1BYTE));
while (ReadSize-- && TimeoutTicksRemaining)
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
}
else
{
/* Send a LDS command with the read address to read out the requested byte */
- XPROGTarget_SendByte(PDI_CMD_LDS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_LDS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendAddress(ReadAddress);
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
}
@@ -279,12 +279,12 @@ bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand,
return false;
/* Send the memory write command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(WriteCommand);
/* Send new memory byte to the memory of the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendAddress(WriteAddress);
XPROGTarget_SendByte(Byte);
@@ -311,19 +311,19 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand,
const uint8_t* WriteBuffer,
uint16_t WriteSize)
{
- if (PageMode & XPRG_PAGEMODE_ERASE)
+ if (PageMode & XPROG_PAGEMODE_ERASE)
{
/* Wait until the NVM controller is no longer busy */
if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
return false;
/* Send the memory buffer erase command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(EraseBuffCommand);
/* Set CMDEX bit in NVM CTRLA register to start the buffer erase */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
}
@@ -335,37 +335,37 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand,
return false;
/* Send the memory buffer write command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(WriteBuffCommand);
/* Load the PDI pointer register with the start address we want to write to */
- XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATSIZE_4BYTES));
+ XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATASIZE_4BYTES));
XMEGANVM_SendAddress(WriteAddress);
/* Send the REPEAT command with the specified number of bytes to write */
- XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATASIZE_1BYTE));
XPROGTarget_SendByte(WriteSize - 1);
/* Send a ST command with indirect access and post-increment to write the bytes */
- XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_INDIRECT_PI, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_INDIRECT_PI, PDI_DATASIZE_1BYTE));
while (WriteSize--)
XPROGTarget_SendByte(*(WriteBuffer++));
}
- if (PageMode & XPRG_PAGEMODE_WRITE)
+ if (PageMode & XPROG_PAGEMODE_WRITE)
{
/* Wait until the NVM controller is no longer busy */
if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
return false;
/* Send the memory write command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(WritePageCommand);
/* Send the address of the first page location to write the memory page */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendAddress(WriteAddress);
XPROGTarget_SendByte(0x00);
}
@@ -391,24 +391,24 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand,
if (EraseCommand == XMEGA_NVM_CMD_CHIPERASE)
{
/* Send the memory erase command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(EraseCommand);
/* Set CMDEX bit in NVM CTRLA register to start the erase sequence */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
}
else if (EraseCommand == XMEGA_NVM_CMD_ERASEEEPROM)
{
/* Send the EEPROM page buffer erase command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(XMEGA_NVM_CMD_ERASEEEPROMPAGEBUFF);
/* Set CMDEX bit in NVM CTRLA register to start the buffer erase */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
@@ -417,42 +417,42 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand,
return false;
/* Send the EEPROM memory buffer write command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(XMEGA_NVM_CMD_LOADEEPROMPAGEBUFF);
/* Load the PDI pointer register with the EEPROM page start address */
- XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATSIZE_4BYTES));
+ XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_DIRECT, PDI_DATASIZE_4BYTES));
XMEGANVM_SendAddress(Address);
/* Send the REPEAT command with the specified number of bytes to write */
- XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_REPEAT(PDI_DATASIZE_1BYTE));
XPROGTarget_SendByte(XPROG_Param_EEPageSize - 1);
/* Send a ST command with indirect access and post-increment to tag each byte in the EEPROM page buffer */
- XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_INDIRECT_PI, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_ST(PDI_POINTER_INDIRECT_PI, PDI_DATASIZE_1BYTE));
for (uint8_t PageByte = 0; PageByte < XPROG_Param_EEPageSize; PageByte++)
XPROGTarget_SendByte(0x00);
/* Send the memory erase command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(EraseCommand);
/* Set CMDEX bit in NVM CTRLA register to start the EEPROM erase sequence */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
XPROGTarget_SendByte(XMEGA_NVM_BIT_CTRLA_CMDEX);
}
else
{
/* Send the memory erase command to the target */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(EraseCommand);
/* Other erase modes just need us to address a byte within the target memory space */
- XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATSIZE_4BYTES, PDI_DATSIZE_1BYTE));
+ XPROGTarget_SendByte(PDI_CMD_STS(PDI_DATASIZE_4BYTES, PDI_DATASIZE_1BYTE));
XMEGANVM_SendAddress(Address);
XPROGTarget_SendByte(0x00);
}
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h
index c8450cbef..37329cc2e 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h
@@ -116,7 +116,8 @@
bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand,
uint32_t* const CRCDest);
bool XMEGANVM_ReadMemory(const uint32_t ReadAddress,
- uint8_t* ReadBuffer, uint16_t ReadSize);
+ uint8_t* ReadBuffer,
+ uint16_t ReadSize);
bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand,
const uint32_t WriteAddress,
const uint8_t Byte);
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
index 17a8b47ff..33a1cc68d 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
@@ -50,7 +50,7 @@ uint8_t XPROG_Param_NVMCMDRegAddr = 0x33;
uint8_t XPROG_Param_NVMCSRRegAddr = 0x32;
/** Currently selected XPROG programming protocol */
-uint8_t XPROG_SelectedProtocol = XPRG_PROTOCOL_PDI;
+uint8_t XPROG_SelectedProtocol = XPROG_PROTOCOL_PDI;
/** Handler for the CMD_XPROG_SETMODE command, which sets the programmer-to-target protocol used for PDI/TPI
* programming.
@@ -71,7 +71,7 @@ void XPROGProtocol_SetMode(void)
XPROG_SelectedProtocol = SetMode_XPROG_Params.Protocol;
Endpoint_Write_8(CMD_XPROG_SETMODE);
- Endpoint_Write_8((SetMode_XPROG_Params.Protocol != XPRG_PROTOCOL_JTAG) ? STATUS_CMD_OK : STATUS_CMD_FAILED);
+ Endpoint_Write_8((SetMode_XPROG_Params.Protocol != XPROG_PROTOCOL_JTAG) ? STATUS_CMD_OK : STATUS_CMD_FAILED);
Endpoint_ClearIN();
}
@@ -84,25 +84,25 @@ void XPROGProtocol_Command(void)
switch (XPROGCommand)
{
- case XPRG_CMD_ENTER_PROGMODE:
+ case XPROG_CMD_ENTER_PROGMODE:
XPROGProtocol_EnterXPROGMode();
break;
- case XPRG_CMD_LEAVE_PROGMODE:
+ case XPROG_CMD_LEAVE_PROGMODE:
XPROGProtocol_LeaveXPROGMode();
break;
- case XPRG_CMD_ERASE:
+ case XPROG_CMD_ERASE:
XPROGProtocol_Erase();
break;
- case XPRG_CMD_WRITE_MEM:
+ case XPROG_CMD_WRITE_MEM:
XPROGProtocol_WriteMemory();
break;
- case XPRG_CMD_READ_MEM:
+ case XPROG_CMD_READ_MEM:
XPROGProtocol_ReadMemory();
break;
- case XPRG_CMD_CRC:
+ case XPROG_CMD_CRC:
XPROGProtocol_ReadCRC();
break;
- case XPRG_CMD_SET_PARAM:
+ case XPROG_CMD_SET_PARAM:
XPROGProtocol_SetParam();
break;
}
@@ -117,14 +117,14 @@ static void XPROGProtocol_EnterXPROGMode(void)
bool NVMBusEnabled = false;
- if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
+ if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
NVMBusEnabled = XMEGANVM_EnablePDI();
- else if (XPROG_SelectedProtocol == XPRG_PROTOCOL_TPI)
+ else if (XPROG_SelectedProtocol == XPROG_PROTOCOL_TPI)
NVMBusEnabled = TINYNVM_EnableTPI();
Endpoint_Write_8(CMD_XPROG);
- Endpoint_Write_8(XPRG_CMD_ENTER_PROGMODE);
- Endpoint_Write_8(NVMBusEnabled ? XPRG_ERR_OK : XPRG_ERR_FAILED);
+ Endpoint_Write_8(XPROG_CMD_ENTER_PROGMODE);
+ Endpoint_Write_8(NVMBusEnabled ? XPROG_ERR_OK : XPROG_ERR_FAILED);
Endpoint_ClearIN();
}
@@ -137,7 +137,7 @@ static void XPROGProtocol_LeaveXPROGMode(void)
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPADDR);
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
- if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
+ if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
XMEGANVM_DisablePDI();
else
TINYNVM_DisableTPI();
@@ -149,15 +149,15 @@ static void XPROGProtocol_LeaveXPROGMode(void)
#endif
Endpoint_Write_8(CMD_XPROG);
- Endpoint_Write_8(XPRG_CMD_LEAVE_PROGMODE);
- Endpoint_Write_8(XPRG_ERR_OK);
+ Endpoint_Write_8(XPROG_CMD_LEAVE_PROGMODE);
+ Endpoint_Write_8(XPROG_ERR_OK);
Endpoint_ClearIN();
}
/** Handler for the XPRG ERASE command to erase a specific memory address space in the attached device. */
static void XPROGProtocol_Erase(void)
{
- uint8_t ReturnStatus = XPRG_ERR_OK;
+ uint8_t ReturnStatus = XPROG_ERR_OK;
struct
{
@@ -174,33 +174,33 @@ static void XPROGProtocol_Erase(void)
uint8_t EraseCommand;
- if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
+ if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
{
/* Determine which NVM command to send to the device depending on the memory to erase */
switch (Erase_XPROG_Params.MemoryType)
{
- case XPRG_ERASE_CHIP:
+ case XPROG_ERASE_CHIP:
EraseCommand = XMEGA_NVM_CMD_CHIPERASE;
break;
- case XPRG_ERASE_APP:
+ case XPROG_ERASE_APP:
EraseCommand = XMEGA_NVM_CMD_ERASEAPPSEC;
break;
- case XPRG_ERASE_BOOT:
+ case XPROG_ERASE_BOOT:
EraseCommand = XMEGA_NVM_CMD_ERASEBOOTSEC;
break;
- case XPRG_ERASE_EEPROM:
+ case XPROG_ERASE_EEPROM:
EraseCommand = XMEGA_NVM_CMD_ERASEEEPROM;
break;
- case XPRG_ERASE_APP_PAGE:
+ case XPROG_ERASE_APP_PAGE:
EraseCommand = XMEGA_NVM_CMD_ERASEAPPSECPAGE;
break;
- case XPRG_ERASE_BOOT_PAGE:
+ case XPROG_ERASE_BOOT_PAGE:
EraseCommand = XMEGA_NVM_CMD_ERASEBOOTSECPAGE;
break;
- case XPRG_ERASE_EEPROM_PAGE:
+ case XPROG_ERASE_EEPROM_PAGE:
EraseCommand = XMEGA_NVM_CMD_ERASEEEPROMPAGE;
break;
- case XPRG_ERASE_USERSIG:
+ case XPROG_ERASE_USERSIG:
EraseCommand = XMEGA_NVM_CMD_ERASEUSERSIG;
break;
default:
@@ -210,22 +210,22 @@ static void XPROGProtocol_Erase(void)
/* Erase the target memory, indicate timeout if occurred */
if (!(XMEGANVM_EraseMemory(EraseCommand, Erase_XPROG_Params.Address)))
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ ReturnStatus = XPROG_ERR_TIMEOUT;
}
else
{
- if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_CHIP)
+ if (Erase_XPROG_Params.MemoryType == XPROG_ERASE_CHIP)
EraseCommand = TINY_NVM_CMD_CHIPERASE;
else
EraseCommand = TINY_NVM_CMD_SECTIONERASE;
/* Erase the target memory, indicate timeout if occurred */
if (!(TINYNVM_EraseMemory(EraseCommand, Erase_XPROG_Params.Address)))
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ ReturnStatus = XPROG_ERR_TIMEOUT;
}
Endpoint_Write_8(CMD_XPROG);
- Endpoint_Write_8(XPRG_CMD_ERASE);
+ Endpoint_Write_8(XPROG_CMD_ERASE);
Endpoint_Write_8(ReturnStatus);
Endpoint_ClearIN();
}
@@ -233,7 +233,7 @@ static void XPROGProtocol_Erase(void)
/** Handler for the XPROG WRITE_MEMORY command to write to a specific memory space within the attached device. */
static void XPROGProtocol_WriteMemory(void)
{
- uint8_t ReturnStatus = XPRG_ERR_OK;
+ uint8_t ReturnStatus = XPROG_ERR_OK;
struct
{
@@ -263,7 +263,7 @@ static void XPROGProtocol_WriteMemory(void)
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPADDR);
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
- if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
+ if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
{
/* Assume FLASH page programming by default, as it is the common case */
uint8_t WriteCommand = XMEGA_NVM_CMD_WRITEFLASHPAGE;
@@ -273,25 +273,25 @@ static void XPROGProtocol_WriteMemory(void)
switch (WriteMemory_XPROG_Params.MemoryType)
{
- case XPRG_MEM_TYPE_APPL:
+ case XPROG_MEM_TYPE_APPL:
WriteCommand = XMEGA_NVM_CMD_WRITEAPPSECPAGE;
break;
- case XPRG_MEM_TYPE_BOOT:
+ case XPROG_MEM_TYPE_BOOT:
WriteCommand = XMEGA_NVM_CMD_WRITEBOOTSECPAGE;
break;
- case XPRG_MEM_TYPE_EEPROM:
+ case XPROG_MEM_TYPE_EEPROM:
WriteCommand = XMEGA_NVM_CMD_ERASEWRITEEEPROMPAGE;
WriteBuffCommand = XMEGA_NVM_CMD_LOADEEPROMPAGEBUFF;
EraseBuffCommand = XMEGA_NVM_CMD_ERASEEEPROMPAGEBUFF;
break;
- case XPRG_MEM_TYPE_USERSIG:
+ case XPROG_MEM_TYPE_USERSIG:
WriteCommand = XMEGA_NVM_CMD_WRITEUSERSIG;
break;
- case XPRG_MEM_TYPE_FUSE:
+ case XPROG_MEM_TYPE_FUSE:
WriteCommand = XMEGA_NVM_CMD_WRITEFUSE;
PagedMemory = false;
break;
- case XPRG_MEM_TYPE_LOCKBITS:
+ case XPROG_MEM_TYPE_LOCKBITS:
WriteCommand = XMEGA_NVM_CMD_WRITELOCK;
PagedMemory = false;
break;
@@ -304,7 +304,7 @@ static void XPROGProtocol_WriteMemory(void)
(!PagedMemory && !(XMEGANVM_WriteByteMemory(WriteCommand, WriteMemory_XPROG_Params.Address,
WriteMemory_XPROG_Params.ProgData[0]))))
{
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ ReturnStatus = XPROG_ERR_TIMEOUT;
}
}
else
@@ -313,12 +313,12 @@ static void XPROGProtocol_WriteMemory(void)
if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData,
WriteMemory_XPROG_Params.Length)))
{
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ ReturnStatus = XPROG_ERR_TIMEOUT;
}
}
Endpoint_Write_8(CMD_XPROG);
- Endpoint_Write_8(XPRG_CMD_WRITE_MEM);
+ Endpoint_Write_8(XPROG_CMD_WRITE_MEM);
Endpoint_Write_8(ReturnStatus);
Endpoint_ClearIN();
}
@@ -328,7 +328,7 @@ static void XPROGProtocol_WriteMemory(void)
*/
static void XPROGProtocol_ReadMemory(void)
{
- uint8_t ReturnStatus = XPRG_ERR_OK;
+ uint8_t ReturnStatus = XPROG_ERR_OK;
struct
{
@@ -347,24 +347,24 @@ static void XPROGProtocol_ReadMemory(void)
uint8_t ReadBuffer[256];
- if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
+ if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
{
/* Read the PDI target's memory, indicate timeout if occurred */
if (!(XMEGANVM_ReadMemory(ReadMemory_XPROG_Params.Address, ReadBuffer, ReadMemory_XPROG_Params.Length)))
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ ReturnStatus = XPROG_ERR_TIMEOUT;
}
else
{
/* Read the TPI target's memory, indicate timeout if occurred */
if (!(TINYNVM_ReadMemory(ReadMemory_XPROG_Params.Address, ReadBuffer, ReadMemory_XPROG_Params.Length)))
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ ReturnStatus = XPROG_ERR_TIMEOUT;
}
Endpoint_Write_8(CMD_XPROG);
- Endpoint_Write_8(XPRG_CMD_READ_MEM);
+ Endpoint_Write_8(XPROG_CMD_READ_MEM);
Endpoint_Write_8(ReturnStatus);
- if (ReturnStatus == XPRG_ERR_OK)
+ if (ReturnStatus == XPROG_ERR_OK)
Endpoint_Write_Stream_LE(ReadBuffer, ReadMemory_XPROG_Params.Length, NULL);
Endpoint_ClearIN();
@@ -375,7 +375,7 @@ static void XPROGProtocol_ReadMemory(void)
*/
static void XPROGProtocol_ReadCRC(void)
{
- uint8_t ReturnStatus = XPRG_ERR_OK;
+ uint8_t ReturnStatus = XPROG_ERR_OK;
struct
{
@@ -390,17 +390,17 @@ static void XPROGProtocol_ReadCRC(void)
uint32_t MemoryCRC;
- if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
+ if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
{
uint8_t CRCCommand;
/* Determine which NVM command to send to the device depending on the memory to CRC */
switch (ReadCRC_XPROG_Params.CRCType)
{
- case XPRG_CRC_APP:
+ case XPROG_CRC_APP:
CRCCommand = XMEGA_NVM_CMD_APPCRC;
break;
- case XPRG_CRC_BOOT:
+ case XPROG_CRC_BOOT:
CRCCommand = XMEGA_NVM_CMD_BOOTCRC;
break;
default:
@@ -410,19 +410,19 @@ static void XPROGProtocol_ReadCRC(void)
/* Perform and retrieve the memory CRC, indicate timeout if occurred */
if (!(XMEGANVM_GetMemoryCRC(CRCCommand, &MemoryCRC)))
- ReturnStatus = XPRG_ERR_TIMEOUT;
+ ReturnStatus = XPROG_ERR_TIMEOUT;
}
else
{
/* TPI does not support memory CRC */
- ReturnStatus = XPRG_ERR_FAILED;
+ ReturnStatus = XPROG_ERR_FAILED;
}
Endpoint_Write_8(CMD_XPROG);
- Endpoint_Write_8(XPRG_CMD_CRC);
+ Endpoint_Write_8(XPROG_CMD_CRC);
Endpoint_Write_8(ReturnStatus);
- if (ReturnStatus == XPRG_ERR_OK)
+ if (ReturnStatus == XPROG_ERR_OK)
{
Endpoint_Write_8(MemoryCRC >> 16);
Endpoint_Write_16_LE(MemoryCRC & 0xFFFF);
@@ -436,33 +436,33 @@ static void XPROGProtocol_ReadCRC(void)
*/
static void XPROGProtocol_SetParam(void)
{
- uint8_t ReturnStatus = XPRG_ERR_OK;
+ uint8_t ReturnStatus = XPROG_ERR_OK;
uint8_t XPROGParam = Endpoint_Read_8();
/* Determine which parameter is being set, store the new parameter value */
switch (XPROGParam)
{
- case XPRG_PARAM_NVMBASE:
+ case XPROG_PARAM_NVMBASE:
XPROG_Param_NVMBase = Endpoint_Read_32_BE();
break;
- case XPRG_PARAM_EEPPAGESIZE:
+ case XPROG_PARAM_EEPPAGESIZE:
XPROG_Param_EEPageSize = Endpoint_Read_16_BE();
break;
- case XPRG_PARAM_NVMCMD_REG:
+ case XPROG_PARAM_NVMCMD_REG:
XPROG_Param_NVMCMDRegAddr = Endpoint_Read_8();
break;
- case XPRG_PARAM_NVMCSR_REG:
+ case XPROG_PARAM_NVMCSR_REG:
XPROG_Param_NVMCSRRegAddr = Endpoint_Read_8();
break;
- case XPRG_PARAM_UNKNOWN_1:
+ case XPROG_PARAM_UNKNOWN_1:
/* TODO: Undocumented parameter added in AVRStudio 5.1, purpose unknown. Must ACK and discard or
the communication with AVRStudio 5.1 will fail.
*/
Endpoint_Discard_16();
break;
default:
- ReturnStatus = XPRG_ERR_FAILED;
+ ReturnStatus = XPROG_ERR_FAILED;
break;
}
@@ -471,7 +471,7 @@ static void XPROGProtocol_SetParam(void)
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
Endpoint_Write_8(CMD_XPROG);
- Endpoint_Write_8(XPRG_CMD_SET_PARAM);
+ Endpoint_Write_8(XPROG_CMD_SET_PARAM);
Endpoint_Write_8(ReturnStatus);
Endpoint_ClearIN();
}
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
index 232ab53f2..ae0aa3465 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
@@ -47,7 +47,7 @@
#include "XMEGANVM.h"
#include "TINYNVM.h"
#include "Config/AppConfig.h"
-
+
/* Preprocessor Checks: */
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
/* On the XPLAIN board, we only need PDI programming
@@ -62,55 +62,55 @@
#endif
/* Macros: */
- #define XPRG_CMD_ENTER_PROGMODE 0x01
- #define XPRG_CMD_LEAVE_PROGMODE 0x02
- #define XPRG_CMD_ERASE 0x03
- #define XPRG_CMD_WRITE_MEM 0x04
- #define XPRG_CMD_READ_MEM 0x05
- #define XPRG_CMD_CRC 0x06
- #define XPRG_CMD_SET_PARAM 0x07
-
- #define XPRG_MEM_TYPE_APPL 1
- #define XPRG_MEM_TYPE_BOOT 2
- #define XPRG_MEM_TYPE_EEPROM 3
- #define XPRG_MEM_TYPE_FUSE 4
- #define XPRG_MEM_TYPE_LOCKBITS 5
- #define XPRG_MEM_TYPE_USERSIG 6
- #define XPRG_MEM_TYPE_FACTORY_CALIBRATION 7
-
- #define XPRG_ERASE_CHIP 1
- #define XPRG_ERASE_APP 2
- #define XPRG_ERASE_BOOT 3
- #define XPRG_ERASE_EEPROM 4
- #define XPRG_ERASE_APP_PAGE 5
- #define XPRG_ERASE_BOOT_PAGE 6
- #define XPRG_ERASE_EEPROM_PAGE 7
- #define XPRG_ERASE_USERSIG 8
-
- #define XPRG_MEM_WRITE_ERASE 0
- #define XPRG_MEM_WRITE_WRITE 1
-
- #define XPRG_CRC_APP 1
- #define XPRG_CRC_BOOT 2
- #define XPRG_CRC_FLASH 3
-
- #define XPRG_ERR_OK 0
- #define XPRG_ERR_FAILED 1
- #define XPRG_ERR_COLLISION 2
- #define XPRG_ERR_TIMEOUT 3
-
- #define XPRG_PARAM_NVMBASE 0x01
- #define XPRG_PARAM_EEPPAGESIZE 0x02
- #define XPRG_PARAM_NVMCMD_REG 0x03
- #define XPRG_PARAM_NVMCSR_REG 0x04
- #define XPRG_PARAM_UNKNOWN_1 0x05
-
- #define XPRG_PROTOCOL_PDI 0x00
- #define XPRG_PROTOCOL_JTAG 0x01
- #define XPRG_PROTOCOL_TPI 0x02
-
- #define XPRG_PAGEMODE_WRITE (1 << 1)
- #define XPRG_PAGEMODE_ERASE (1 << 0)
+ #define XPROG_CMD_ENTER_PROGMODE 0x01
+ #define XPROG_CMD_LEAVE_PROGMODE 0x02
+ #define XPROG_CMD_ERASE 0x03
+ #define XPROG_CMD_WRITE_MEM 0x04
+ #define XPROG_CMD_READ_MEM 0x05
+ #define XPROG_CMD_CRC 0x06
+ #define XPROG_CMD_SET_PARAM 0x07
+
+ #define XPROG_MEM_TYPE_APPL 1
+ #define XPROG_MEM_TYPE_BOOT 2
+ #define XPROG_MEM_TYPE_EEPROM 3
+ #define XPROG_MEM_TYPE_FUSE 4
+ #define XPROG_MEM_TYPE_LOCKBITS 5
+ #define XPROG_MEM_TYPE_USERSIG 6
+ #define XPROG_MEM_TYPE_FACTORY_CALIBRATION 7
+
+ #define XPROG_ERASE_CHIP 1
+ #define XPROG_ERASE_APP 2
+ #define XPROG_ERASE_BOOT 3
+ #define XPROG_ERASE_EEPROM 4
+ #define XPROG_ERASE_APP_PAGE 5
+ #define XPROG_ERASE_BOOT_PAGE 6
+ #define XPROG_ERASE_EEPROM_PAGE 7
+ #define XPROG_ERASE_USERSIG 8
+
+ #define XPROG_MEM_WRITE_ERASE 0
+ #define XPROG_MEM_WRITE_WRITE 1
+
+ #define XPROG_CRC_APP 1
+ #define XPROG_CRC_BOOT 2
+ #define XPROG_CRC_FLASH 3
+
+ #define XPROG_ERR_OK 0
+ #define XPROG_ERR_FAILED 1
+ #define XPROG_ERR_COLLISION 2
+ #define XPROG_ERR_TIMEOUT 3
+
+ #define XPROG_PARAM_NVMBASE 0x01
+ #define XPROG_PARAM_EEPPAGESIZE 0x02
+ #define XPROG_PARAM_NVMCMD_REG 0x03
+ #define XPROG_PARAM_NVMCSR_REG 0x04
+ #define XPROG_PARAM_UNKNOWN_1 0x05
+
+ #define XPROG_PROTOCOL_PDI 0x00
+ #define XPROG_PROTOCOL_JTAG 0x01
+ #define XPROG_PROTOCOL_TPI 0x02
+
+ #define XPROG_PAGEMODE_WRITE (1 << 1)
+ #define XPROG_PAGEMODE_ERASE (1 << 0)
/* External Variables: */
extern uint32_t XPROG_Param_NVMBase;
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h
index 0f6758ca9..b6e924b19 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h
@@ -83,10 +83,10 @@
#define PDI_RESET_KEY 0x59
#define PDI_NVMENABLE_KEY (uint8_t[]){0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF}
- #define PDI_DATSIZE_1BYTE 0
- #define PDI_DATSIZE_2BYTES 1
- #define PDI_DATSIZE_3BYTES 2
- #define PDI_DATSIZE_4BYTES 3
+ #define PDI_DATASIZE_1BYTE 0
+ #define PDI_DATASIZE_2BYTES 1
+ #define PDI_DATASIZE_3BYTES 2
+ #define PDI_DATASIZE_4BYTES 3
#define PDI_POINTER_INDIRECT 0
#define PDI_POINTER_INDIRECT_PI 1