X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/60fd0ff418566d85224f9841037ba01b77acc0d8..5e14c194c9a2f5cb52a43f7efeacb795a38ced74:/Projects/AVRISP-MKII/Lib/V2Protocol.c diff --git a/Projects/AVRISP-MKII/Lib/V2Protocol.c b/Projects/AVRISP-MKII/Lib/V2Protocol.c index d6de77404..431f9c2d5 100644 --- a/Projects/AVRISP-MKII/Lib/V2Protocol.c +++ b/Projects/AVRISP-MKII/Lib/V2Protocol.c @@ -42,14 +42,6 @@ uint32_t CurrentAddress; /** Flag to indicate that the next read/write operation must update the device's current address */ bool MustSetAddress; - -/** ISR for the management of the command execution timeout counter */ -ISR(TIMER0_COMPA_vect, ISR_BLOCK) -{ - if (TimeoutMSRemaining) - TimeoutMSRemaining--; -} - /** Initializes the hardware and software associated with the V2 protocol command handling. */ void V2Protocol_Init(void) { @@ -57,7 +49,7 @@ void V2Protocol_Init(void) /* Initialize the ADC converter for VTARGET level detection on supported AVR models */ ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128); ADC_SetupChannel(VTARGET_ADC_CHANNEL); - ADC_StartReading(VTARGET_ADC_CHANNEL | ADC_RIGHT_ADJUSTED | ADC_REFERENCE_AVCC); + ADC_StartReading(VTARGET_ADC_CHANNEL_MASK | ADC_RIGHT_ADJUSTED | ADC_REFERENCE_AVCC); #endif /* Millisecond timer initialization for managing the command timeout counter */ @@ -76,10 +68,8 @@ void V2Protocol_ProcessCommand(void) { uint8_t V2Command = Endpoint_Read_Byte(); - /* Set total command processing timeout value, enable timeout management interrupt */ TimeoutMSRemaining = COMMAND_TIMEOUT_MS; - TIMSK0 |= (1 << OCIE0A); - + switch (V2Command) { case CMD_SIGN_ON: @@ -139,11 +129,9 @@ void V2Protocol_ProcessCommand(void) V2Protocol_UnknownCommand(V2Command); break; } - - /* Disable timeout management interrupt once processing has completed */ - TIMSK0 &= ~(1 << OCIE0A); Endpoint_WaitUntilReady(); + Endpoint_SelectEndpoint(AVRISP_DATA_OUT_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT); } @@ -162,6 +150,7 @@ static void V2Protocol_UnknownCommand(const uint8_t V2Command) } Endpoint_ClearOUT(); + Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); Endpoint_Write_Byte(V2Command); @@ -173,6 +162,7 @@ static void V2Protocol_UnknownCommand(const uint8_t V2Command) static void V2Protocol_SignOn(void) { Endpoint_ClearOUT(); + Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); Endpoint_Write_Byte(CMD_SIGN_ON); @@ -188,6 +178,7 @@ static void V2Protocol_SignOn(void) static void V2Protocol_ResetProtection(void) { Endpoint_ClearOUT(); + Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); Endpoint_Write_Byte(CMD_RESET_PROTECTION); @@ -210,6 +201,7 @@ static void V2Protocol_GetSetParam(const uint8_t V2Command) ParamValue = Endpoint_Read_Byte(); Endpoint_ClearOUT(); + Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); Endpoint_Write_Byte(V2Command); @@ -243,6 +235,7 @@ static void V2Protocol_LoadAddress(void) Endpoint_Read_Stream_BE(&CurrentAddress, sizeof(CurrentAddress), NO_STREAM_CALLBACK); Endpoint_ClearOUT(); + Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); MustSetAddress = true;