Added const where possible to the source functions in the Projects directory.
[pub/USBasp.git] / Projects / AVRISP / Lib / V2Protocol.c
index eae2e83..4fcb5aa 100644 (file)
@@ -43,6 +43,13 @@ uint32_t CurrentAddress;
 bool MustSetAddress;\r
 \r
 \r
+/** ISR for the management of the command execution timeout counter */\r
+ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
+{\r
+       if (TimeoutMSRemaining)\r
+         TimeoutMSRemaining--;\r
+}\r
+\r
 /** Master V2 Protocol packet handler, for received V2 Protocol packets from a connected host.\r
  *  This routine decodes the issued command and passes off the handling of the command to the\r
  *  appropriate function.\r
@@ -51,8 +58,9 @@ void V2Protocol_ProcessCommand(void)
 {\r
        uint8_t V2Command = Endpoint_Read_Byte();\r
        \r
-       Serial_TxByte(V2Command);\r
-       \r
+       TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
+       TIMSK0 |= (1 << OCIE0A);\r
+\r
        switch (V2Command)\r
        {\r
                case CMD_SIGN_ON:\r
@@ -100,22 +108,21 @@ void V2Protocol_ProcessCommand(void)
                        ISPProtocol_SPIMulti();\r
                        break;\r
 #endif\r
-#if defined(ENABLE_PDI_PROTOCOL)\r
+#if defined(ENABLE_XPROG_PROTOCOL)\r
                case CMD_XPROG_SETMODE:\r
-                       PDIProtocol_XPROG_SetMode();\r
+                       XPROGProtocol_SetMode();\r
                        break;\r
                case CMD_XPROG:\r
-                       PDIProtocol_XPROG_Command();\r
+                       XPROGProtocol_Command();\r
                        break;\r
 #endif\r
-#if defined(ENABLE_TPI_PROTOCOL)\r
-               // TODO\r
-#endif\r
                default:\r
                        V2Protocol_UnknownCommand(V2Command);\r
                        break;\r
        }\r
-       \r
+               \r
+       TIMSK0 &= ~(1 << OCIE0A);\r
+\r
        Endpoint_WaitUntilReady();\r
        Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT);\r
 }\r