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:
@@ -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)
|
||||
{
|
||||
// skip if previous transfer not complete
|
||||
TU_VERIFY(!usbd_edpt_busy(TUD_OPT_RHPORT, ep));
|
||||
uint8_t const rhport = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
uint8_t const rhport = TUD_OPT_RHPORT;
|
||||
uint8_t const rhport = 0;
|
||||
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.
|
||||
@@ -189,7 +189,7 @@ uint32_t tud_cdc_n_write_flush (uint8_t itf)
|
||||
// No data to send
|
||||
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
|
||||
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)
|
||||
{
|
||||
uint8_t const rhport = 0;
|
||||
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)
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -172,7 +173,7 @@ bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id,
|
||||
//--------------------------------------------------------------------+
|
||||
void hidd_init(void)
|
||||
{
|
||||
hidd_reset(TUD_OPT_RHPORT);
|
||||
hidd_reset(0);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
uint8_t const rhport = TUD_OPT_RHPORT;
|
||||
uint8_t const rhport = 0;
|
||||
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.
|
||||
@@ -219,7 +219,7 @@ static uint32_t write_flush(midid_interface_t* midi)
|
||||
// No data to send
|
||||
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
|
||||
TU_VERIFY( usbd_edpt_claim(rhport, midi->ep_in), 0 );
|
||||
|
||||
@@ -108,20 +108,22 @@ static bool can_xmit;
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
uint8_t const rhport = 0;
|
||||
|
||||
// skip if previous report not yet acknowledged by host
|
||||
if ( usbd_edpt_busy(TUD_OPT_RHPORT, _netd_itf.ep_notif) ) return;
|
||||
usbd_edpt_xfer(TUD_OPT_RHPORT, _netd_itf.ep_notif, buf, len);
|
||||
if ( usbd_edpt_busy(rhport, _netd_itf.ep_notif) ) return;
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
// Swap to the other NTB and clear it out
|
||||
@@ -229,7 +229,7 @@ void tud_network_recv_renew(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -316,14 +316,15 @@ uint16_t netd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint1
|
||||
|
||||
static void ncm_report(void)
|
||||
{
|
||||
uint8_t const rhport = 0;
|
||||
if (ncm_interface.report_state == REPORT_SPEED) {
|
||||
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_pending = true;
|
||||
} else if (ncm_interface.report_state == REPORT_CONNECTED) {
|
||||
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_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)
|
||||
{
|
||||
uint8_t const rhport = 0;
|
||||
|
||||
// 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.
|
||||
uint16_t max_read = tu_fifo_remaining(&p_itf->rx_ff);
|
||||
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)
|
||||
{
|
||||
uint8_t const rhport = 0;
|
||||
|
||||
// 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);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user