@@ -48,16 +48,14 @@ static pio_usb_configuration_t pio_host_cfg = PIO_USB_DEFAULT_CONFIG;
4848//--------------------------------------------------------------------+
4949// HCD API
5050//--------------------------------------------------------------------+
51- bool hcd_configure (uint8_t rhport , uint32_t cfg_id , const void * cfg_param )
52- {
51+ bool hcd_configure (uint8_t rhport , uint32_t cfg_id , const void * cfg_param ) {
5352 (void ) rhport ;
5453 TU_VERIFY (cfg_id == TUH_CFGID_RPI_PIO_USB_CONFIGURATION );
5554 memcpy (& pio_host_cfg , cfg_param , sizeof (pio_usb_configuration_t ));
5655 return true;
5756}
5857
59- bool hcd_init (uint8_t rhport )
60- {
58+ bool hcd_init (uint8_t rhport ) {
6159 (void ) rhport ;
6260
6361 // To run USB SOF interrupt in core1, call this init in core1
@@ -66,20 +64,17 @@ bool hcd_init(uint8_t rhport)
6664 return true;
6765}
6866
69- void hcd_port_reset (uint8_t rhport )
70- {
67+ void hcd_port_reset (uint8_t rhport ) {
7168 uint8_t const pio_rhport = RHPORT_PIO (rhport );
7269 pio_usb_host_port_reset_start (pio_rhport );
7370}
7471
75- void hcd_port_reset_end (uint8_t rhport )
76- {
72+ void hcd_port_reset_end (uint8_t rhport ) {
7773 uint8_t const pio_rhport = RHPORT_PIO (rhport );
7874 pio_usb_host_port_reset_end (pio_rhport );
7975}
8076
81- bool hcd_port_connect_status (uint8_t rhport )
82- {
77+ bool hcd_port_connect_status (uint8_t rhport ) {
8378 uint8_t const pio_rhport = RHPORT_PIO (rhport );
8479
8580 root_port_t * root = PIO_USB_ROOT_PORT (pio_rhport );
@@ -88,52 +83,45 @@ bool hcd_port_connect_status(uint8_t rhport)
8883 return line_state != PORT_PIN_SE0 ;
8984}
9085
91- tusb_speed_t hcd_port_speed_get (uint8_t rhport )
92- {
86+ tusb_speed_t hcd_port_speed_get (uint8_t rhport ) {
9387 // TODO determine link speed
9488 uint8_t const pio_rhport = RHPORT_PIO (rhport );
9589 return PIO_USB_ROOT_PORT (pio_rhport )-> is_fullspeed ? TUSB_SPEED_FULL : TUSB_SPEED_LOW ;
9690}
9791
9892// Close all opened endpoint belong to this device
99- void hcd_device_close (uint8_t rhport , uint8_t dev_addr )
100- {
93+ void hcd_device_close (uint8_t rhport , uint8_t dev_addr ) {
10194 uint8_t const pio_rhport = RHPORT_PIO (rhport );
10295 pio_usb_host_close_device (pio_rhport , dev_addr );
10396}
10497
105- uint32_t hcd_frame_number (uint8_t rhport )
106- {
98+ uint32_t hcd_frame_number (uint8_t rhport ) {
10799 (void ) rhport ;
108100 return pio_usb_host_get_frame_number ();
109101}
110102
111- void hcd_int_enable (uint8_t rhport )
112- {
103+ void hcd_int_enable (uint8_t rhport ) {
113104 (void ) rhport ;
114105}
115106
116- void hcd_int_disable (uint8_t rhport )
117- {
107+ void hcd_int_disable (uint8_t rhport ) {
118108 (void ) rhport ;
119109}
120110
121111//--------------------------------------------------------------------+
122112// Endpoint API
123113//--------------------------------------------------------------------+
124114
125- bool hcd_edpt_open (uint8_t rhport , uint8_t dev_addr , tusb_desc_endpoint_t const * desc_ep )
126- {
115+ bool hcd_edpt_open (uint8_t rhport , uint8_t dev_addr , tusb_desc_endpoint_t const * desc_ep ) {
127116 hcd_devtree_info_t dev_tree ;
128117 hcd_devtree_get_info (dev_addr , & dev_tree );
129118 bool const need_pre = (dev_tree .hub_addr && dev_tree .speed == TUSB_SPEED_LOW );
130119
131120 uint8_t const pio_rhport = RHPORT_PIO (rhport );
132- return pio_usb_host_endpoint_open (pio_rhport , dev_addr , (uint8_t const * ) desc_ep , need_pre );
121+ return pio_usb_host_endpoint_open (pio_rhport , dev_addr , (uint8_t const * ) desc_ep , need_pre );
133122}
134123
135- bool hcd_edpt_xfer (uint8_t rhport , uint8_t dev_addr , uint8_t ep_addr , uint8_t * buffer , uint16_t buflen )
136- {
124+ bool hcd_edpt_xfer (uint8_t rhport , uint8_t dev_addr , uint8_t ep_addr , uint8_t * buffer , uint16_t buflen ) {
137125 uint8_t const pio_rhport = RHPORT_PIO (rhport );
138126 return pio_usb_host_endpoint_transfer (pio_rhport , dev_addr , ep_addr , buffer , buflen );
139127}
@@ -143,8 +131,7 @@ bool hcd_edpt_abort_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr) {
143131 return pio_usb_host_endpoint_abort_transfer (pio_rhport , dev_addr , ep_addr );
144132}
145133
146- bool hcd_setup_send (uint8_t rhport , uint8_t dev_addr , uint8_t const setup_packet [8 ])
147- {
134+ bool hcd_setup_send (uint8_t rhport , uint8_t dev_addr , uint8_t const setup_packet [8 ]) {
148135 uint8_t const pio_rhport = RHPORT_PIO (rhport );
149136 return pio_usb_host_send_setup (pio_rhport , dev_addr , setup_packet );
150137}
@@ -171,18 +158,16 @@ bool hcd_edpt_clear_stall(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr) {
171158 return true;
172159}
173160
174- static void __no_inline_not_in_flash_func (handle_endpoint_irq )(root_port_t * rport , xfer_result_t result , volatile uint32_t * ep_reg )
175- {
161+ static void __no_inline_not_in_flash_func (handle_endpoint_irq )(root_port_t * rport , xfer_result_t result ,
162+ volatile uint32_t * ep_reg ) {
176163 (void ) rport ;
177164 const uint32_t ep_all = * ep_reg ;
178165
179- for (uint8_t ep_idx = 0 ; ep_idx < PIO_USB_EP_POOL_CNT ; ep_idx ++ )
180- {
166+ for ( uint8_t ep_idx = 0 ; ep_idx < PIO_USB_EP_POOL_CNT ; ep_idx ++ ) {
181167 uint32_t const mask = (1u << ep_idx );
182168
183- if (ep_all & mask )
184- {
185- endpoint_t * ep = PIO_USB_ENDPOINT (ep_idx );
169+ if ( ep_all & mask ) {
170+ endpoint_t * ep = PIO_USB_ENDPOINT (ep_idx );
186171 hcd_event_xfer_complete (ep -> dev_addr , ep -> ep_num , ep -> actual_len , result , true);
187172 }
188173 }
@@ -192,34 +177,28 @@ static void __no_inline_not_in_flash_func(handle_endpoint_irq)(root_port_t* rpor
192177}
193178
194179// IRQ Handler
195- void __no_inline_not_in_flash_func (pio_usb_host_irq_handler )(uint8_t root_id )
196- {
180+ void __no_inline_not_in_flash_func (pio_usb_host_irq_handler )(uint8_t root_id ) {
197181 uint8_t const tu_rhport = root_id + 1 ;
198- root_port_t * rport = PIO_USB_ROOT_PORT (root_id );
182+ root_port_t * rport = PIO_USB_ROOT_PORT (root_id );
199183 uint32_t const ints = rport -> ints ;
200184
201- if ( ints & PIO_USB_INTS_CONNECT_BITS )
202- {
185+ if ( ints & PIO_USB_INTS_CONNECT_BITS ) {
203186 hcd_event_device_attach (tu_rhport , true);
204187 }
205188
206- if ( ints & PIO_USB_INTS_DISCONNECT_BITS )
207- {
189+ if ( ints & PIO_USB_INTS_DISCONNECT_BITS ) {
208190 hcd_event_device_remove (tu_rhport , true);
209191 }
210192
211- if ( ints & PIO_USB_INTS_ENDPOINT_COMPLETE_BITS )
212- {
193+ if ( ints & PIO_USB_INTS_ENDPOINT_COMPLETE_BITS ) {
213194 handle_endpoint_irq (rport , XFER_RESULT_SUCCESS , & rport -> ep_complete );
214195 }
215196
216- if ( ints & PIO_USB_INTS_ENDPOINT_STALLED_BITS )
217- {
197+ if ( ints & PIO_USB_INTS_ENDPOINT_STALLED_BITS ) {
218198 handle_endpoint_irq (rport , XFER_RESULT_STALLED , & rport -> ep_stalled );
219199 }
220200
221- if ( ints & PIO_USB_INTS_ENDPOINT_ERROR_BITS )
222- {
201+ if ( ints & PIO_USB_INTS_ENDPOINT_ERROR_BITS ) {
223202 handle_endpoint_irq (rport , XFER_RESULT_FAILED , & rport -> ep_error );
224203 }
225204
0 commit comments