aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-10-27 18:26:11 +0100
committerDean Camera <dean@fourwalledcubicle.com>2013-10-27 18:26:11 +0100
commite1b19e4e103396c06b4bbce4b82f2f50b21405ad (patch)
tree75595a798fb4b9c83aea8c10adc5cec19ae603f7 /Projects/AVRISP-MKII
parent13b3014db42c933769248420f6c179cd49d181bb (diff)
downloadlufa-e1b19e4e103396c06b4bbce4b82f2f50b21405ad.tar.gz
lufa-e1b19e4e103396c06b4bbce4b82f2f50b21405ad.tar.bz2
lufa-e1b19e4e103396c06b4bbce4b82f2f50b21405ad.zip
More minor speedups to the AVRISP-MKII clone programmer PDI memory reading code.
Diffstat (limited to 'Projects/AVRISP-MKII')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
index 43c540e17..3d7b91365 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
@@ -236,21 +236,28 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress,
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
XPROGTarget_SendByte(XMEGA_NVM_CMD_READNVM);
- /* Load the PDI pointer register with the start address we want to read from */
- XPROGTarget_SendByte(PDI_CMD_ST | (PDI_POINTER_DIRECT << 2) | PDI_DATSIZE_4BYTES);
- XMEGANVM_SendAddress(ReadAddress);
-
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 << 2) | PDI_DATSIZE_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(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 << 2) | PDI_DATSIZE_1BYTE);
- while (ReadSize-- && TimeoutTicksRemaining)
- *(ReadBuffer++) = XPROGTarget_ReceiveByte();
+ /* Send a LD command with indirect access and post-increment to read out the bytes */
+ XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_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 << 2));
+ XMEGANVM_SendAddress(ReadAddress);
+ *(ReadBuffer++) = XPROGTarget_ReceiveByte();
+ }
return (TimeoutTicksRemaining > 0);
}