aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-11-09 12:22:33 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-11-09 12:22:33 +0000
commitc647c2763980b374da1c4314c752295d72228d4c (patch)
tree5f8048b90c04d276efb0270907d9a0a7aa55f4fd /Projects/AVRISP
parent8bb007f80b3e275c9857a5ffa2cf597711fb7478 (diff)
downloadlufa-c647c2763980b374da1c4314c752295d72228d4c.tar.gz
lufa-c647c2763980b374da1c4314c752295d72228d4c.tar.bz2
lufa-c647c2763980b374da1c4314c752295d72228d4c.zip
Minor changes to the AVRISP project for code clarity.
Diffstat (limited to 'Projects/AVRISP')
-rw-r--r--Projects/AVRISP/AVRISP.c12
-rw-r--r--Projects/AVRISP/Lib/V2Protocol.c8
-rw-r--r--Projects/AVRISP/Lib/V2ProtocolParams.c4
-rw-r--r--Projects/AVRISP/Lib/V2ProtocolTarget.c7
4 files changed, 14 insertions, 17 deletions
diff --git a/Projects/AVRISP/AVRISP.c b/Projects/AVRISP/AVRISP.c
index 44b8356cd..4eb02d2bf 100644
--- a/Projects/AVRISP/AVRISP.c
+++ b/Projects/AVRISP/AVRISP.c
@@ -120,11 +120,11 @@ void Process_AVRISP_Commands(void)
Endpoint_SelectEndpoint(AVRISP_DATA_EPNUM);
- /* Check to see if a V2 Protocol command has been received - if not, abort */
- if (!(Endpoint_IsOUTReceived()))
- return;
-
- /* Pass off processing of the V2 Protocol command to the V2 Protocol handler */
- V2Protocol_ProcessCommand();
+ /* Check to see if a V2 Protocol command has been received */
+ if (Endpoint_IsOUTReceived())
+ {
+ /* Pass off processing of the V2 Protocol command to the V2 Protocol handler */
+ V2Protocol_ProcessCommand();
+ }
}
diff --git a/Projects/AVRISP/Lib/V2Protocol.c b/Projects/AVRISP/Lib/V2Protocol.c
index 6099234fa..d7343aad6 100644
--- a/Projects/AVRISP/Lib/V2Protocol.c
+++ b/Projects/AVRISP/Lib/V2Protocol.c
@@ -301,11 +301,9 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
uint8_t ProgrammingCommands[3];
uint8_t PollValue1;
uint8_t PollValue2;
- uint8_t ProgData[256];
- } Write_Memory_Params;
+ uint8_t ProgData[256]; // Note, the Jungo driver has a very short ACK timeout period, need to buffer the
+ } Write_Memory_Params; // whole page and ACK the packet as fast as possible to prevent it from aborting
- uint8_t* NextWriteByte = Write_Memory_Params.ProgData;
-
Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData));
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);
@@ -329,6 +327,8 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
uint16_t PollAddress = 0;
uint8_t PollValue = (V2Command == CMD_PROGRAM_FLASH_ISP) ? Write_Memory_Params.PollValue1 :
Write_Memory_Params.PollValue2;
+ uint8_t* NextWriteByte = Write_Memory_Params.ProgData;
+
if (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_WRITES_MASK)
{
uint16_t StartAddress = (CurrentAddress & 0xFFFF);
diff --git a/Projects/AVRISP/Lib/V2ProtocolParams.c b/Projects/AVRISP/Lib/V2ProtocolParams.c
index 6aaa9558e..6b4568a94 100644
--- a/Projects/AVRISP/Lib/V2ProtocolParams.c
+++ b/Projects/AVRISP/Lib/V2ProtocolParams.c
@@ -132,7 +132,7 @@ uint8_t V2Params_GetParameterValue(uint8_t ParamID)
{
ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
- if (ParamInfo == NULL)
+ if ((ParamInfo == NULL) || !(ParamInfo->ParamPrivellages & PARAM_PRIV_READ))
return 0;
return ParamInfo->ParamValue;
@@ -149,7 +149,7 @@ void V2Params_SetParameterValue(uint8_t ParamID, uint8_t Value)
{
ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
- if (ParamInfo == NULL)
+ if ((ParamInfo == NULL) || !(ParamInfo->ParamPrivellages & PARAM_PRIV_WRITE))
return;
ParamInfo->ParamValue = Value;
diff --git a/Projects/AVRISP/Lib/V2ProtocolTarget.c b/Projects/AVRISP/Lib/V2ProtocolTarget.c
index 9f8978a70..169e49ac7 100644
--- a/Projects/AVRISP/Lib/V2ProtocolTarget.c
+++ b/Projects/AVRISP/Lib/V2ProtocolTarget.c
@@ -85,7 +85,7 @@ void V2Protocol_ChangeTargetResetLine(bool ResetTarget)
{
if (ResetTarget)
{
- RESET_LINE_DDR |= RESET_LINE_MASK;
+ RESET_LINE_DDR |= RESET_LINE_MASK;
if (!(V2Params_GetParameterValue(PARAM_RESET_POLARITY)))
RESET_LINE_PORT |= RESET_LINE_MASK;
@@ -155,17 +155,14 @@ uint8_t V2Protocol_WaitWhileTargetBusy(void)
{
TCNT0 = 0;
- bool DeviceBusy;
-
do
{
SPI_SendByte(0xF0);
SPI_SendByte(0x00);
SPI_SendByte(0x00);
- DeviceBusy = (SPI_ReceiveByte() & 0x01);
}
- while (DeviceBusy && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));
+ while ((SPI_ReceiveByte() & 0x01) && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));
if (TCNT0 >= TARGET_BUSY_TIMEOUT_MS)
return STATUS_RDY_BSY_TOUT;