From c647c2763980b374da1c4314c752295d72228d4c Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 9 Nov 2009 12:22:33 +0000 Subject: Minor changes to the AVRISP project for code clarity. --- Projects/AVRISP/Lib/V2Protocol.c | 8 ++++---- Projects/AVRISP/Lib/V2ProtocolParams.c | 4 ++-- Projects/AVRISP/Lib/V2ProtocolTarget.c | 7 ++----- 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'Projects/AVRISP/Lib') 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; -- cgit v1.2.3