aboutsummaryrefslogtreecommitdiff
path: root/Projects/Incomplete/AVRISP/Lib/V2Protocol.c
diff options
context:
space:
mode:
authorDean Camera <[email protected]>2009-08-24 09:37:54 +0000
committerDean Camera <[email protected]>2009-08-24 09:37:54 +0000
commitbff4dbe1897d8c19b4bb9807e76350465ca1f1c4 (patch)
tree5d6f9ffba04b1327b145fc37e24778be856cc8ec /Projects/Incomplete/AVRISP/Lib/V2Protocol.c
parentdbb5f249bd057c7b292645463c52067c1da58efa (diff)
downloadqmk_firmware-bff4dbe1897d8c19b4bb9807e76350465ca1f1c4.tar.gz
qmk_firmware-bff4dbe1897d8c19b4bb9807e76350465ca1f1c4.zip
Fix to V2 Protocol for Fuse/Sig/Lock byte read -- off by one error on the array when writing back the response from the device.
FLASH/EEPROM reading and writing currently broken and unfinished, respectively.
Diffstat (limited to 'Projects/Incomplete/AVRISP/Lib/V2Protocol.c')
-rw-r--r--Projects/Incomplete/AVRISP/Lib/V2Protocol.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/Projects/Incomplete/AVRISP/Lib/V2Protocol.c b/Projects/Incomplete/AVRISP/Lib/V2Protocol.c
index 85e3a382d0..cffb91e025 100644
--- a/Projects/Incomplete/AVRISP/Lib/V2Protocol.c
+++ b/Projects/Incomplete/AVRISP/Lib/V2Protocol.c
@@ -264,9 +264,36 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params));
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);
- for (uint16_t CurrentByte = 0; CurrentByte < Write_Memory_Params.BytesToWrite; CurrentByte++)
+ if (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_WRITES_MASK)
{
- // TODO - Read in programming data, write to device
+ for (uint16_t CurrentByte = 0; CurrentByte < Write_Memory_Params.BytesToWrite; CurrentByte++)
+ {
+ if ((V2Command == CMD_READ_FLASH_ISP) && (CurrentByte & 0x01))
+ Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_ODD_BYTE_MASK;
+
+ SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]);
+ SPI_SendByte(CurrentAddress >> 8);
+ SPI_SendByte(CurrentAddress & 0xFF);
+ SPI_SendByte(Endpoint_Read_Byte());
+
+ // TODO - Correct Polling
+
+ if (((V2Command == CMD_PROGRAM_FLASH_ISP) && (CurrentByte & 0x01)) || (V2Command == CMD_PROGRAM_EEPROM_ISP))
+ CurrentAddress++;
+ }
+
+ /* If the current page must be committed, send the PROGRAM PAGE command to the target */
+ if (Write_Memory_Params.ProgrammingMode & PROG_MODE_COMMIT_PAGE_MASK)
+ {
+ SPI_SendByte(Write_Memory_Params.ProgrammingCommands[1]);
+ SPI_SendByte(CurrentAddress >> 8);
+ SPI_SendByte(CurrentAddress & 0xFF);
+ SPI_SendByte(0x00);
+ }
+ }
+ else
+ {
+ // TODO - Read in programming data, write to device
}
Endpoint_ClearOUT();
@@ -294,7 +321,7 @@ static void V2Protocol_Command_ReadMemory(uint8_t V2Command)
Endpoint_Write_Byte(V2Command);
Endpoint_Write_Byte(STATUS_CMD_OK);
-
+
for (uint16_t CurrentByte = 0; CurrentByte < Read_Memory_Params.BytesToRead; CurrentByte++)
{
if ((V2Command == CMD_READ_FLASH_ISP) && (CurrentByte & 0x01))
@@ -312,7 +339,8 @@ static void V2Protocol_Command_ReadMemory(uint8_t V2Command)
Endpoint_WaitUntilReady();
}
- CurrentAddress++;
+ if (((V2Command == CMD_READ_FLASH_ISP) && (CurrentByte & 0x01)) || (V2Command == CMD_READ_EEPROM_ISP))
+ CurrentAddress++;
}
Endpoint_Write_Byte(STATUS_CMD_OK);
@@ -377,7 +405,7 @@ static void V2Protocol_Command_ReadFuseLockSigOSCCAL(uint8_t V2Command)
Endpoint_Write_Byte(V2Command);
Endpoint_Write_Byte(STATUS_CMD_OK);
- Endpoint_Write_Byte(ResponseBytes[Read_FuseLockSigOSCCAL_Params.RetByte]);
+ Endpoint_Write_Byte(ResponseBytes[Read_FuseLockSigOSCCAL_Params.RetByte - 1]);
Endpoint_Write_Byte(STATUS_CMD_OK);
Endpoint_ClearIN();
}