53 #include <util/delay.h>
59 #if (USB_DEVICE_FEATURE==DISABLED && USB_HOST_FEATURE==DISABLED)
60 #error at least one of USB_DEVICE_FEATURE or USB_HOST_FEATURE should be unabled
63 #if (USB_DEVICE_FEATURE == ENABLED)
65 #define USB_ENDPOINT_WAIT_TIMEOUT 250
67 U8 usb_endpoint_wait_for_write_enabled() {
68 #if USB_ENDPOINT_WAIT_TIMEOUT
69 U16 timeout=USB_ENDPOINT_WAIT_TIMEOUT;
90 U8 usb_endpoint_wait_for_read_control_enabled() {
91 #if USB_ENDPOINT_WAIT_TIMEOUT
92 U16 timeout=USB_ENDPOINT_WAIT_TIMEOUT;
114 U8 usb_endpoint_wait_for_IN_ready() {
115 #if USB_ENDPOINT_WAIT_TIMEOUT
116 U16 timeout=USB_ENDPOINT_WAIT_TIMEOUT;
138 U8 usb_endpoint_wait_for_receive_out() {
139 #if USB_ENDPOINT_WAIT_TIMEOUT
140 U16 timeout=USB_ENDPOINT_WAIT_TIMEOUT;
174 UECFG1X = (UECFG1X & (1<<ALLOC)) | config1;
195 while(ep_num < MAX_EP_NB)
197 if (interrupt_flags & 1)
204 interrupt_flags = interrupt_flags >> 1;
234 remaining_length = data_length;
242 return remaining_length;
269 remaining_length = data_length;
278 return remaining_length;
308 if(Is_usb_id_device())
313 #if (USB_LOW_SPEED_DEVICE==DISABLE)
314 rv = usb_configure_endpoint(EP_CONTROL, \
321 rv = usb_configure_endpoint(EP_CONTROL, \
340 #if (USB_HOST_FEATURE == ENABLED)
350 U8 host_config_pipe(U8 config0, U8 config1)
373 U8 host_determine_pipe_size(U16 size)
375 if(size <= 8 ) {
return (SIZE_8 );}
376 else if(size <= 16 ) {
return (SIZE_16 );}
377 else if(size <= 32 ) {
return (SIZE_32 );}
378 else if(size <= 64 ) {
return (SIZE_64 );}
379 else if(size <= 128) {
return (SIZE_128 );}
380 else if(size <= 256) {
return (SIZE_256 );}
381 else if(size <= 512) {
return (SIZE_512 );}
382 else {
return (SIZE_1024);}
391 void host_disable_all_pipe(
void)
410 U8 usb_get_nb_pipe_interrupt(
void)
416 for(i=0;i< MAX_EP_NB;i++)
418 if (interrupt_flags & (1<<i))
428 #endif // USB_HOST_FEATURE == ENABLED