aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII/Lib/ISP
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-02-01 03:42:10 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-02-01 03:42:10 +0000
commit5f363996e3b6fc66017ff02eb2de6f477e0f328e (patch)
tree0e202ad0d80e4b7351c503a7cca00eac3cccfef6 /Projects/AVRISP-MKII/Lib/ISP
parentb6a4584a19e81c2e1f909355bbc64c2b8cea84f6 (diff)
downloadlufa-5f363996e3b6fc66017ff02eb2de6f477e0f328e.tar.gz
lufa-5f363996e3b6fc66017ff02eb2de6f477e0f328e.tar.bz2
lufa-5f363996e3b6fc66017ff02eb2de6f477e0f328e.zip
Fixed issues with EEPROM and FLASH ISP programming in the AVRISP project.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/ISP')
-rw-r--r--Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c15
-rw-r--r--Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c2
2 files changed, 9 insertions, 8 deletions
diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
index 59a77e575..33ccbf91e 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
@@ -198,14 +198,15 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
* or low byte at the current word address */
- Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
+ if (V2Command == CMD_PROGRAM_FLASH_ISP)
+ Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
/* Check to see the write completion method, to see if we have a valid polling address */
if (!(PollAddress) && (ByteToWrite != PollValue))
{
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
Write_Memory_Params.ProgrammingCommands[2] |= READ_WRITE_HIGH_BYTE_MASK;
-
+
PollAddress = (CurrentAddress & 0xFFFF);
}
@@ -239,17 +240,17 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
{
bool IsOddByte = (CurrentByte & 0x01);
uint8_t ByteToWrite = *(NextWriteByte++);
-
- if (IsOddByte && (V2Command == CMD_READ_FLASH_ISP))
- Write_Memory_Params.ProgrammingCommands[0] |= READ_WRITE_HIGH_BYTE_MASK;
- else
- Write_Memory_Params.ProgrammingCommands[0] &= ~READ_WRITE_HIGH_BYTE_MASK;
SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]);
SPI_SendByte(CurrentAddress >> 8);
SPI_SendByte(CurrentAddress & 0xFF);
SPI_SendByte(ByteToWrite);
+ /* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
+ * or low byte at the current word address */
+ if (V2Command == CMD_PROGRAM_FLASH_ISP)
+ Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
+
if (ByteToWrite != PollValue)
{
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
index 19b0aa07b..c9822d0a6 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
@@ -128,7 +128,7 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1
SPI_SendByte(PollAddress >> 8);
SPI_SendByte(PollAddress & 0xFF);
}
- while ((SPI_TransferByte(0x00) != PollValue) && TimeoutMSRemaining);
+ while ((SPI_TransferByte(0x00) == PollValue) && TimeoutMSRemaining);
if (!(TimeoutMSRemaining))
ProgrammingStatus = STATUS_CMD_TOUT;