correct cdc usbh_driver_set_config_complete()

This commit is contained in:
hathach 2022-12-16 23:54:21 +07:00
parent 4811b3463f
commit fc9321ce26
2 changed files with 23 additions and 12 deletions

View File

@ -36,13 +36,24 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF // MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#if 0
typedef struct {
tu_fifo_t ff;
OSAL_MUTEX_DEF(ff_mutex);
}tu_edpt_stream_t;
//typedef struct { uint32_t tud_cdc_read_available (void);
// tu_fifo_t fifo; uint32_t tud_cdc_read (void *buffer, uint32_t bufsize);
// OSAL_MUTEX_DEF(ff_mutex); void tud_cdc_read_flush (void);
// bool tud_cdc_peek (uint8_t *ui8);
//
//}usbh_edpt_stream_t; uint32_t tud_cdc_write (void const *buffer, uint32_t bufsize);
uint32_t tud_cdc_write_flush (void);
uint32_t tud_cdc_write_available (void);
//--------------------------------------------------------
tu_edpt_stream_write()
#endif
typedef struct { typedef struct {
uint8_t daddr; uint8_t daddr;
@ -65,10 +76,8 @@ typedef struct {
uint8_t rx_ff_buf[CFG_TUH_CDC_RX_BUFSIZE]; uint8_t rx_ff_buf[CFG_TUH_CDC_RX_BUFSIZE];
uint8_t tx_ff_buf[CFG_TUH_CDC_TX_BUFSIZE]; uint8_t tx_ff_buf[CFG_TUH_CDC_TX_BUFSIZE];
#if CFG_FIFO_MUTEX OSAL_MUTEX_DEF(rx_ff_mutex);
osal_mutex_def_t rx_ff_mutex; OSAL_MUTEX_DEF(tx_ff_mutex);
osal_mutex_def_t tx_ff_mutex;
#endif
// Endpoint Transfer buffer // Endpoint Transfer buffer
CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUH_CDC_RX_EPSIZE]; CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUH_CDC_RX_EPSIZE];
@ -311,7 +320,8 @@ bool cdch_set_config(uint8_t dev_addr, uint8_t itf_num)
if (tuh_cdc_mount_cb) tuh_cdc_mount_cb(dev_addr); if (tuh_cdc_mount_cb) tuh_cdc_mount_cb(dev_addr);
// notify usbh that driver enumeration is complete // notify usbh that driver enumeration is complete
usbh_driver_set_config_complete(dev_addr, itf_num); // itf_num+1 to account for data interface as well
usbh_driver_set_config_complete(dev_addr, itf_num+1);
return true; return true;
} }

View File

@ -1570,7 +1570,8 @@ void usbh_driver_set_config_complete(uint8_t dev_addr, uint8_t itf_num)
for(itf_num++; itf_num < CFG_TUH_INTERFACE_MAX; itf_num++) for(itf_num++; itf_num < CFG_TUH_INTERFACE_MAX; itf_num++)
{ {
// continue with next valid interface // continue with next valid interface
// TODO skip IAD binding interface such as CDCs // IAD binding interface such as CDCs should return itf_num + 1 when complete
// with usbh_driver_set_config_complete()
uint8_t const drv_id = dev->itf2drv[itf_num]; uint8_t const drv_id = dev->itf2drv[itf_num];
if (drv_id != DRVID_INVALID) if (drv_id != DRVID_INVALID)
{ {