mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 21:41:09 +00:00
rhport argument in usbd_ API() is not used (always use the initialized port)
remove the usage of TUD_OPT_RHPORT in class driver
This commit is contained in:
parent
99c1585ed2
commit
8b9cf152a0
@ -41,7 +41,12 @@
|
|||||||
|
|
||||||
// This example doesn't use an RTOS
|
// This example doesn't use an RTOS
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
||||||
|
#ifndef CFG_TUSB_DEBUG
|
||||||
|
#define CFG_TUSB_DEBUG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable Device stack
|
// Enable Device stack
|
||||||
@ -53,34 +58,14 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RHPort max operational speed can defined by board.mk
|
// RHPort max operational speed can defined by board.mk
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
#ifndef BOARD_TUD_MAX_SPEED
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
// Default is max speed that hardware controller could support with on-chip PHY
|
||||||
#if BOARD_TUD_RHPORT == 0
|
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
|
||||||
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_TUD_MAX_SPEED)
|
|
||||||
#elif BOARD_TUD_RHPORT == 1
|
|
||||||
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_TUD_MAX_SPEED)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Device max speed, default is max speed that hardware controller could support without external PHY
|
|
||||||
// BOARD_TUD_MAX_SPEED can be used to change value (e.g for board features external PHY).
|
|
||||||
#ifdef BOARD_TUD_MAX_SPEED
|
|
||||||
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
|
|
||||||
#else
|
|
||||||
#define CFG_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
|
||||||
// #define CFG_TUSB_DEBUG 0
|
|
||||||
|
|
||||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||||
* into those specific section.
|
* into those specific section.
|
||||||
|
@ -28,28 +28,40 @@
|
|||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
|
#ifdef BOARD_TUD_RHPORT
|
||||||
|
#define PORT_SUPPORT_DEVICE(_n) (BOARD_TUD_RHPORT == _n)
|
||||||
|
#else
|
||||||
|
#define PORT_SUPPORT_DEVICE(_n) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOARD_TUH_RHPORT
|
||||||
|
#define PORT_SUPPORT_HOST(_n) (BOARD_TUH_RHPORT == _n)
|
||||||
|
#else
|
||||||
|
#define PORT_SUPPORT_HOST(_n) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USB Interrupt Handler
|
// USB Interrupt Handler
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void USB0_IRQHandler(void)
|
void USB0_IRQHandler(void)
|
||||||
{
|
{
|
||||||
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
|
#if PORT_SUPPORT_DEVICE(0)
|
||||||
tuh_int_handler(0);
|
tud_int_handler(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
|
#if PORT_SUPPORT_HOST(0)
|
||||||
tud_int_handler(0);
|
tuh_int_handler(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void USB1_IRQHandler(void)
|
void USB1_IRQHandler(void)
|
||||||
{
|
{
|
||||||
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST
|
#if PORT_SUPPORT_DEVICE(1)
|
||||||
tuh_int_handler(1);
|
tud_int_handler(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
|
#if PORT_SUPPORT_HOST(1)
|
||||||
tud_int_handler(1);
|
tuh_int_handler(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +96,8 @@ void board_init(void)
|
|||||||
SysTick_Config(SystemCoreClock / 1000);
|
SysTick_Config(SystemCoreClock / 1000);
|
||||||
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
|
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||||
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
|
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
|
||||||
//NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||||
|
NVIC_SetPriority(USB1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Chip_GPIO_Init(LPC_GPIO_PORT);
|
Chip_GPIO_Init(LPC_GPIO_PORT);
|
||||||
@ -102,11 +115,11 @@ void board_init(void)
|
|||||||
Chip_UART_TXEnable(UART_DEV);
|
Chip_UART_TXEnable(UART_DEV);
|
||||||
|
|
||||||
//------------- USB -------------//
|
//------------- USB -------------//
|
||||||
#if CFG_TUSB_RHPORT0_MODE
|
#if PORT_SUPPORT_DEVICE(0) || PORT_SUPPORT_HOST(0)
|
||||||
Chip_USB0_Init();
|
Chip_USB0_Init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUSB_RHPORT1_MODE
|
#if PORT_SUPPORT_DEVICE(1) || PORT_SUPPORT_HOST(1)
|
||||||
Chip_USB1_Init();
|
Chip_USB1_Init();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,12 @@ CFG_TUSB_MEM_SECTION btd_interface_t _btd_itf;
|
|||||||
|
|
||||||
static bool bt_tx_data(uint8_t ep, void *data, uint16_t len)
|
static bool bt_tx_data(uint8_t ep, void *data, uint16_t len)
|
||||||
{
|
{
|
||||||
// skip if previous transfer not complete
|
uint8_t const rhport = 0;
|
||||||
TU_VERIFY(!usbd_edpt_busy(TUD_OPT_RHPORT, ep));
|
|
||||||
|
|
||||||
TU_ASSERT(usbd_edpt_xfer(TUD_OPT_RHPORT, ep, data, len));
|
// skip if previous transfer not complete
|
||||||
|
TU_VERIFY(!usbd_edpt_busy(rhport, ep));
|
||||||
|
|
||||||
|
TU_ASSERT(usbd_edpt_xfer(rhport, ep, data, len));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
|
|||||||
|
|
||||||
static bool _prep_out_transaction (cdcd_interface_t* p_cdc)
|
static bool _prep_out_transaction (cdcd_interface_t* p_cdc)
|
||||||
{
|
{
|
||||||
uint8_t const rhport = TUD_OPT_RHPORT;
|
uint8_t const rhport = 0;
|
||||||
uint16_t available = tu_fifo_remaining(&p_cdc->rx_ff);
|
uint16_t available = tu_fifo_remaining(&p_cdc->rx_ff);
|
||||||
|
|
||||||
// Prepare for incoming data but only allow what we can store in the ring buffer.
|
// Prepare for incoming data but only allow what we can store in the ring buffer.
|
||||||
@ -189,7 +189,7 @@ uint32_t tud_cdc_n_write_flush (uint8_t itf)
|
|||||||
// No data to send
|
// No data to send
|
||||||
if ( !tu_fifo_count(&p_cdc->tx_ff) ) return 0;
|
if ( !tu_fifo_count(&p_cdc->tx_ff) ) return 0;
|
||||||
|
|
||||||
uint8_t const rhport = TUD_OPT_RHPORT;
|
uint8_t const rhport = 0;
|
||||||
|
|
||||||
// Claim the endpoint
|
// Claim the endpoint
|
||||||
TU_VERIFY( usbd_edpt_claim(rhport, p_cdc->ep_in), 0 );
|
TU_VERIFY( usbd_edpt_claim(rhport, p_cdc->ep_in), 0 );
|
||||||
|
@ -76,8 +76,9 @@ static inline uint8_t get_index_by_itfnum(uint8_t itf_num)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_hid_n_ready(uint8_t instance)
|
bool tud_hid_n_ready(uint8_t instance)
|
||||||
{
|
{
|
||||||
|
uint8_t const rhport = 0;
|
||||||
uint8_t const ep_in = _hidd_itf[instance].ep_in;
|
uint8_t const ep_in = _hidd_itf[instance].ep_in;
|
||||||
return tud_ready() && (ep_in != 0) && !usbd_edpt_busy(TUD_OPT_RHPORT, ep_in);
|
return tud_ready() && (ep_in != 0) && !usbd_edpt_busy(rhport, ep_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint8_t len)
|
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint8_t len)
|
||||||
@ -103,7 +104,7 @@ bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, u
|
|||||||
memcpy(p_hid->epin_buf, report, len);
|
memcpy(p_hid->epin_buf, report, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return usbd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->epin_buf, len);
|
return usbd_edpt_xfer(rhport, p_hid->ep_in, p_hid->epin_buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tud_hid_n_interface_protocol(uint8_t instance)
|
uint8_t tud_hid_n_interface_protocol(uint8_t instance)
|
||||||
@ -172,7 +173,7 @@ bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id,
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void hidd_init(void)
|
void hidd_init(void)
|
||||||
{
|
{
|
||||||
hidd_reset(TUD_OPT_RHPORT);
|
hidd_reset(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidd_reset(uint8_t rhport)
|
void hidd_reset(uint8_t rhport)
|
||||||
|
@ -92,7 +92,7 @@ bool tud_midi_n_mounted (uint8_t itf)
|
|||||||
|
|
||||||
static void _prep_out_transaction (midid_interface_t* p_midi)
|
static void _prep_out_transaction (midid_interface_t* p_midi)
|
||||||
{
|
{
|
||||||
uint8_t const rhport = TUD_OPT_RHPORT;
|
uint8_t const rhport = 0;
|
||||||
uint16_t available = tu_fifo_remaining(&p_midi->rx_ff);
|
uint16_t available = tu_fifo_remaining(&p_midi->rx_ff);
|
||||||
|
|
||||||
// Prepare for incoming data but only allow what we can store in the ring buffer.
|
// Prepare for incoming data but only allow what we can store in the ring buffer.
|
||||||
@ -219,7 +219,7 @@ static uint32_t write_flush(midid_interface_t* midi)
|
|||||||
// No data to send
|
// No data to send
|
||||||
if ( !tu_fifo_count(&midi->tx_ff) ) return 0;
|
if ( !tu_fifo_count(&midi->tx_ff) ) return 0;
|
||||||
|
|
||||||
uint8_t const rhport = TUD_OPT_RHPORT;
|
uint8_t const rhport = 0;
|
||||||
|
|
||||||
// skip if previous transfer not complete
|
// skip if previous transfer not complete
|
||||||
TU_VERIFY( usbd_edpt_claim(rhport, midi->ep_in), 0 );
|
TU_VERIFY( usbd_edpt_claim(rhport, midi->ep_in), 0 );
|
||||||
|
@ -108,20 +108,22 @@ static bool can_xmit;
|
|||||||
|
|
||||||
void tud_network_recv_renew(void)
|
void tud_network_recv_renew(void)
|
||||||
{
|
{
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, _netd_itf.ep_out, received, sizeof(received));
|
usbd_edpt_xfer(0, _netd_itf.ep_out, received, sizeof(received));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_in_xfer(uint8_t *buf, uint16_t len)
|
static void do_in_xfer(uint8_t *buf, uint16_t len)
|
||||||
{
|
{
|
||||||
can_xmit = false;
|
can_xmit = false;
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, _netd_itf.ep_in, buf, len);
|
usbd_edpt_xfer(0, _netd_itf.ep_in, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void netd_report(uint8_t *buf, uint16_t len)
|
void netd_report(uint8_t *buf, uint16_t len)
|
||||||
{
|
{
|
||||||
|
uint8_t const rhport = 0;
|
||||||
|
|
||||||
// skip if previous report not yet acknowledged by host
|
// skip if previous report not yet acknowledged by host
|
||||||
if ( usbd_edpt_busy(TUD_OPT_RHPORT, _netd_itf.ep_notif) ) return;
|
if ( usbd_edpt_busy(rhport, _netd_itf.ep_notif) ) return;
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, _netd_itf.ep_notif, buf, len);
|
usbd_edpt_xfer(rhport, _netd_itf.ep_notif, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -188,7 +188,7 @@ static void ncm_start_tx(void) {
|
|||||||
ntb->ndp.datagram[ncm_interface.datagram_count].wDatagramLength = 0;
|
ntb->ndp.datagram[ncm_interface.datagram_count].wDatagramLength = 0;
|
||||||
|
|
||||||
// Kick off an endpoint transfer
|
// Kick off an endpoint transfer
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, ncm_interface.ep_in, ntb->data, ntb_length);
|
usbd_edpt_xfer(0, ncm_interface.ep_in, ntb->data, ntb_length);
|
||||||
ncm_interface.transferring = true;
|
ncm_interface.transferring = true;
|
||||||
|
|
||||||
// Swap to the other NTB and clear it out
|
// Swap to the other NTB and clear it out
|
||||||
@ -229,7 +229,7 @@ void tud_network_recv_renew(void)
|
|||||||
{
|
{
|
||||||
if (!ncm_interface.num_datagrams)
|
if (!ncm_interface.num_datagrams)
|
||||||
{
|
{
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, ncm_interface.ep_out, receive_ntb, sizeof(receive_ntb));
|
usbd_edpt_xfer(0, ncm_interface.ep_out, receive_ntb, sizeof(receive_ntb));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,14 +316,15 @@ uint16_t netd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint1
|
|||||||
|
|
||||||
static void ncm_report(void)
|
static void ncm_report(void)
|
||||||
{
|
{
|
||||||
|
uint8_t const rhport = 0;
|
||||||
if (ncm_interface.report_state == REPORT_SPEED) {
|
if (ncm_interface.report_state == REPORT_SPEED) {
|
||||||
ncm_notify_speed_change.header.wIndex = ncm_interface.itf_num;
|
ncm_notify_speed_change.header.wIndex = ncm_interface.itf_num;
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, ncm_interface.ep_notif, (uint8_t *) &ncm_notify_speed_change, sizeof(ncm_notify_speed_change));
|
usbd_edpt_xfer(rhport, ncm_interface.ep_notif, (uint8_t *) &ncm_notify_speed_change, sizeof(ncm_notify_speed_change));
|
||||||
ncm_interface.report_state = REPORT_CONNECTED;
|
ncm_interface.report_state = REPORT_CONNECTED;
|
||||||
ncm_interface.report_pending = true;
|
ncm_interface.report_pending = true;
|
||||||
} else if (ncm_interface.report_state == REPORT_CONNECTED) {
|
} else if (ncm_interface.report_state == REPORT_CONNECTED) {
|
||||||
ncm_notify_connected.header.wIndex = ncm_interface.itf_num;
|
ncm_notify_connected.header.wIndex = ncm_interface.itf_num;
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, ncm_interface.ep_notif, (uint8_t *) &ncm_notify_connected, sizeof(ncm_notify_connected));
|
usbd_edpt_xfer(rhport, ncm_interface.ep_notif, (uint8_t *) &ncm_notify_connected, sizeof(ncm_notify_connected));
|
||||||
ncm_interface.report_state = REPORT_DONE;
|
ncm_interface.report_state = REPORT_DONE;
|
||||||
ncm_interface.report_pending = true;
|
ncm_interface.report_pending = true;
|
||||||
}
|
}
|
||||||
|
12
src/class/vendor/vendor_device.c
vendored
12
src/class/vendor/vendor_device.c
vendored
@ -84,14 +84,16 @@ bool tud_vendor_n_peek(uint8_t itf, uint8_t* u8)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
static void _prep_out_transaction (vendord_interface_t* p_itf)
|
static void _prep_out_transaction (vendord_interface_t* p_itf)
|
||||||
{
|
{
|
||||||
|
uint8_t const rhport = 0;
|
||||||
|
|
||||||
// skip if previous transfer not complete
|
// skip if previous transfer not complete
|
||||||
if ( usbd_edpt_busy(TUD_OPT_RHPORT, p_itf->ep_out) ) return;
|
if ( usbd_edpt_busy(rhport, p_itf->ep_out) ) return;
|
||||||
|
|
||||||
// Prepare for incoming data but only allow what we can store in the ring buffer.
|
// Prepare for incoming data but only allow what we can store in the ring buffer.
|
||||||
uint16_t max_read = tu_fifo_remaining(&p_itf->rx_ff);
|
uint16_t max_read = tu_fifo_remaining(&p_itf->rx_ff);
|
||||||
if ( max_read >= CFG_TUD_VENDOR_EPSIZE )
|
if ( max_read >= CFG_TUD_VENDOR_EPSIZE )
|
||||||
{
|
{
|
||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, p_itf->ep_out, p_itf->epout_buf, CFG_TUD_VENDOR_EPSIZE);
|
usbd_edpt_xfer(rhport, p_itf->ep_out, p_itf->epout_buf, CFG_TUD_VENDOR_EPSIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,13 +117,15 @@ void tud_vendor_n_read_flush (uint8_t itf)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
static uint16_t maybe_transmit(vendord_interface_t* p_itf)
|
static uint16_t maybe_transmit(vendord_interface_t* p_itf)
|
||||||
{
|
{
|
||||||
|
uint8_t const rhport = 0;
|
||||||
|
|
||||||
// skip if previous transfer not complete
|
// skip if previous transfer not complete
|
||||||
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, p_itf->ep_in) );
|
TU_VERIFY( !usbd_edpt_busy(rhport, p_itf->ep_in) );
|
||||||
|
|
||||||
uint16_t count = tu_fifo_read_n(&p_itf->tx_ff, p_itf->epin_buf, CFG_TUD_VENDOR_EPSIZE);
|
uint16_t count = tu_fifo_read_n(&p_itf->tx_ff, p_itf->epin_buf, CFG_TUD_VENDOR_EPSIZE);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, p_itf->ep_in, p_itf->epin_buf, count) );
|
TU_ASSERT( usbd_edpt_xfer(rhport, p_itf->ep_in, p_itf->epin_buf, count) );
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@
|
|||||||
* - ENDPOINT_MAX: max (logical) number of endpoint
|
* - ENDPOINT_MAX: max (logical) number of endpoint
|
||||||
* - ENDPOINT_EXCLUSIVE_NUMBER: endpoint number with different direction IN and OUT aren't allowed,
|
* - ENDPOINT_EXCLUSIVE_NUMBER: endpoint number with different direction IN and OUT aren't allowed,
|
||||||
* e.g EP1 OUT & EP1 IN cannot exist together
|
* e.g EP1 OUT & EP1 IN cannot exist together
|
||||||
* - RHPORT_HIGHSPEED: mask to indicate which port support highspeed mode (without external PHY)
|
* - RHPORT_HIGHSPEED: support highspeed with on-chip PHY
|
||||||
* bit0 for port0 and so on.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//------------- NXP -------------//
|
//------------- NXP -------------//
|
||||||
@ -63,8 +62,7 @@
|
|||||||
#define TUP_USBIP_EHCI
|
#define TUP_USBIP_EHCI
|
||||||
|
|
||||||
#define TUP_DCD_ENDPOINT_MAX 6
|
#define TUP_DCD_ENDPOINT_MAX 6
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x01 // Port0 HS, Port1 FS
|
#define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 FS
|
||||||
|
|
||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
|
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 5
|
#define TUP_DCD_ENDPOINT_MAX 5
|
||||||
@ -82,8 +80,7 @@
|
|||||||
#define TUP_USBIP_EHCI
|
#define TUP_USBIP_EHCI
|
||||||
|
|
||||||
#define TUP_DCD_ENDPOINT_MAX 8
|
#define TUP_DCD_ENDPOINT_MAX 8
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x03 // Port0 HS, Port1 HS
|
#define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 HS
|
||||||
|
|
||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX)
|
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 16
|
#define TUP_DCD_ENDPOINT_MAX 16
|
||||||
@ -107,7 +104,7 @@
|
|||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
|
#elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 10
|
#define TUP_DCD_ENDPOINT_MAX 10
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x01
|
#define TUP_RHPORT_HIGHSPEED 1
|
||||||
#define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
|
#define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
|
||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_PIC32MZ)
|
#elif TU_CHECK_MCU(OPT_MCU_PIC32MZ)
|
||||||
@ -155,7 +152,7 @@
|
|||||||
|
|
||||||
// MCU with on-chip HS Phy
|
// MCU with on-chip HS Phy
|
||||||
#if defined(STM32F723xx) || defined(STM32F730xx) || defined(STM32F733xx)
|
#if defined(STM32F723xx) || defined(STM32F730xx) || defined(STM32F733xx)
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x02 // Port 0: FS, Port 1: HS
|
#define TUP_RHPORT_HIGHSPEED 1 // Port0: FS, Port1: HS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_STM32H7)
|
#elif TU_CHECK_MCU(OPT_MCU_STM32H7)
|
||||||
@ -185,12 +182,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_STM32WB)
|
#elif TU_CHECK_MCU(OPT_MCU_STM32WB)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 8
|
#define TUP_DCD_ENDPOINT_MAX 8
|
||||||
|
|
||||||
//------------- Sony -------------//
|
//------------- Sony -------------//
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_CXD56)
|
#elif TU_CHECK_MCU(OPT_MCU_CXD56)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 7
|
#define TUP_DCD_ENDPOINT_MAX 7
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x01
|
#define TUP_RHPORT_HIGHSPEED 1
|
||||||
#define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
|
#define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
|
||||||
|
|
||||||
//------------- TI -------------//
|
//------------- TI -------------//
|
||||||
@ -213,7 +210,7 @@
|
|||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_NUC505)
|
#elif TU_CHECK_MCU(OPT_MCU_NUC505)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 12
|
#define TUP_DCD_ENDPOINT_MAX 12
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x01
|
#define TUP_RHPORT_HIGHSPEED 1
|
||||||
|
|
||||||
//------------- Espressif -------------//
|
//------------- Espressif -------------//
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
||||||
@ -228,7 +225,7 @@
|
|||||||
#elif TU_CHECK_MCU(OPT_MCU_RP2040)
|
#elif TU_CHECK_MCU(OPT_MCU_RP2040)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 16
|
#define TUP_DCD_ENDPOINT_MAX 16
|
||||||
|
|
||||||
#define TU_ATTR_FAST_FUNC __attribute__((section(".time_critical.tinyusb")))
|
#define TU_ATTR_FAST_FUNC __attribute__((section(".time_critical.tinyusb")))
|
||||||
|
|
||||||
//------------- Silabs -------------//
|
//------------- Silabs -------------//
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_EFM32GG)
|
#elif TU_CHECK_MCU(OPT_MCU_EFM32GG)
|
||||||
@ -248,7 +245,7 @@
|
|||||||
#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
|
#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
|
||||||
#define TUP_USBIP_DWC2
|
#define TUP_USBIP_DWC2
|
||||||
#define TUP_DCD_ENDPOINT_MAX 8
|
#define TUP_DCD_ENDPOINT_MAX 8
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x01
|
#define TUP_RHPORT_HIGHSPEED 1
|
||||||
|
|
||||||
//------------- Broadcom -------------//
|
//------------- Broadcom -------------//
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_XMC4000)
|
#elif TU_CHECK_MCU(OPT_MCU_XMC4000)
|
||||||
@ -258,11 +255,11 @@
|
|||||||
//------------- BridgeTek -------------//
|
//------------- BridgeTek -------------//
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_FT90X)
|
#elif TU_CHECK_MCU(OPT_MCU_FT90X)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 8
|
#define TUP_DCD_ENDPOINT_MAX 8
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x01
|
#define TUP_RHPORT_HIGHSPEED 1
|
||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_FT93X)
|
#elif TU_CHECK_MCU(OPT_MCU_FT93X)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 16
|
#define TUP_DCD_ENDPOINT_MAX 16
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x01
|
#define TUP_RHPORT_HIGHSPEED 1
|
||||||
|
|
||||||
//------------ Allwinner -------------//
|
//------------ Allwinner -------------//
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_F1C100S)
|
#elif TU_CHECK_MCU(OPT_MCU_F1C100S)
|
||||||
@ -281,7 +278,7 @@
|
|||||||
|
|
||||||
// Default to fullspeed if not defined
|
// Default to fullspeed if not defined
|
||||||
#ifndef TUP_RHPORT_HIGHSPEED
|
#ifndef TUP_RHPORT_HIGHSPEED
|
||||||
#define TUP_RHPORT_HIGHSPEED 0x00
|
#define TUP_RHPORT_HIGHSPEED 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// fast function, normally mean placing function in SRAM
|
// fast function, normally mean placing function in SRAM
|
||||||
|
@ -428,7 +428,6 @@ bool tud_init (uint8_t rhport)
|
|||||||
dcd_init(rhport);
|
dcd_init(rhport);
|
||||||
dcd_int_enable(rhport);
|
dcd_int_enable(rhport);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1199,6 +1198,8 @@ void usbd_defer_func(osal_task_func_t func, void* param, bool in_isr)
|
|||||||
|
|
||||||
bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep)
|
bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep)
|
||||||
{
|
{
|
||||||
|
rhport = _usbd_rhport;
|
||||||
|
|
||||||
TU_ASSERT(tu_edpt_number(desc_ep->bEndpointAddress) < CFG_TUD_ENDPPOINT_MAX);
|
TU_ASSERT(tu_edpt_number(desc_ep->bEndpointAddress) < CFG_TUD_ENDPPOINT_MAX);
|
||||||
TU_ASSERT(tu_edpt_validate(desc_ep, (tusb_speed_t) _usbd_dev.speed));
|
TU_ASSERT(tu_edpt_validate(desc_ep, (tusb_speed_t) _usbd_dev.speed));
|
||||||
|
|
||||||
@ -1240,6 +1241,8 @@ bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr)
|
|||||||
|
|
||||||
bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||||
{
|
{
|
||||||
|
rhport = _usbd_rhport;
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||||
|
|
||||||
@ -1275,6 +1278,8 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
|||||||
// into the USB buffer!
|
// into the USB buffer!
|
||||||
bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||||
{
|
{
|
||||||
|
rhport = _usbd_rhport;
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||||
|
|
||||||
@ -1314,6 +1319,7 @@ bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr)
|
|||||||
|
|
||||||
void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
|
rhport = _usbd_rhport;
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||||
@ -1330,6 +1336,8 @@ void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
|||||||
|
|
||||||
void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
|
rhport = _usbd_rhport;
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||||
|
|
||||||
@ -1361,6 +1369,8 @@ bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)
|
|||||||
*/
|
*/
|
||||||
void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
|
rhport = _usbd_rhport;
|
||||||
|
|
||||||
TU_ASSERT(dcd_edpt_close, /**/);
|
TU_ASSERT(dcd_edpt_close, /**/);
|
||||||
TU_LOG2(" CLOSING Endpoint: 0x%02X\r\n", ep_addr);
|
TU_LOG2(" CLOSING Endpoint: 0x%02X\r\n", ep_addr);
|
||||||
|
|
||||||
@ -1377,6 +1387,8 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
|||||||
|
|
||||||
void usbd_sof_enable(uint8_t rhport, bool en)
|
void usbd_sof_enable(uint8_t rhport, bool en)
|
||||||
{
|
{
|
||||||
|
rhport = _usbd_rhport;
|
||||||
|
|
||||||
// TODO: Check needed if all drivers including the user sof_cb does not need an active SOF ISR any more.
|
// TODO: Check needed if all drivers including the user sof_cb does not need an active SOF ISR any more.
|
||||||
// Only if all drivers switched off SOF calls the SOF interrupt may be disabled
|
// Only if all drivers switched off SOF calls the SOF interrupt may be disabled
|
||||||
dcd_sof_enable(rhport, en);
|
dcd_sof_enable(rhport, en);
|
||||||
|
@ -62,6 +62,7 @@ void usbd_int_set(bool enabled);
|
|||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USBD Endpoint API
|
// USBD Endpoint API
|
||||||
|
// Note: rhport should be 0 since device stack only support 1 rhport for now
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Open an endpoint
|
// Open an endpoint
|
||||||
|
@ -195,25 +195,21 @@ typedef int make_iso_compilers_happy ;
|
|||||||
#define OPT_MODE_HIGH_SPEED 0x0400 ///< High Speed
|
#define OPT_MODE_HIGH_SPEED 0x0400 ///< High Speed
|
||||||
#define OPT_MODE_SPEED_MASK 0xff00
|
#define OPT_MODE_SPEED_MASK 0xff00
|
||||||
|
|
||||||
#ifndef CFG_TUSB_RHPORT0_MODE
|
|
||||||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CFG_TUSB_RHPORT1_MODE
|
|
||||||
#define CFG_TUSB_RHPORT1_MODE OPT_MODE_NONE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST ) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST )) || \
|
|
||||||
(((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE))
|
|
||||||
#error "TinyUSB currently does not support same modes on more than 1 roothub port"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------- Roothub as Device -------------//
|
//------------- Roothub as Device -------------//
|
||||||
|
|
||||||
#if (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE
|
//#ifndef CFG_TUSB_RHPORT0_MODE
|
||||||
|
// #define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
|
||||||
|
//#endif
|
||||||
|
//
|
||||||
|
//#ifndef CFG_TUSB_RHPORT1_MODE
|
||||||
|
// #define CFG_TUSB_RHPORT1_MODE OPT_MODE_NONE
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CFG_TUSB_RHPORT0_MODE) && ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE)
|
||||||
#define TUD_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE)
|
#define TUD_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE)
|
||||||
#define TUD_OPT_RHPORT 0
|
#define TUD_OPT_RHPORT 0
|
||||||
#elif (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE
|
#elif defined(CFG_TUSB_RHPORT1_MODE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE)
|
||||||
#define TUD_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE)
|
#define TUD_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE)
|
||||||
#define TUD_OPT_RHPORT 1
|
#define TUD_OPT_RHPORT 1
|
||||||
#else
|
#else
|
||||||
@ -222,21 +218,24 @@ typedef int make_iso_compilers_happy ;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUD_ENABLED
|
#ifndef CFG_TUD_ENABLED
|
||||||
#define CFG_TUD_ENABLED (TUD_RHPORT_MODE & OPT_MODE_DEVICE)
|
// fallback to use CFG_TUSB_RHPORTx_MODE
|
||||||
|
#define CFG_TUD_ENABLED (TUD_RHPORT_MODE & OPT_MODE_DEVICE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUD_ENABLED
|
#ifndef CFG_TUD_MAX_SPEED
|
||||||
#define TUD_OPT_HIGH_SPEED ((TUD_RHPORT_MODE & OPT_MODE_SPEED_MASK) ? (TUD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) : (TUP_RHPORT_HIGHSPEED & (1 << TUD_OPT_RHPORT)))
|
// fallback to use CFG_TUSB_RHPORTx_MODE
|
||||||
#else
|
#define CFG_TUD_MAX_SPEED (TUD_RHPORT_MODE & OPT_MODE_SPEED_MASK)
|
||||||
#define TUD_OPT_HIGH_SPEED 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// highspeed support indicator
|
||||||
|
#define TUD_OPT_HIGH_SPEED (CFG_TUD_MAX_SPEED ? CFG_TUD_MAX_SPEED : TUP_RHPORT_HIGHSPEED)
|
||||||
|
|
||||||
//------------- Roothub as Host -------------//
|
//------------- Roothub as Host -------------//
|
||||||
|
|
||||||
#if (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST
|
#if defined(CFG_TUSB_RHPORT0_MODE) && ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST)
|
||||||
#define TUH_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE)
|
#define TUH_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE)
|
||||||
#define TUH_OPT_RHPORT 0
|
#define TUH_OPT_RHPORT 0
|
||||||
#elif (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST
|
#elif defined(CFG_TUSB_RHPORT1_MODE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST)
|
||||||
#define TUH_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE)
|
#define TUH_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE)
|
||||||
#define TUH_OPT_RHPORT 1
|
#define TUH_OPT_RHPORT 1
|
||||||
#else
|
#else
|
||||||
@ -244,7 +243,10 @@ typedef int make_iso_compilers_happy ;
|
|||||||
#define TUH_OPT_RHPORT -1
|
#define TUH_OPT_RHPORT -1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CFG_TUH_ENABLED (TUH_RHPORT_MODE & OPT_MODE_HOST)
|
#ifndef CFG_TUH_ENABLED
|
||||||
|
// fallback to use CFG_TUSB_RHPORTx_MODE
|
||||||
|
#define CFG_TUH_ENABLED (TUH_RHPORT_MODE & OPT_MODE_HOST)
|
||||||
|
#endif
|
||||||
|
|
||||||
// For backward compatible
|
// For backward compatible
|
||||||
#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED
|
#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user