Fix nasty bug in USBInterrupt.c which would cause a lockup if the control endpoint was not selected at the point the USB endpoint interrupt fires when INTERRUPT_CONTROL_ENDPOINT is defined.

pull/1469/head
Dean Camera 15 years ago
parent 53ebb2f21a
commit ee5ea4ce2b

@ -183,8 +183,6 @@ static uint32_t ServiceDiscovery_GetDataElementSize(const void** DataElementHead
uint8_t SizeIndex = (*((uint8_t*)*DataElementHeader) & 0x07); uint8_t SizeIndex = (*((uint8_t*)*DataElementHeader) & 0x07);
*DataElementHeader += sizeof(uint8_t); *DataElementHeader += sizeof(uint8_t);
*ElementHeaderSize = 1;
uint32_t ElementValue; uint32_t ElementValue;
switch (SizeIndex) switch (SizeIndex)
@ -205,7 +203,8 @@ static uint32_t ServiceDiscovery_GetDataElementSize(const void** DataElementHead
*ElementHeaderSize = (1 + sizeof(uint32_t)); *ElementHeaderSize = (1 + sizeof(uint32_t));
break; break;
default: default:
ElementValue = (1UL << SizeIndex); ElementValue = (1 << SizeIndex);
*ElementHeaderSize = 1;
break; break;
} }

@ -233,15 +233,15 @@ ISR(USB_GEN_vect, ISR_BLOCK)
#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE) #if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)
ISR(USB_COM_vect, ISR_BLOCK) ISR(USB_COM_vect, ISR_BLOCK)
{ {
uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
USB_INT_Disable(USB_INT_RXSTPI); USB_INT_Disable(USB_INT_RXSTPI);
sei(); sei();
USB_USBTask(); USB_USBTask();
USB_INT_Enable(USB_INT_RXSTPI);
USB_INT_Clear(USB_INT_RXSTPI); USB_INT_Enable(USB_INT_RXSTPI);
Endpoint_SelectEndpoint(PrevSelectedEndpoint); Endpoint_SelectEndpoint(PrevSelectedEndpoint);
} }
#endif #endif

Loading…
Cancel
Save