static void usb_process(void) { Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); do { if (Endpoint_IsSETUPReceived()) USB_Device_ProcessControlRequest(); } while (USB_DeviceState != DEVICE_STATE_Configured); }
ISR(USB_COM_vect, ISR_BLOCK) { USB_Device_ProcessControlRequest(); #if !defined(CONTROL_ONLY_DEVICE) #error Previous selected endpoints will not be restored. #error Add this feature or only use this if you know what you are doing. #error Remove this error to accept. #endif #error EVENT_USB_Device_ControlRequest() needs to be inlined. #warning Interrupt control Endpoint uses ~150-200 more bytes of flash }
static void USB_DeviceTask(void) { if (USB_DeviceState != DEVICE_STATE_Unattached) { uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); if (Endpoint_IsSETUPReceived()) USB_Device_ProcessControlRequest(); Endpoint_SelectEndpoint(PrevEndpoint); } }
ISR(USB_COM_vect, ISR_BLOCK) { uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); USB_INT_Disable(USB_INT_RXSTPI); GlobalInterruptEnable(); USB_Device_ProcessControlRequest(); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); USB_INT_Enable(USB_INT_RXSTPI); Endpoint_SelectEndpoint(PrevSelectedEndpoint); }
ISR(USB_COM_vect, ISR_BLOCK) { uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); USB_INT_Disable(USB_INT_RXSTPI); NONATOMIC_BLOCK(NONATOMIC_FORCEOFF) { USB_Device_ProcessControlRequest(); } Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); USB_INT_Enable(USB_INT_RXSTPI); Endpoint_SelectEndpoint(PrevSelectedEndpoint); }