@@ -62,7 +62,7 @@ void tusb_host_port_changed(tusb_host_t* host, uint8_t port, host_port_state_t n
6262 POST_MESSAGE (root -> mq , tusbh_msg_root_disconnected , 0 , host , 0 );
6363 }else {
6464 root -> en_mask &= ~(1 <<0 );
65- POST_MESSAGE (root -> mq , tusbh_msg_root_disable , 0 , host , 0 );
65+ POST_MESSAGE (root -> mq , tusbh_msg_root_disable , 0 , host , new_state );
6666 }
6767}
6868
@@ -152,7 +152,6 @@ void tusbh_close_pipe(tusbh_device_t* dev, int pipe_num)
152152 tusb_pipe_close (& pipe );
153153}
154154
155- #if 1
156155static channel_state_t tusbh_pipe_xfer_and_wait (tusbh_device_t * dev , int pipe_num , uint8_t is_data , void * data , uint16_t len , uint32_t timeout )
157156{
158157 void * bak = dev -> host -> hc [pipe_num ].user_data ;
@@ -168,49 +167,24 @@ static channel_state_t tusbh_pipe_xfer_and_wait(tusbh_device_t* dev, int pipe_nu
168167 channel_state_t s ;
169168
170169 do {
171- tusb_host_xfer_data (dev -> host , pipe_num , is_data , p , remain );
170+ tusb_host_xfer_data (dev -> host , pipe_num , is_data , p , remain , dev -> hub_port );
172171 tusbh_evt_wait (dev -> xfer_evt .event , timeout );
173172 tusb_hc_data_t * hc = & dev -> host -> hc [pipe_num ];
174173 s = (channel_state_t )hc -> state ;
175- if (s != TUSB_CS_TRANSFER_CSPLIT ) {
176- if (s != TUSB_CS_TRANSFER_COMPLETE ){
177- res = - (int )s ;
178- goto error ;
179- }
180- remain -= hc -> count ;
181- p += hc -> count ;
174+ if (s != TUSB_CS_TRANSFER_COMPLETE ){
175+ res = - (int )s ;
176+ goto error ;
182177 }
183- }while ((remain && len ) || (s == TUSB_CS_TRANSFER_CSPLIT ));
178+ remain -= hc -> count ;
179+ p += hc -> count ;
180+ }while ((remain && len ));
184181 res = p - ((uint8_t * )data );
185182error :
186183 dev -> host -> hc [pipe_num ].user_data = bak ;
187184 r = (channel_state_t )dev -> host -> hc [pipe_num ].state ;
188185 return r ;
189186}
190187
191- #else
192-
193- static channel_state_t tusbh_pipe_xfer_and_wait (tusbh_device_t * dev , int pipe_num , uint8_t is_data , void * data , uint16_t len , uint32_t timeout )
194- {
195- void * bak = dev -> host -> hc [pipe_num ].user_data ;
196- dev -> host -> hc [pipe_num ].user_data = & dev -> xfer_evt ;
197-
198- tusb_host_xfer_data (dev -> host , pipe_num , is_data , data , len );
199-
200- channel_state_t r = TUSB_CS_UNKNOWN_ERROR ;
201-
202- //int res =
203- tusbh_evt_wait (dev -> xfer_evt .event , timeout );
204-
205- //if(res == 0){
206- r = (channel_state_t )dev -> host -> hc [pipe_num ].state ;
207- //}
208- dev -> host -> hc [pipe_num ].user_data = bak ;
209-
210- return r ;
211- }
212- #endif
213-
214188int tusbh_ep_xfer (tusbh_ep_info_t * ep , void * data , uint16_t len , uint32_t timeout )
215189{
216190 return tusbh_ep_xfer_with_event (ep , data , len , & ep_device (ep )-> xfer_evt , timeout );
@@ -223,15 +197,17 @@ static int tusbh_ep_in_xfer_with_event(tusbh_ep_info_t* ep, void* data, uint16_t
223197 uint16_t remain = len ;
224198 uint8_t * p = (uint8_t * )data ;
225199 int res = 0 ;
200+
201+ channel_state_t s ;
226202 do {
227203 uint16_t xfer_len = EP_MPS (ep -> desc );
228204 if (xfer_len > remain ){
229205 xfer_len = remain ;
230206 }
231- tusb_host_xfer_data (ep_host (ep ), ep -> pipe_num , 1 , p , xfer_len );
207+ tusb_host_xfer_data (ep_host (ep ), ep -> pipe_num , 1 , p , xfer_len , ep_device ( ep ) -> hub_port );
232208 tusbh_evt_wait (action -> event , timeout );
233209 tusb_hc_data_t * hc = & ep_device (ep )-> host -> hc [ep -> pipe_num ];
234- channel_state_t s = (channel_state_t )hc -> state ;
210+ s = (channel_state_t )hc -> state ;
235211 if (s != TUSB_CS_TRANSFER_COMPLETE ){
236212 res = - (int )s ;
237213 goto error ;
@@ -273,7 +249,7 @@ static int tusbh_ep_out_xfer_with_event(tusbh_ep_info_t* ep, void* data, uint16_
273249 }else {
274250 xfer_len = remain ;
275251 }
276- tusb_host_xfer_data (ep_host (ep ), ep -> pipe_num , 1 , p , xfer_len );
252+ tusb_host_xfer_data (ep_host (ep ), ep -> pipe_num , 1 , p , xfer_len , ep_device ( ep ) -> hub_port );
277253 tusbh_evt_wait (action -> event , timeout );
278254 tusb_hc_data_t * hc = & ep_device (ep )-> host -> hc [ep -> pipe_num ];
279255 channel_state_t s = (channel_state_t )hc -> state ;
@@ -876,7 +852,7 @@ static void tusbh_msg_root_disable(tusbh_message_t* msg)
876852 tusbh_root_hub_t * root = (tusbh_root_hub_t * )host -> user_data ;
877853 (void )port ;
878854 (void )root ;
879- TUSB_ROOT_INFO ("Disable\n" );
855+ TUSB_ROOT_INFO ("Disable %d \n" , msg -> len );
880856}
881857
882858static void tusbh_ep_data_xfered (tusbh_message_t * msg )
@@ -949,7 +925,7 @@ static void start_period_in(tusbh_device_t* dev, tusbh_ep_info_t* ep)
949925 if (ep -> pipe_num >= 0 ){
950926 uint16_t mps = EP_MPS (ep -> desc );
951927 ep -> xfer_in_progress = 1 ;
952- tusb_host_xfer_data (dev -> host , ep -> pipe_num , 1 , ep -> data , mps );
928+ tusb_host_xfer_data (dev -> host , ep -> pipe_num , 1 , ep -> data , mps , dev -> hub_port );
953929 }
954930}
955931
0 commit comments