mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
clean up pio driver
This commit is contained in:
parent
b5a9537eea
commit
a32cb1bb93
@ -1 +1 @@
|
||||
Subproject commit d6712cad5bfbddb25647974f0d583596e703c06f
|
||||
Subproject commit 98e3feefcd1c7218bced0ea2ea35530fd1b550e4
|
@ -174,16 +174,40 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
|
||||
extern void dcd_event_handler(dcd_event_t const * event, bool in_isr);
|
||||
|
||||
// helper to send bus signal event
|
||||
extern void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr);
|
||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = eid };
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
// helper to send bus reset event
|
||||
extern void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr);
|
||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_BUS_RESET };
|
||||
event.bus_reset.speed = speed;
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
// helper to send setup received
|
||||
extern void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr);
|
||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SETUP_RECEIVED };
|
||||
memcpy(&event.setup_received, setup, 8);
|
||||
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
// helper to send transfer complete event
|
||||
extern void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr);
|
||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_XFER_COMPLETE };
|
||||
|
||||
event.xfer_complete.ep_addr = ep_addr;
|
||||
event.xfer_complete.len = xferred_bytes;
|
||||
event.xfer_complete.result = result;
|
||||
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ static inline usbd_class_driver_t const * get_driver(uint8_t drvid)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
enum { RHPORT_INVALID = 0xFFu };
|
||||
static uint8_t _usbd_rhport = RHPORT_INVALID;
|
||||
static volatile uint8_t _usbd_rhport = RHPORT_INVALID;
|
||||
|
||||
// Event queue
|
||||
// usbd_int_set() is used as mutex in OS NONE config
|
||||
@ -1065,7 +1065,7 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
//--------------------------------------------------------------------+
|
||||
// DCD Event Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
||||
void __no_inline_not_in_flash_func(dcd_event_handler)(dcd_event_t const * event, bool in_isr)
|
||||
{
|
||||
switch (event->event_id)
|
||||
{
|
||||
@ -1115,38 +1115,6 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
||||
}
|
||||
}
|
||||
|
||||
void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = eid };
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_BUS_RESET };
|
||||
event.bus_reset.speed = speed;
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SETUP_RECEIVED };
|
||||
memcpy(&event.setup_received, setup, 8);
|
||||
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr)
|
||||
{
|
||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_XFER_COMPLETE };
|
||||
|
||||
event.xfer_complete.ep_addr = ep_addr;
|
||||
event.xfer_complete.len = xferred_bytes;
|
||||
event.xfer_complete.result = result;
|
||||
|
||||
dcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD API For Class Driver
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -46,7 +46,7 @@ bool tud_inited(void);
|
||||
// Task function should be called in main/rtos loop
|
||||
void tud_task (void);
|
||||
|
||||
// Check if there is pending events need proccessing by tud_task()
|
||||
// Check if there is pending events need processing by tud_task()
|
||||
bool tud_task_event_ready(void);
|
||||
|
||||
// Interrupt handler, name alias to DCD
|
||||
|
@ -78,7 +78,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||
// must be called before queuing status
|
||||
pio_usb_device_set_address(pio_rhport, dev_addr);
|
||||
|
||||
pio_usb_device_endpoint_transfer(pio_rhport, 0x80, NULL, 0);
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0);
|
||||
}
|
||||
|
||||
// Wake up host
|
||||
@ -118,8 +118,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
{
|
||||
uint8_t const pio_rhport = RHPORT_PIO(rhport);
|
||||
return pio_usb_device_endpoint_transfer(pio_rhport, ep_addr, buffer, total_bytes);
|
||||
(void) rhport;
|
||||
pio_hw_endpoint_t *ep = pio_usb_device_get_ep(ep_addr);
|
||||
return pio_usb_endpoint_transfer(ep, buffer, total_bytes);
|
||||
}
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||
|
@ -51,7 +51,7 @@ static pio_usb_configuration_t pio_host_config = PIO_USB_DEFAULT_CONFIG;
|
||||
bool hcd_init(uint8_t rhport)
|
||||
{
|
||||
// To run USB SOF interrupt in core1, call this init in core1
|
||||
pio_usb_host_controller_init(&pio_host_config);
|
||||
pio_usb_host_init(&pio_host_config);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -59,13 +59,13 @@ bool hcd_init(uint8_t rhport)
|
||||
void hcd_port_reset(uint8_t rhport)
|
||||
{
|
||||
rhport = RHPORT_PIO(rhport);
|
||||
pio_usb_hw_port_reset_start(rhport);
|
||||
pio_usb_host_port_reset_start(rhport);
|
||||
}
|
||||
|
||||
void hcd_port_reset_end(uint8_t rhport)
|
||||
{
|
||||
rhport = RHPORT_PIO(rhport);
|
||||
pio_usb_hw_port_reset_end(rhport);
|
||||
pio_usb_host_port_reset_end(rhport);
|
||||
}
|
||||
|
||||
bool hcd_port_connect_status(uint8_t rhport)
|
||||
|
Loading…
x
Reference in New Issue
Block a user