diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-08-25 08:58:48 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-08-25 08:58:48 +0000 |
commit | 4742e95a3f8ef01715c6d5e740c4aab59d2c2b58 (patch) | |
tree | 170eb265b3a86ec93c9609cc4087167e82d441a7 | |
parent | 6d1adf7339b71952d1ba8616af9422fbc7333eb1 (diff) | |
download | lufa-4742e95a3f8ef01715c6d5e740c4aab59d2c2b58.tar.gz lufa-4742e95a3f8ef01715c6d5e740c4aab59d2c2b58.tar.bz2 lufa-4742e95a3f8ef01715c6d5e740c4aab59d2c2b58.zip |
Fixed AVRISP V2 Protocol handler for the READ_FLASH_ISP and READ_EEPROM_ISP handler - can now correctly read back device data. Programming command handler is still broken, although first page is written correctly to FLASH in paged write mode.
-rw-r--r-- | LUFA/ManPages/ChangeLog.txt | 4 | ||||
-rw-r--r-- | Projects/Incomplete/AVRISP/Lib/V2Protocol.c | 50 |
2 files changed, 32 insertions, 22 deletions
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index da4c007f0..6c4fea568 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -14,7 +14,7 @@ * - Added new EVENT_USB_Device_StartOfFrame() event, controlled by the new USB_Device_EnableSOFEvents() and
* USB_Device_DisableSOFEvents() macros to give bus-synchronised millisecond interrupts when in USB device mode
* - Added new Endpoint_SetEndpointDirection() macro for bi-directional endpoints
- * - Added new AVRISP project, a LUFA clone of the Atmel AVRISP-MKII programmer
+ * - Added new AVRISP project, a LUFA powered clone of the Atmel AVRISP-MKII programmer
* - Added ShutDown functions for all hardware peripheral drivers, so that peripherals can be turned off after use
*
* <b>Changed:</b>
@@ -35,6 +35,8 @@ * causing continuous USART receive interrupts
* - Fixed misspelt event name in the Class driver USBtoSerial demo, preventing correct operation
* - Fixed invalid data being returned when a GetStatus request is issued in Device mode with an unhandled data recipient
+ * - Added hardware USART receive interrupt and software buffering to the Benito project to ensure received data is not
+ * missed or corrupted
*
*
* \section Sec_ChangeLog090810 Version 090810
diff --git a/Projects/Incomplete/AVRISP/Lib/V2Protocol.c b/Projects/Incomplete/AVRISP/Lib/V2Protocol.c index 8d1480269..f2089c67a 100644 --- a/Projects/Incomplete/AVRISP/Lib/V2Protocol.c +++ b/Projects/Incomplete/AVRISP/Lib/V2Protocol.c @@ -286,12 +286,21 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command) /* Paged mode memory programming */
for (uint16_t CurrentByte = 0; CurrentByte < Write_Memory_Params.BytesToWrite; CurrentByte++)
- {
+ {
+ /* Check if the endpoint bank is currently empty */
+ if (!(Endpoint_IsReadWriteAllowed()))
+ {
+ Endpoint_ClearOUT();
+ Endpoint_WaitUntilReady();
+ }
+
bool IsOddByte = (CurrentByte & 0x01);
uint8_t ByteToWrite = Endpoint_Read_Byte();
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
- Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
+ 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);
@@ -304,14 +313,7 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command) Write_Memory_Params.ProgrammingCommands[2] |= READ_WRITE_HIGH_BYTE_MASK;
PollAddress = (CurrentAddress & 0xFFFF);
- }
-
- /* Check if the endpoint bank is currently empty */
- if (!(Endpoint_IsReadWriteAllowed()))
- {
- Endpoint_ClearOUT();
- Endpoint_WaitUntilReady();
- }
+ }
if (IsOddByte || (V2Command == CMD_PROGRAM_EEPROM_ISP))
CurrentAddress++;
@@ -341,11 +343,20 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command) /* Word/byte mode memory programming */
for (uint16_t CurrentByte = 0; CurrentByte < Write_Memory_Params.BytesToWrite; CurrentByte++)
{
+ /* Check if the endpoint bank is currently empty */
+ if (!(Endpoint_IsReadWriteAllowed()))
+ {
+ Endpoint_ClearOUT();
+ Endpoint_WaitUntilReady();
+ }
+
bool IsOddByte = (CurrentByte & 0x01);
uint8_t ByteToWrite = Endpoint_Read_Byte();
if (IsOddByte && (V2Command == CMD_READ_FLASH_ISP))
- Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
+ 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);
@@ -359,13 +370,6 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command) PollAddress = (CurrentAddress & 0xFFFF);
}
-
- /* Check if the endpoint bank is currently empty */
- if (!(Endpoint_IsReadWriteAllowed()))
- {
- Endpoint_ClearOUT();
- Endpoint_WaitUntilReady();
- }
if (IsOddByte || (V2Command == CMD_PROGRAM_EEPROM_ISP))
CurrentAddress++;
@@ -406,8 +410,12 @@ static void V2Protocol_Command_ReadMemory(uint8_t V2Command) for (uint16_t CurrentByte = 0; CurrentByte < Read_Memory_Params.BytesToRead; CurrentByte++)
{
- if ((V2Command == CMD_READ_FLASH_ISP) && (CurrentByte & 0x01))
- Read_Memory_Params.ReadMemoryCommand ^= READ_WRITE_HIGH_BYTE_MASK;
+ bool IsOddByte = (CurrentByte & 0x01);
+
+ if (IsOddByte && (V2Command == CMD_READ_FLASH_ISP))
+ Read_Memory_Params.ReadMemoryCommand |= READ_WRITE_HIGH_BYTE_MASK;
+ else
+ Read_Memory_Params.ReadMemoryCommand &= ~READ_WRITE_HIGH_BYTE_MASK;
SPI_SendByte(Read_Memory_Params.ReadMemoryCommand);
SPI_SendByte(CurrentAddress >> 8);
@@ -421,7 +429,7 @@ static void V2Protocol_Command_ReadMemory(uint8_t V2Command) Endpoint_WaitUntilReady();
}
- if (((V2Command == CMD_READ_FLASH_ISP) && (CurrentByte & 0x01)) || (V2Command == CMD_READ_EEPROM_ISP))
+ if ((IsOddByte && (V2Command == CMD_READ_FLASH_ISP)) || (V2Command == CMD_READ_EEPROM_ISP))
CurrentAddress++;
}
|