mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-19 19:21:05 +00:00
more with pio usb
This commit is contained in:
parent
12debd7763
commit
2f9b9a31be
@ -1 +1 @@
|
|||||||
Subproject commit f656d703f3cee1e589eebb6606e204f59afb5611
|
Subproject commit 496454021deab00e1c425a6eb70009666fa036b3
|
@ -31,6 +31,7 @@
|
|||||||
#include "pico.h"
|
#include "pico.h"
|
||||||
#include "hardware/pio.h"
|
#include "hardware/pio.h"
|
||||||
#include "pio_usb.h"
|
#include "pio_usb.h"
|
||||||
|
#include "pio_usb_ll.h"
|
||||||
|
|
||||||
#include "device/dcd.h"
|
#include "device/dcd.h"
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ void dcd_edpt_close_all (uint8_t rhport)
|
|||||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
endpoint_t *ep = pio_usb_device_get_ep(ep_addr);
|
endpoint_t *ep = pio_usb_device_get_endpoint_by_address(ep_addr);
|
||||||
return pio_usb_ll_endpoint_transfer(ep, buffer, total_bytes);
|
return pio_usb_ll_endpoint_transfer(ep, buffer, total_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
|||||||
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
endpoint_t *ep = pio_usb_device_get_ep(ep_addr);
|
endpoint_t *ep = pio_usb_device_get_endpoint_by_address(ep_addr);
|
||||||
ep->stalled = true;
|
ep->stalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
endpoint_t *ep = pio_usb_device_get_ep(ep_addr);
|
endpoint_t *ep = pio_usb_device_get_endpoint_by_address(ep_addr);
|
||||||
ep->data_id = 0;
|
ep->data_id = 0;
|
||||||
ep->stalled = false;
|
ep->stalled = false;
|
||||||
}
|
}
|
||||||
@ -154,24 +155,24 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
//
|
//
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
static void __no_inline_not_in_flash_func(handle_endpoint_irq)(pio_hw_root_port_t* port, uint32_t flag)
|
static void __no_inline_not_in_flash_func(handle_endpoint_irq)(root_port_t* rport, uint32_t flag)
|
||||||
{
|
{
|
||||||
volatile uint32_t* ep_reg;
|
volatile uint32_t* ep_reg;
|
||||||
xfer_result_t result;
|
xfer_result_t result;
|
||||||
|
|
||||||
if ( flag == PIO_USB_INTS_ENDPOINT_COMPLETE_BITS )
|
if ( flag == PIO_USB_INTS_ENDPOINT_COMPLETE_BITS )
|
||||||
{
|
{
|
||||||
ep_reg = &port->ep_complete;
|
ep_reg = &rport->ep_complete;
|
||||||
result = XFER_RESULT_SUCCESS;
|
result = XFER_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
else if ( flag == PIO_USB_INTS_ENDPOINT_ERROR_BITS )
|
else if ( flag == PIO_USB_INTS_ENDPOINT_ERROR_BITS )
|
||||||
{
|
{
|
||||||
ep_reg = &port->ep_error;
|
ep_reg = &rport->ep_error;
|
||||||
result = XFER_RESULT_FAILED;
|
result = XFER_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
else if ( flag == PIO_USB_INTS_ENDPOINT_STALLED_BITS )
|
else if ( flag == PIO_USB_INTS_ENDPOINT_STALLED_BITS )
|
||||||
{
|
{
|
||||||
ep_reg = &port->ep_stalled;
|
ep_reg = &rport->ep_stalled;
|
||||||
result = XFER_RESULT_STALLED;
|
result = XFER_RESULT_STALLED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -188,8 +189,8 @@ static void __no_inline_not_in_flash_func(handle_endpoint_irq)(pio_hw_root_port_
|
|||||||
|
|
||||||
if (ep_all & mask)
|
if (ep_all & mask)
|
||||||
{
|
{
|
||||||
endpoint_t* ep = PIO_USB_HW_EP(ep_idx);
|
endpoint_t* ep = PIO_USB_ENDPOINT(ep_idx);
|
||||||
uint8_t const tu_rhport = port - PIO_USB_HW_RPORT(0) + 1;
|
uint8_t const tu_rhport = rport - PIO_USB_ROOT_PORT(0) + 1;
|
||||||
dcd_event_xfer_complete(tu_rhport, ep->ep_num, ep->actual_len, result, true);
|
dcd_event_xfer_complete(tu_rhport, ep->ep_num, ep->actual_len, result, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,8 +203,8 @@ static void __no_inline_not_in_flash_func(handle_endpoint_irq)(pio_hw_root_port_
|
|||||||
void __no_inline_not_in_flash_func(pio_usb_device_irq_handler)(uint8_t root_id)
|
void __no_inline_not_in_flash_func(pio_usb_device_irq_handler)(uint8_t root_id)
|
||||||
{
|
{
|
||||||
uint8_t const tu_rhport = root_id + 1;
|
uint8_t const tu_rhport = root_id + 1;
|
||||||
pio_hw_root_port_t* port = PIO_USB_HW_RPORT(root_id);
|
root_port_t* rport = PIO_USB_ROOT_PORT(root_id);
|
||||||
uint32_t const ints = port->ints;
|
uint32_t const ints = rport->ints;
|
||||||
|
|
||||||
if (ints & PIO_USB_INTS_RESET_END_BITS)
|
if (ints & PIO_USB_INTS_RESET_END_BITS)
|
||||||
{
|
{
|
||||||
@ -212,16 +213,16 @@ void __no_inline_not_in_flash_func(pio_usb_device_irq_handler)(uint8_t root_id)
|
|||||||
|
|
||||||
if (ints & PIO_USB_INTS_SETUP_REQ_BITS)
|
if (ints & PIO_USB_INTS_SETUP_REQ_BITS)
|
||||||
{
|
{
|
||||||
dcd_event_setup_received(tu_rhport, port->setup_packet, true);
|
dcd_event_setup_received(tu_rhport, rport->setup_packet, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ints & PIO_USB_INTS_ENDPOINT_COMPLETE_BITS )
|
if ( ints & PIO_USB_INTS_ENDPOINT_COMPLETE_BITS )
|
||||||
{
|
{
|
||||||
handle_endpoint_irq(port, PIO_USB_INTS_ENDPOINT_COMPLETE_BITS);
|
handle_endpoint_irq(rport, PIO_USB_INTS_ENDPOINT_COMPLETE_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear all
|
// clear all
|
||||||
port->ints &= ~ints;
|
rport->ints &= ~ints;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "pico.h"
|
#include "pico.h"
|
||||||
#include "hardware/pio.h"
|
#include "hardware/pio.h"
|
||||||
#include "pio_usb.h"
|
#include "pio_usb.h"
|
||||||
|
#include "pio_usb_ll.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INCLUDE
|
// INCLUDE
|
||||||
@ -72,8 +73,8 @@ bool hcd_port_connect_status(uint8_t rhport)
|
|||||||
{
|
{
|
||||||
rhport = RHPORT_PIO(rhport);
|
rhport = RHPORT_PIO(rhport);
|
||||||
|
|
||||||
pio_hw_root_port_t *root = PIO_USB_HW_RPORT(rhport);
|
root_port_t *root = PIO_USB_ROOT_PORT(rhport);
|
||||||
port_pin_status_t line_state = pio_usb_ll_get_line_state(root);
|
port_pin_status_t line_state = pio_usb_bus_get_line_state(root);
|
||||||
|
|
||||||
return line_state != PORT_PIN_SE0;
|
return line_state != PORT_PIN_SE0;
|
||||||
}
|
}
|
||||||
@ -82,7 +83,7 @@ tusb_speed_t hcd_port_speed_get(uint8_t rhport)
|
|||||||
{
|
{
|
||||||
// TODO determine link speed
|
// TODO determine link speed
|
||||||
rhport = RHPORT_PIO(rhport);
|
rhport = RHPORT_PIO(rhport);
|
||||||
return PIO_USB_HW_RPORT(rhport)->is_fullspeed ? TUSB_SPEED_FULL : TUSB_SPEED_LOW;
|
return PIO_USB_ROOT_PORT(rhport)->is_fullspeed ? TUSB_SPEED_FULL : TUSB_SPEED_LOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close all opened endpoint belong to this device
|
// Close all opened endpoint belong to this device
|
||||||
@ -153,7 +154,7 @@ bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __no_inline_not_in_flash_func(handle_endpoint_irq)(pio_hw_root_port_t* port, uint32_t flag)
|
static void __no_inline_not_in_flash_func(handle_endpoint_irq)(root_port_t* port, uint32_t flag)
|
||||||
{
|
{
|
||||||
volatile uint32_t* ep_reg;
|
volatile uint32_t* ep_reg;
|
||||||
xfer_result_t result;
|
xfer_result_t result;
|
||||||
@ -187,7 +188,7 @@ static void __no_inline_not_in_flash_func(handle_endpoint_irq)(pio_hw_root_port_
|
|||||||
|
|
||||||
if (ep_all & mask)
|
if (ep_all & mask)
|
||||||
{
|
{
|
||||||
endpoint_t* ep = PIO_USB_HW_EP(ep_idx);
|
endpoint_t* ep = PIO_USB_ENDPOINT(ep_idx);
|
||||||
hcd_event_xfer_complete(ep->dev_addr, ep->ep_num, ep->actual_len, result, true);
|
hcd_event_xfer_complete(ep->dev_addr, ep->ep_num, ep->actual_len, result, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +200,7 @@ static void __no_inline_not_in_flash_func(handle_endpoint_irq)(pio_hw_root_port_
|
|||||||
// IRQ Handler
|
// IRQ Handler
|
||||||
void __no_inline_not_in_flash_func(pio_usb_host_irq_handler)(uint8_t root_id)
|
void __no_inline_not_in_flash_func(pio_usb_host_irq_handler)(uint8_t root_id)
|
||||||
{
|
{
|
||||||
pio_hw_root_port_t* port = PIO_USB_HW_RPORT(root_id);
|
root_port_t* port = PIO_USB_ROOT_PORT(root_id);
|
||||||
uint32_t const ints = port->ints;
|
uint32_t const ints = port->ints;
|
||||||
|
|
||||||
if ( ints & PIO_USB_INTS_CONNECT_BITS )
|
if ( ints & PIO_USB_INTS_CONNECT_BITS )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user