aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-05-13 09:25:17 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-05-13 09:25:17 +0000
commitcd0093a14bd12d61ceab6860341c1a1fcd0ebb04 (patch)
treead4402b674c74297f30c2a72b1522c2ac1d475ee /Projects/AVRISP-MKII
parent1331cce08a6e899b15382dd1c6110565ed1b34c5 (diff)
downloadlufa-cd0093a14bd12d61ceab6860341c1a1fcd0ebb04.tar.gz
lufa-cd0093a14bd12d61ceab6860341c1a1fcd0ebb04.tar.bz2
lufa-cd0093a14bd12d61ceab6860341c1a1fcd0ebb04.zip
Fixed AVRISP-MKII clone project not correctly issuing SET EXTENDED ADDRESS commands when the extended address boundary is crossed during programming or readback (thanks to Gerard Sexton).
Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled.
Diffstat (limited to 'Projects/AVRISP-MKII')
-rw-r--r--Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c46
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h2
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h2
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h2
4 files changed, 40 insertions, 12 deletions
diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
index a16504da1..430772ddc 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
@@ -227,8 +227,18 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
PollAddress = (CurrentAddress & 0xFFFF);
}
- if (IsOddByte || (V2Command == CMD_PROGRAM_EEPROM_ISP))
- CurrentAddress++;
+ /* EEPROM just increments the address each byte, flash needs to increment on each word and
+ * also check to ensure that a LOAD EXTENDED ADDRESS command is issued each time the extended
+ * address boundary has been crossed */
+ if (V2Command == CMD_PROGRAM_EEPROM_ISP)
+ {
+ CurrentAddress++;
+ }
+ else if (IsOddByte)
+ {
+ if (!(++CurrentAddress & 0xFFFF))
+ ISPTarget_LoadExtendedAddress();
+ }
}
/* If the current page must be committed, send the PROGRAM PAGE command to the target */
@@ -276,8 +286,18 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
PollAddress = (CurrentAddress & 0xFFFF);
}
- if (IsOddByte || (V2Command == CMD_PROGRAM_EEPROM_ISP))
- CurrentAddress++;
+ /* EEPROM just increments the address each byte, flash needs to increment on each word and
+ * also check to ensure that a LOAD EXTENDED ADDRESS command is issued each time the extended
+ * address boundary has been crossed */
+ if (V2Command == CMD_PROGRAM_EEPROM_ISP)
+ {
+ CurrentAddress++;
+ }
+ else if (IsOddByte)
+ {
+ if (!(++CurrentAddress & 0xFFFF))
+ ISPTarget_LoadExtendedAddress();
+ }
ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue,
Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]);
@@ -346,11 +366,19 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
* or low byte at the current word address */
if (V2Command == CMD_READ_FLASH_ISP)
Read_Memory_Params.ReadMemoryCommand ^= READ_WRITE_HIGH_BYTE_MASK;
-
- /* Only increment the current address if we have read both bytes in the current word when in FLASH
- * read mode, or for each byte when in EEPROM read mode */
- if (((CurrentByte & 0x01) && (V2Command == CMD_READ_FLASH_ISP)) || (V2Command == CMD_READ_EEPROM_ISP))
- CurrentAddress++;
+
+ /* EEPROM just increments the address each byte, flash needs to increment on each word and
+ * also check to ensure that a LOAD EXTENDED ADDRESS command is issued each time the extended
+ * address boundary has been crossed */
+ if (V2Command == CMD_READ_EEPROM_ISP)
+ {
+ CurrentAddress++;
+ }
+ else if (CurrentByte & 0x01)
+ {
+ if (!(++CurrentAddress & 0xFFFF))
+ ISPTarget_LoadExtendedAddress();
+ }
}
Endpoint_Write_Byte(STATUS_CMD_OK);
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h
index 73bf1f953..2daca16fc 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h
@@ -68,7 +68,7 @@
bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint16_t WriteLength);
bool TINYNVM_EraseMemory(const uint8_t EraseCommand, const uint16_t Address);
- #if defined(INCLUDE_FROM_TINYNVM_C)
+ #if (defined(INCLUDE_FROM_TINYNVM_C) && defined(ENABLE_XPROG_PROTOCOL))
static void TINYNVM_SendReadNVMRegister(const uint8_t Address);
static void TINYNVM_SendWriteNVMRegister(const uint8_t Address);
static void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress);
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
index 1fdb5a1b8..c812578e5 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
@@ -119,7 +119,7 @@
void XPROGProtocol_SetMode(void);
void XPROGProtocol_Command(void);
- #if defined(INCLUDE_FROM_XPROGPROTOCOL_C)
+ #if (defined(INCLUDE_FROM_XPROGPROTOCOL_C) && defined(ENABLE_XPROG_PROTOCOL))
static void XPROGProtocol_EnterXPROGMode(void);
static void XPROGProtocol_LeaveXPROGMode(void);
static void XPROGProtocol_SetParam(void);
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h
index 436f0f30d..db233a1a4 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h
@@ -118,7 +118,7 @@
void XPROGTarget_SendBreak(void);
bool XPROGTarget_WaitWhileNVMBusBusy(void);
- #if defined(INCLUDE_FROM_XPROGTARGET_C)
+ #if (defined(INCLUDE_FROM_XPROGTARGET_C) && defined(ENABLE_XPROG_PROTOCOL))
static void XPROGTarget_SetTxMode(void);
static void XPROGTarget_SetRxMode(void);
#endif