@ -163,7 +163,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
switch ( bRequest )
switch ( bRequest )
{
{
case DFU_DNLOAD :
case DFU_DNLOAD :
Endpoint_Clear Control SETUP( ) ;
Endpoint_Clear SETUP( ) ;
/* Check if bootloader is waiting to terminate */
/* Check if bootloader is waiting to terminate */
if ( WaitForExit )
if ( WaitForExit )
@ -235,7 +235,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if ( ! ( Endpoint_BytesInEndpoint ( ) ) )
if ( ! ( Endpoint_BytesInEndpoint ( ) ) )
{
{
Endpoint_Clear Control OUT( ) ;
Endpoint_Clear OUT( ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
}
}
@ -279,7 +279,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if ( ! ( Endpoint_BytesInEndpoint ( ) ) )
if ( ! ( Endpoint_BytesInEndpoint ( ) ) )
{
{
Endpoint_Clear Control OUT( ) ;
Endpoint_Clear OUT( ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
}
}
@ -296,15 +296,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
}
}
}
}
Endpoint_Clear Control OUT( ) ;
Endpoint_Clear OUT( ) ;
/* Acknowledge status stage */
/* Acknowledge status stage */
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
break ;
break ;
case DFU_UPLOAD :
case DFU_UPLOAD :
Endpoint_Clear Control SETUP( ) ;
Endpoint_Clear SETUP( ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
@ -343,7 +343,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
if ( Endpoint_BytesInEndpoint ( ) = = FIXED_CONTROL_ENDPOINT_SIZE )
if ( Endpoint_BytesInEndpoint ( ) = = FIXED_CONTROL_ENDPOINT_SIZE )
{
{
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
}
}
@ -368,7 +368,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
if ( Endpoint_BytesInEndpoint ( ) = = FIXED_CONTROL_ENDPOINT_SIZE )
if ( Endpoint_BytesInEndpoint ( ) = = FIXED_CONTROL_ENDPOINT_SIZE )
{
{
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
}
}
@ -384,15 +384,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
DFU_State = dfuIDLE ;
DFU_State = dfuIDLE ;
}
}
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
/* Acknowledge status stage */
/* Acknowledge status stage */
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
Endpoint_Clear Control OUT( ) ;
Endpoint_Clear OUT( ) ;
break ;
break ;
case DFU_GETSTATUS :
case DFU_GETSTATUS :
Endpoint_Clear Control SETUP( ) ;
Endpoint_Clear SETUP( ) ;
/* Write 8-bit status value */
/* Write 8-bit status value */
Endpoint_Write_Byte ( DFU_Status ) ;
Endpoint_Write_Byte ( DFU_Status ) ;
@ -407,46 +407,46 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Write 8-bit state string ID number */
/* Write 8-bit state string ID number */
Endpoint_Write_Byte ( 0 ) ;
Endpoint_Write_Byte ( 0 ) ;
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
/* Acknowledge status stage */
/* Acknowledge status stage */
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
Endpoint_Clear Control OUT( ) ;
Endpoint_Clear OUT( ) ;
break ;
break ;
case DFU_CLRSTATUS :
case DFU_CLRSTATUS :
Endpoint_Clear Control SETUP( ) ;
Endpoint_Clear SETUP( ) ;
/* Reset the status value variable to the default OK status */
/* Reset the status value variable to the default OK status */
DFU_Status = OK ;
DFU_Status = OK ;
/* Acknowledge status stage */
/* Acknowledge status stage */
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
break ;
break ;
case DFU_GETSTATE :
case DFU_GETSTATE :
Endpoint_Clear Control SETUP( ) ;
Endpoint_Clear SETUP( ) ;
/* Write the current device state to the endpoint */
/* Write the current device state to the endpoint */
Endpoint_Write_Byte ( DFU_State ) ;
Endpoint_Write_Byte ( DFU_State ) ;
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
/* Acknowledge status stage */
/* Acknowledge status stage */
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
Endpoint_Clear Control OUT( ) ;
Endpoint_Clear OUT( ) ;
break ;
break ;
case DFU_ABORT :
case DFU_ABORT :
Endpoint_Clear Control SETUP( ) ;
Endpoint_Clear SETUP( ) ;
/* Reset the current state variable to the default idle state */
/* Reset the current state variable to the default idle state */
DFU_State = dfuIDLE ;
DFU_State = dfuIDLE ;
/* Acknowledge status stage */
/* Acknowledge status stage */
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
while ( ! ( Endpoint_IsINReady ( ) ) ) ;
Endpoint_Clear Control IN( ) ;
Endpoint_Clear IN( ) ;
break ;
break ;
}
}
@ -463,7 +463,7 @@ static void DiscardFillerBytes(uint8_t NumberOfBytes)
{
{
if ( ! ( Endpoint_BytesInEndpoint ( ) ) )
if ( ! ( Endpoint_BytesInEndpoint ( ) ) )
{
{
Endpoint_Clear Control OUT( ) ;
Endpoint_Clear OUT( ) ;
/* Wait until next data packet received */
/* Wait until next data packet received */
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;
while ( ! ( Endpoint_IsOUTReceived ( ) ) ) ;