aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-08-19 13:19:01 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-08-19 13:19:01 +0000
commita9602f02509432e2a0e531b33d491558b69c14d8 (patch)
tree67243c4191a83bbe4c6014b648c6203137a2aafe
parentfa8beef82d1340a69390d4b11ca785ee016789c5 (diff)
downloadlufa-a9602f02509432e2a0e531b33d491558b69c14d8.tar.gz
lufa-a9602f02509432e2a0e531b33d491558b69c14d8.tar.bz2
lufa-a9602f02509432e2a0e531b33d491558b69c14d8.zip
Change spinloop in the AVRISP project Unknown V2 Protocol Command handler to use Endpoint_WaitUntilReady() instead to prevent infinite loops.
-rw-r--r--Projects/Unfinished/AVRISP/Lib/V2Protocol.c12
-rw-r--r--Projects/Unfinished/AVRISP/Lib/V2Protocol.h2
2 files changed, 8 insertions, 6 deletions
diff --git a/Projects/Unfinished/AVRISP/Lib/V2Protocol.c b/Projects/Unfinished/AVRISP/Lib/V2Protocol.c
index 403889241..dfa27ad9e 100644
--- a/Projects/Unfinished/AVRISP/Lib/V2Protocol.c
+++ b/Projects/Unfinished/AVRISP/Lib/V2Protocol.c
@@ -103,15 +103,17 @@ void V2Protocol_ProcessCommand(void)
}
static void V2Protocol_Command_Unknown(uint8_t V2Command)
-{
+{
+ /* Discard all incomming data */
while (Endpoint_BytesInEndpoint() == AVRISP_DATA_EPSIZE)
{
Endpoint_ClearOUT();
- while (!(Endpoint_IsOUTReceived()));
+ Endpoint_WaitUntilReady();
}
Endpoint_ClearOUT();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
+ Endpoint_WaitUntilReady();
Endpoint_Write_Byte(V2Command);
Endpoint_Write_Byte(STATUS_CMD_UNKNOWN);
@@ -166,8 +168,8 @@ static void V2Protocol_Command_GetSetParam(uint8_t V2Command)
static void V2Protocol_Command_SPIMulti(void)
{
- uint8_t TxBytes = Endpoint_Read_Byte();
- uint8_t RxBytes = Endpoint_Read_Byte();
+ uint8_t TxBytes = Endpoint_Read_Byte();
+ uint8_t RxBytes = Endpoint_Read_Byte();
uint8_t RxStartAddr = Endpoint_Read_Byte();
uint8_t TxData[255];
@@ -183,6 +185,7 @@ static void V2Protocol_Command_SPIMulti(void)
uint8_t CurrTxPos = 0;
uint8_t CurrRxPos = 0;
+ /* Write out bytes to transmit until the start of the bytes to receive is met */
while (CurrTxPos < RxStartAddr)
{
if (CurrTxPos < TxBytes)
@@ -193,6 +196,7 @@ static void V2Protocol_Command_SPIMulti(void)
CurrTxPos++;
}
+ /* Transmit remaining bytes with padding as needed, read in response bytes */
while (CurrRxPos < RxBytes)
{
if (CurrTxPos < TxBytes)
diff --git a/Projects/Unfinished/AVRISP/Lib/V2Protocol.h b/Projects/Unfinished/AVRISP/Lib/V2Protocol.h
index 9f6b83b47..03ca83536 100644
--- a/Projects/Unfinished/AVRISP/Lib/V2Protocol.h
+++ b/Projects/Unfinished/AVRISP/Lib/V2Protocol.h
@@ -38,9 +38,7 @@
/* Includes: */
#include <avr/io.h>
- #include <avr/eeprom.h>
- #include <LUFA/Version.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SPI.h>