[tuxdroid-svn] r1156 - in firmware/fuxusb/trunk: . src
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-05-15 14:14:49
|
Author: Paul_R Date: 2008-05-15 16:14:49 +0200 (Thu, 15 May 2008) New Revision: 1156 Modified: firmware/fuxusb/trunk/fuxusb.Opt firmware/fuxusb/trunk/src/usb_enum.c Log: * Added a function to send a zero-length packet (send_zlp). Modified: firmware/fuxusb/trunk/fuxusb.Opt =================================================================== (Binary files differ) Modified: firmware/fuxusb/trunk/src/usb_enum.c =================================================================== --- firmware/fuxusb/trunk/src/usb_enum.c 2008-05-15 14:03:24 UTC (rev 1155) +++ firmware/fuxusb/trunk/src/usb_enum.c 2008-05-15 14:14:49 UTC (rev 1156) @@ -31,19 +31,14 @@ #include "lib_mcu\usb\usb_drv.h" uint8_t usb_configuration_nb = 0; -/*_____ M A C R O S _________________________________________________________*/ - static bit zlp; static uint8_t endpoint_status[3]; static uint8_t hid_idle_duration; static uint8_t *pbuffer; static uint8_t bmRequestType; static uint8_t bRequest; -uint8_t line_coding[7]; -/*_____ D E C L A R A T I O N _______________________________________________*/ - static void usb_get_descriptor(void); static void usb_read_request(void); static void usb_set_address(void); @@ -70,6 +65,7 @@ static void usb_hid_get_idle(void); static void stall_request(void); +static void send_zlp(void); /*F************************************************************************** * NAME: usb_var_init *---------------------------------------------------------------------------- @@ -314,10 +310,8 @@ add = Usb_read_byte(); /* store the LSB of wValue = address */ Usb_clear_rx_setup(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ Usb_set_FADDEN(); - while (!(Usb_tx_complete())); - Usb_clear_tx_complete(); + send_zlp(); Usb_configure_address(add); #ifdef USB_ENUM_DEBUG printf("SET_ADDRESSE %BX",add); @@ -382,9 +376,7 @@ return; } - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while (!Usb_tx_complete()); - Usb_clear_tx_complete(); + send_zlp(); usb_ep_init(); /* endpoints configuration */ Usb_set_CONFG(); @@ -425,9 +417,7 @@ Usb_clear_DIR(); Usb_clear_rx_setup(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while (!Usb_tx_complete()); - Usb_clear_tx_complete(); + send_zlp(); #ifdef USB_ENUM_DEBUG printf("SET_INTERFACE %BX %BX %BX %BX",HAlternateSetting, \ @@ -458,7 +448,7 @@ uint8_t descriptor_type; uint8_t string_type; - zlp = FALSE; /* no zero length packet */ + zlp = False; /* no zero length packet */ string_type = Usb_read_byte(); /* read LSB of wValue */ descriptor_type = Usb_read_byte(); /* read MSB of wValue */ @@ -614,8 +604,8 @@ ((uint8_t *)&wLength)[0] = Usb_read_byte(); if (wLength > data_to_transfer) { - if ((data_to_transfer % EP_CONTROL_LENGTH) == 0) { zlp = TRUE; } - else { zlp = FALSE; } /* no need of zero length packet */ + if ((data_to_transfer % EP_CONTROL_LENGTH) == 0) { zlp = True; } + else { zlp = False; } /* no need of zero length packet */ } else { @@ -658,7 +648,7 @@ return; } - if (zlp == TRUE) + if (zlp == True) { usb_send_ep0_packet(pbuffer, 0); while ((!(Usb_rx_complete())) && (!(Usb_tx_complete()))); @@ -850,10 +840,8 @@ Usb_clear_DIR(); Usb_clear_rx_setup(); + send_zlp(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while (!Usb_tx_complete()); - Usb_clear_tx_complete(); #ifdef USB_ENUM_DEBUG printf("SET CURRENT %BX %BX %BX %BX Answer",LwValue,HwValue,\ LwIndex,HwIndex); @@ -876,10 +864,8 @@ Usb_clear_DIR(); Usb_clear_rx_setup(); + send_zlp(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while (!Usb_tx_complete()); - Usb_clear_tx_complete(); #ifdef USB_ENUM_DEBUG printf("SET MIN %BX %BX %BX %BX Answer",LwValue,HwValue,LwIndex,HwIndex); #endif @@ -898,10 +884,8 @@ Usb_clear_DIR(); Usb_clear_rx_setup(); + send_zlp(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while (!Usb_tx_complete()); - Usb_clear_tx_complete(); #ifdef USB_ENUM_DEBUG printf("SET MAX %BX %BX %BX %BX Answer",LwValue,HwValue,LwIndex,HwIndex); #endif @@ -920,11 +904,8 @@ Usb_clear_DIR(); Usb_clear_rx_setup(); + send_zlp(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while (!Usb_tx_complete()); - Usb_clear_tx_complete(); - #ifdef USB_ENUM_DEBUG printf("SET RES %BX %BX %BX %BX Answer",LwValue,HwValue,LwIndex,HwIndex); #endif @@ -1187,9 +1168,8 @@ while(!Usb_rx_complete() ); Usb_clear_rx(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while(!(Usb_tx_complete())); - Usb_clear_tx_complete(); + + send_zlp(); } @@ -1216,9 +1196,7 @@ hid_idle_duration = Usb_read_byte(); /* wValue contains the duration */ Usb_clear_rx_setup(); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while(!(Usb_tx_complete())); - Usb_clear_tx_complete(); + send_zlp(); } /*F************************************************************************** @@ -1242,10 +1220,9 @@ Usb_clear_rx_setup(); Usb_set_DIR(); Usb_write_byte(hid_idle_duration); - Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ - while(!(Usb_tx_complete())); - Usb_clear_tx_complete(); + send_zlp(); + while (!(Usb_rx_complete())); Usb_clear_rx(); Usb_clear_DIR(); @@ -1258,3 +1235,10 @@ Usb_clear_stall_request(); Usb_clear_stalled(); } + +static void send_zlp(void) +{ + Usb_set_tx_ready(); + while (!(Usb_tx_complete())); + Usb_clear_tx_complete(); +} |