Minor changes to the AVRISP project for code clarity.
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 9 Nov 2009 12:22:33 +0000 (12:22 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 9 Nov 2009 12:22:33 +0000 (12:22 +0000)
Projects/AVRISP/AVRISP.c
Projects/AVRISP/Lib/V2Protocol.c
Projects/AVRISP/Lib/V2ProtocolParams.c
Projects/AVRISP/Lib/V2ProtocolTarget.c

index 44b8356..4eb02d2 100644 (file)
@@ -120,11 +120,11 @@ void Process_AVRISP_Commands(void)
 
        Endpoint_SelectEndpoint(AVRISP_DATA_EPNUM);\r
        
-       /* 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();\r
+       /* Check to see if a V2 Protocol command has been received */
+       if (Endpoint_IsOUTReceived())\r
+       {
+               /* Pass off processing of the V2 Protocol command to the V2 Protocol handler */
+               V2Protocol_ProcessCommand();\r
+       }\r
 }
 
index 6099234..d7343aa 100644 (file)
@@ -301,11 +301,9 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
                uint8_t  ProgrammingCommands[3];\r
                uint8_t  PollValue1;\r
                uint8_t  PollValue2;\r
-               uint8_t  ProgData[256];\r
-       } Write_Memory_Params;\r
+               uint8_t  ProgData[256]; // Note, the Jungo driver has a very short ACK timeout period, need to buffer the\r
+       } Write_Memory_Params;      // whole page and ACK the packet as fast as possible to prevent it from aborting\r
        \r
-       uint8_t* NextWriteByte = Write_Memory_Params.ProgData;\r
-\r
        Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData));\r
        Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);\r
        \r
@@ -329,6 +327,8 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
        uint16_t PollAddress       = 0;\r
        uint8_t  PollValue         = (V2Command == CMD_PROGRAM_FLASH_ISP) ? Write_Memory_Params.PollValue1 :\r
                                                                            Write_Memory_Params.PollValue2;\r
+       uint8_t* NextWriteByte = Write_Memory_Params.ProgData;\r
+\r
        if (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_WRITES_MASK)\r
        {\r
                uint16_t StartAddress = (CurrentAddress & 0xFFFF);\r
index 6aaa955..6b4568a 100644 (file)
@@ -132,7 +132,7 @@ uint8_t V2Params_GetParameterValue(uint8_t ParamID)
 {\r
        ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);\r
        \r
-       if (ParamInfo == NULL)\r
+       if ((ParamInfo == NULL) || !(ParamInfo->ParamPrivellages & PARAM_PRIV_READ))\r
          return 0;\r
        \r
        return ParamInfo->ParamValue;\r
@@ -149,7 +149,7 @@ void V2Params_SetParameterValue(uint8_t ParamID, uint8_t Value)
 {\r
        ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);\r
 \r
-       if (ParamInfo == NULL)\r
+       if ((ParamInfo == NULL) || !(ParamInfo->ParamPrivellages & PARAM_PRIV_WRITE))\r
          return;\r
 \r
        ParamInfo->ParamValue = Value;\r
index 9f8978a..169e49a 100644 (file)
@@ -85,7 +85,7 @@ void V2Protocol_ChangeTargetResetLine(bool ResetTarget)
 {\r
        if (ResetTarget)\r
        {\r
-               RESET_LINE_DDR  |= RESET_LINE_MASK;\r
+               RESET_LINE_DDR |= RESET_LINE_MASK;\r
                \r
                if (!(V2Params_GetParameterValue(PARAM_RESET_POLARITY)))\r
                  RESET_LINE_PORT |= RESET_LINE_MASK;\r
@@ -155,17 +155,14 @@ uint8_t V2Protocol_WaitWhileTargetBusy(void)
 {\r
        TCNT0 = 0;\r
        \r
-       bool DeviceBusy;\r
-       \r
        do\r
        {\r
                SPI_SendByte(0xF0);\r
                SPI_SendByte(0x00);\r
 \r
                SPI_SendByte(0x00);\r
-               DeviceBusy = (SPI_ReceiveByte() & 0x01);\r
        }\r
-       while (DeviceBusy && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));\r
+       while ((SPI_ReceiveByte() & 0x01) && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));\r
 \r
        if (TCNT0 >= TARGET_BUSY_TIMEOUT_MS)\r
          return STATUS_RDY_BSY_TOUT;\r