Add LOAD ADDRESS command parsing to the V2 Protocol hander in the AVRISP project.
[pub/USBasp.git] / Projects / Unfinished / AVRISP / Lib / V2Protocol.c
index dfa27ad..e55a700 100644 (file)
@@ -36,6 +36,9 @@
 #define  INCLUDE_FROM_V2PROTOCOL_C\r
 #include "V2Protocol.h"\r
 \r
+uint32_t CurrentAddress;\r
+\r
+\r
 /* Table of masks for SPI_Init() from a given PARAM_SCK_DURATION value */\r
 static const uint8_t SPIMaskFromSCKDuration[MAX_SPI_SETTINGS] =\r
        {\r
@@ -88,6 +91,9 @@ void V2Protocol_ProcessCommand(void)
                case CMD_GET_PARAMETER:\r
                        V2Protocol_Command_GetSetParam(V2Command);\r
                        break;\r
+               case CMD_LOAD_ADDRESS:\r
+                       V2Protocol_Command_LoadAddress();\r
+                       break;\r
                case CMD_SPI_MULTI:\r
                        V2Protocol_Command_SPIMulti();\r
                        break;          \r
@@ -127,6 +133,7 @@ static void V2Protocol_Command_SignOn(void)
        Endpoint_WaitUntilReady();\r
 \r
        V2Protocol_ReconfigureSPI();\r
+       CurrentAddress = 0;\r
 \r
        Endpoint_Write_Byte(CMD_SIGN_ON);\r
        Endpoint_Write_Byte(STATUS_CMD_OK);\r
@@ -166,6 +173,19 @@ static void V2Protocol_Command_GetSetParam(uint8_t V2Command)
        Endpoint_ClearIN();\r
 }\r
 \r
+static void V2Protocol_Command_LoadAddress(void)\r
+{\r
+       CurrentAddress = Endpoint_Read_DWord_LE();\r
+\r
+       Endpoint_ClearOUT();\r
+       Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);\r
+       Endpoint_WaitUntilReady();\r
+\r
+       Endpoint_Write_Byte(CMD_LOAD_ADDRESS);\r
+       Endpoint_Write_Byte(STATUS_CMD_OK);\r
+       Endpoint_ClearIN();\r
+}\r
+\r
 static void V2Protocol_Command_SPIMulti(void)\r
 {\r
        uint8_t TxBytes     = Endpoint_Read_Byte();\r