X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/bd5e8f07b71b4fa0c058c0edfa8ff3f59ab31610..d1608d4af321529f0ddef9defcd97669ae9018c3:/Projects/AVRISP/Lib/V2Protocol.c diff --git a/Projects/AVRISP/Lib/V2Protocol.c b/Projects/AVRISP/Lib/V2Protocol.c index 3bfcc11af..4fcb5aa00 100644 --- a/Projects/AVRISP/Lib/V2Protocol.c +++ b/Projects/AVRISP/Lib/V2Protocol.c @@ -43,6 +43,13 @@ uint32_t CurrentAddress; bool MustSetAddress; +/** ISR for the management of the command execution timeout counter */ +ISR(TIMER0_COMPA_vect, ISR_BLOCK) +{ + if (TimeoutMSRemaining) + TimeoutMSRemaining--; +} + /** Master V2 Protocol packet handler, for received V2 Protocol packets from a connected host. * This routine decodes the issued command and passes off the handling of the command to the * appropriate function. @@ -50,7 +57,10 @@ bool MustSetAddress; void V2Protocol_ProcessCommand(void) { uint8_t V2Command = Endpoint_Read_Byte(); - + + TimeoutMSRemaining = COMMAND_TIMEOUT_MS; + TIMSK0 |= (1 << OCIE0A); + switch (V2Command) { case CMD_SIGN_ON: @@ -98,22 +108,21 @@ void V2Protocol_ProcessCommand(void) ISPProtocol_SPIMulti(); break; #endif -#if defined(ENABLE_PDI_PROTOCOL) +#if defined(ENABLE_XPROG_PROTOCOL) case CMD_XPROG_SETMODE: - PDIProtocol_XPROG_SetMode(); + XPROGProtocol_SetMode(); break; case CMD_XPROG: - PDIProtocol_XPROG_Command(); + XPROGProtocol_Command(); break; #endif -#if defined(ENABLE_TPI_PROTOCOL) - // TODO -#endif default: V2Protocol_UnknownCommand(V2Command); break; } - + + TIMSK0 &= ~(1 << OCIE0A); + Endpoint_WaitUntilReady(); Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT); }