29
29
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
30
30
#endif
31
31
32
- #define NU_MAX_USBH_PORT 1 /*USB1.1 port*/
32
+ #define NU_MAX_USBH_PORT 1 /* USB1.1 port */
33
33
#define NU_MAX_USBH_PIPE 16
34
34
#define NU_USBH_THREAD_STACK_SIZE 2048
35
35
60
60
#define NU_USBHOST_UNLOCK ()
61
61
#endif
62
62
63
- /* Private typedef --------------------------------------------------------------*/
63
+ /* Private typedef -------------------------------------------------------------- */
64
64
typedef struct nu_port_dev
65
65
{
66
66
rt_bool_t bRHParent ;
@@ -89,7 +89,7 @@ struct nu_usbh_dev
89
89
S_NU_RH_PORT_CTRL asPortCtrl [NU_MAX_USBH_PORT ];
90
90
};
91
91
92
- /* Private variables ------------------------------------------------------------*/
92
+ /* Private variables ------------------------------------------------------------ */
93
93
static struct nu_usbh_dev s_sUSBHDev ;
94
94
95
95
static S_NU_RH_PORT_CTRL *
@@ -100,13 +100,13 @@ GetRHPortControlFromPipe(
100
100
int port ;
101
101
if (pipe -> inst -> parent_hub -> is_roothub )
102
102
{
103
- /*case: device ---> root hub*/
103
+ /* case: device ---> root hub */
104
104
inst = pipe -> inst ;
105
105
port = inst -> port ;
106
106
}
107
107
else
108
108
{
109
- /*case: device ---> hub ---> root hub*/
109
+ /* case: device ---> hub ---> root hub */
110
110
inst = pipe -> inst -> parent_hub -> self ;
111
111
port = inst -> port ;
112
112
}
@@ -132,11 +132,11 @@ GetPortDevFromPipe(
132
132
133
133
if (pipe -> inst -> parent_hub -> is_roothub )
134
134
{
135
- /*case: device ---> root hub*/
135
+ /* case: device ---> root hub */
136
136
return & psRHPortCtrl -> sRHPortDev ;
137
137
}
138
138
139
- /*case: device ---> hub ---> root hub*/
139
+ /* case: device ---> hub ---> root hub */
140
140
for (i = 0 ; i < NU_MAX_USBH_HUB_PORT_DEV ; i ++ )
141
141
{
142
142
if (psRHPortCtrl -> asHubPortDev [i ].port_num == pipe -> inst -> port )
@@ -266,7 +266,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
266
266
267
267
if ((psPortDev == NULL ) || (psPortDev -> pUDev == NULL ))
268
268
{
269
- /*allocate new dev for hub device*/
269
+ /* allocate new dev for hub device */
270
270
psPortDev = AllocateNewUDev (psPortCtrl );
271
271
272
272
if (psPortDev == RT_NULL )
@@ -291,7 +291,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
291
291
psPortDev -> bEnumDone = FALSE;
292
292
}
293
293
294
- /*For ep0 control transfer*/
294
+ /* For ep0 control transfer */
295
295
if ((pipe -> ep .bEndpointAddress & 0x7F ) == 0 )
296
296
{
297
297
pipe -> pipe_index = 0 ;
@@ -339,7 +339,7 @@ static rt_err_t nu_close_pipe(upipe_t pipe)
339
339
340
340
psPortDev = GetPortDevFromPipe (pipe );
341
341
342
- /*For ep0 control transfer*/
342
+ /* For ep0 control transfer */
343
343
if ((pipe -> ep .bEndpointAddress & 0x7F ) == 0 )
344
344
{
345
345
if ((psPortDev ) && (psPortDev -> bRHParent == FALSE) && (psPortDev -> bEnumDone == TRUE))
@@ -410,7 +410,7 @@ static int nu_bulk_xfer(
410
410
if (ret < 0 )
411
411
return ret ;
412
412
413
- /*wait transfer done*/
413
+ /* wait transfer done */
414
414
if (rt_completion_wait (& (psPortDev -> utr_completion ), timeouts ) < 0 )
415
415
{
416
416
rt_kprintf ("Request Timeout in %d ms!! (bulk_xfer)\n" , timeouts );
@@ -465,7 +465,7 @@ static void xfer_done_cb(UTR_T *psUTR)
465
465
{
466
466
S_NU_PORT_DEV * psPortDev = (S_NU_PORT_DEV * )psUTR -> context ;
467
467
468
- /*transfer done, signal utr_completion*/
468
+ /* transfer done, signal utr_completion */
469
469
rt_completion_done (& (psPortDev -> utr_completion ));
470
470
}
471
471
@@ -493,7 +493,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
493
493
goto exit_nu_pipe_xfer ;
494
494
}
495
495
496
- /*ctrl xfer*/
496
+ /* ctrl xfer */
497
497
if (pipe -> ep .bmAttributes == USB_EP_ATTR_CONTROL )
498
498
{
499
499
int ret ;
@@ -507,27 +507,27 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
507
507
/* Read data from USB device. */
508
508
if (psSetup -> request_type & USB_REQ_TYPE_DIR_IN )
509
509
{
510
- /*Store setup request*/
510
+ /* Store setup request */
511
511
rt_memcpy (& psPortCtrl -> asHubPortDev -> asSetupReq [pipe -> pipe_index ], psSetup , sizeof (struct urequest ));
512
512
}
513
513
else
514
514
{
515
515
/* Write data to USB device. */
516
- /*Trigger USBHostLib Ctrl_Xfer*/
516
+ /* Trigger USBHostLib Ctrl_Xfer */
517
517
ret = nu_ctrl_xfer (psPortDev , psSetup , NULL , timeouts );
518
518
if (ret != psSetup -> wLength )
519
519
goto exit_nu_pipe_xfer ;
520
520
}
521
521
}
522
522
else
523
523
{
524
- /*token == USBH_PID_DATA*/
524
+ /* token == USBH_PID_DATA */
525
525
if (buffer_nonch && ((pipe -> ep .bEndpointAddress & USB_DIR_MASK ) == USB_DIR_IN ))
526
526
{
527
527
struct urequest * psSetup = & psPortCtrl -> asHubPortDev -> asSetupReq [pipe -> pipe_index ];
528
528
529
529
/* Read data from USB device. */
530
- /*Trigger USBHostLib Ctril_Xfer*/
530
+ /* Trigger USBHostLib Ctril_Xfer */
531
531
/*
532
532
* Workaround: HCD driver can readback all bytes of setup.wLength, but not support single packet transferring.
533
533
*/
@@ -556,10 +556,10 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
556
556
LOG_D ("%d == USBH_PID_DATA, nil buf-%d" , token , nbytes );
557
557
}
558
558
559
- } /*else*/
559
+ } /* else */
560
560
i32XferLen = nbytes ;
561
561
goto exit_nu_pipe_xfer ;
562
- } /* if ( pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL )*/
562
+ } /* if ( pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL ) */
563
563
else
564
564
{
565
565
@@ -580,7 +580,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
580
580
psUTR -> bIsTransferDone = 0 ;
581
581
psUTR -> status = 0 ;
582
582
583
- /*others xfer*/
583
+ /* others xfer */
584
584
rt_completion_init (& (psPortDev -> utr_completion ));
585
585
586
586
if (pipe -> ep .bmAttributes == USB_EP_ATTR_BULK )
@@ -596,7 +596,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
596
596
if (nu_int_xfer (pipe , psPortDev , psUTR , timeouts ) < 0 )
597
597
{
598
598
LOG_D ("nu_pipe_xfer ERROR: int transfer failed" );
599
- /*goto exit_nu_pipe_xfer;*/
599
+ /* goto exit_nu_pipe_xfer; */
600
600
}
601
601
else
602
602
{
@@ -606,25 +606,25 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
606
606
}
607
607
else if (pipe -> ep .bmAttributes == USB_EP_ATTR_ISOC )
608
608
{
609
- /*TODO: ISO transfer*/
609
+ /* TODO: ISO transfer */
610
610
LOG_D ("nu_pipe_xfer ERROR: isoc transfer not support" );
611
611
goto exit_nu_pipe_xfer ;
612
612
}
613
613
614
- } /*else*/
614
+ } /* else */
615
615
616
616
failreport_nu_pipe_xfer :
617
617
618
618
if (psUTR -> bIsTransferDone == 0 )
619
619
{
620
- /*Timeout*/
620
+ /* Timeout */
621
621
LOG_D ("nu_pipe_xfer ERROR: timeout" );
622
622
pipe -> status = UPIPE_STATUS_ERROR ;
623
623
usbh_quit_utr (psUTR );
624
624
}
625
625
else
626
626
{
627
- /* Transfer Done. Get status*/
627
+ /* Transfer Done. Get status */
628
628
if (psUTR -> status == 0 )
629
629
{
630
630
pipe -> status = UPIPE_STATUS_OK ;
@@ -643,7 +643,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
643
643
644
644
exit_nu_pipe_xfer :
645
645
646
- /*Call callback*/
646
+ /* Call callback */
647
647
if (pipe -> callback != RT_NULL )
648
648
{
649
649
pipe -> callback (pipe );
@@ -742,7 +742,7 @@ static void nu_hcd_disconnect_callback(
742
742
}
743
743
744
744
745
- /* USB host operations -----------------------------------------------------------*/
745
+ /* USB host operations ----------------------------------------------------------- */
746
746
static struct uhcd_ops nu_uhcd_ops =
747
747
{
748
748
nu_reset_port ,
@@ -757,10 +757,10 @@ static rt_err_t nu_hcd_init(rt_device_t device)
757
757
758
758
usbh_core_init ();
759
759
760
- /*install connect/disconnect callback*/
760
+ /* install connect/disconnect callback */
761
761
usbh_install_conn_callback (nu_hcd_connect_callback , nu_hcd_disconnect_callback );
762
762
763
- /*create thread for polling usbh port status*/
763
+ /* create thread for polling usbh port status */
764
764
/* create usb hub thread */
765
765
pNuUSBHDev -> polling_thread = rt_thread_create ("usbh_drv" , nu_usbh_rh_thread_entry , RT_NULL ,
766
766
NU_USBH_THREAD_STACK_SIZE , 8 , 20 );
@@ -772,7 +772,7 @@ static rt_err_t nu_hcd_init(rt_device_t device)
772
772
return RT_EOK ;
773
773
}
774
774
775
- /* global function for USB host library -----------------------------*/
775
+ /* global function for USB host library ----------------------------- */
776
776
uint32_t usbh_get_ticks (void )
777
777
{
778
778
return rt_tick_get ();
@@ -880,7 +880,7 @@ int nu_usbh_register(void)
880
880
res = rt_device_register (& psUHCD -> parent , "usbh" , RT_DEVICE_FLAG_DEACTIVATE );
881
881
RT_ASSERT (res == RT_EOK );
882
882
883
- /*initialize the usb host function */
883
+ /* initialize the usb host function */
884
884
res = rt_usb_host_init ("usbh" );
885
885
RT_ASSERT (res == RT_EOK );
886
886
0 commit comments