106
106
#define USE_LINEAR_BUFFER 1
107
107
#endif
108
108
109
+ // Temporarily put the check here for stm32_fsdev
110
+ #if CFG_TUSB_MCU == OPT_MCU_STM32F0 || \
111
+ CFG_TUSB_MCU == OPT_MCU_STM32F3 || \
112
+ CFG_TUSB_MCU == OPT_MCU_STM32L0 || \
113
+ CFG_TUSB_MCU == OPT_MCU_STM32L1 || \
114
+ CFG_TUSB_MCU == OPT_MCU_STM32G4 || \
115
+ CFG_TUSB_MCU == OPT_MCU_STM32WB
116
+ #define USE_ISO_EP_ALLOCATION 1
117
+ #else
118
+ #define USE_ISO_EP_ALLOCATION 0
119
+ #endif
120
+
109
121
// Declaration of buffers
110
122
111
123
// Check for maximum supported numbers
@@ -1467,6 +1479,104 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1467
1479
#endif
1468
1480
}
1469
1481
1482
+ #if USE_ISO_EP_ALLOCATION
1483
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
1484
+ uint8_t ep_in = 0 ;
1485
+ uint16_t ep_in_size = 0 ;
1486
+ #endif
1487
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1488
+ uint8_t ep_out = 0 ;
1489
+ uint16_t ep_out_size = 0 ;
1490
+ #endif
1491
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1492
+ uint8_t ep_fb = 0 ;
1493
+ #endif
1494
+
1495
+ // First find EP addr
1496
+ uint8_t const * p_desc = _audiod_fct [i ].p_desc ;
1497
+ uint8_t const * p_desc_end = p_desc + _audiod_fct [i ].desc_length - TUD_AUDIO_DESC_IAD_LEN ;
1498
+ while (p_desc < p_desc_end )
1499
+ {
1500
+ if (tu_desc_type (p_desc ) == TUSB_DESC_ENDPOINT )
1501
+ {
1502
+ tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const * ) p_desc ;
1503
+ if (desc_ep -> bmAttributes .xfer == TUSB_XFER_ISOCHRONOUS )
1504
+ {
1505
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1506
+ // Explicit feedback EP
1507
+ if (desc_ep -> bmAttributes .usage == 1 )
1508
+ {
1509
+ ep_fb = desc_ep -> bEndpointAddress ;
1510
+ }
1511
+ #endif
1512
+ // Data EP
1513
+ if (desc_ep -> bmAttributes .usage == 0 )
1514
+ {
1515
+ if (tu_edpt_dir (desc_ep -> bEndpointAddress ) == TUSB_DIR_IN )
1516
+ {
1517
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
1518
+ ep_in = desc_ep -> bEndpointAddress ;
1519
+ #endif
1520
+ } else
1521
+ {
1522
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1523
+ ep_out = desc_ep -> bEndpointAddress ;
1524
+ #endif
1525
+ }
1526
+ }
1527
+
1528
+ }
1529
+ }
1530
+ p_desc = tu_desc_next (p_desc );
1531
+ }
1532
+
1533
+ // Then find EP max size
1534
+ p_desc = _audiod_fct [i ].p_desc ;
1535
+ while (p_desc < p_desc_end )
1536
+ {
1537
+ if (tu_desc_type (p_desc ) == TUSB_DESC_ENDPOINT )
1538
+ {
1539
+ tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const * ) p_desc ;
1540
+ if (desc_ep -> bmAttributes .xfer == TUSB_XFER_ISOCHRONOUS )
1541
+ {
1542
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
1543
+ if (desc_ep -> bEndpointAddress == ep_in )
1544
+ {
1545
+ ep_in_size = TU_MAX (tu_edpt_packet_size (desc_ep ), ep_in_size );
1546
+ }
1547
+ #endif
1548
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1549
+ if (desc_ep -> bEndpointAddress == ep_out )
1550
+ {
1551
+ ep_out_size = TU_MAX (tu_edpt_packet_size (desc_ep ), ep_out_size );
1552
+ }
1553
+ #endif
1554
+ }
1555
+ }
1556
+ p_desc = tu_desc_next (p_desc );
1557
+ }
1558
+
1559
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
1560
+ if (ep_in )
1561
+ {
1562
+ usbd_edpt_iso_alloc (rhport , ep_in , ep_in_size );
1563
+ }
1564
+ #endif
1565
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1566
+ if (ep_out )
1567
+ {
1568
+ usbd_edpt_iso_alloc (rhport , ep_out , ep_out_size );
1569
+ }
1570
+ #endif
1571
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1572
+ if (ep_fb )
1573
+ {
1574
+ usbd_edpt_iso_alloc (rhport , ep_fb , 4 );
1575
+ }
1576
+ #endif
1577
+
1578
+ #endif
1579
+
1470
1580
break ;
1471
1581
}
1472
1582
}
@@ -1528,8 +1638,9 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1528
1638
if (audio -> ep_in_as_intf_num == itf )
1529
1639
{
1530
1640
audio -> ep_in_as_intf_num = 0 ;
1641
+ #if !USE_ISO_EP_ALLOCATION
1531
1642
usbd_edpt_close (rhport , audio -> ep_in );
1532
-
1643
+ #endif
1533
1644
// Clear FIFOs, since data is no longer valid
1534
1645
#if !CFG_TUD_AUDIO_ENABLE_ENCODING
1535
1646
tu_fifo_clear (& audio -> ep_in_ff );
@@ -1552,8 +1663,9 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1552
1663
if (audio -> ep_out_as_intf_num == itf )
1553
1664
{
1554
1665
audio -> ep_out_as_intf_num = 0 ;
1666
+ #if !USE_ISO_EP_ALLOCATION
1555
1667
usbd_edpt_close (rhport , audio -> ep_out );
1556
-
1668
+ #endif
1557
1669
// Clear FIFOs, since data is no longer valid
1558
1670
#if !CFG_TUD_AUDIO_ENABLE_DECODING
1559
1671
tu_fifo_clear (& audio -> ep_out_ff );
@@ -1571,7 +1683,9 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1571
1683
1572
1684
// Close corresponding feedback EP
1573
1685
#if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1686
+ #if !USE_ISO_EP_ALLOCATION
1574
1687
usbd_edpt_close (rhport , audio -> ep_fb );
1688
+ #endif
1575
1689
audio -> ep_fb = 0 ;
1576
1690
tu_memclr (& audio -> feedback , sizeof (audio -> feedback ));
1577
1691
#endif
@@ -1601,8 +1715,11 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1601
1715
if (tu_desc_type (p_desc ) == TUSB_DESC_ENDPOINT )
1602
1716
{
1603
1717
tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const * ) p_desc ;
1718
+ #if USE_ISO_EP_ALLOCATION
1719
+ TU_ASSERT (usbd_edpt_iso_activate (rhport , desc_ep ));
1720
+ #else
1604
1721
TU_ASSERT (usbd_edpt_open (rhport , desc_ep ));
1605
-
1722
+ #endif
1606
1723
uint8_t const ep_addr = desc_ep -> bEndpointAddress ;
1607
1724
1608
1725
//TODO: We need to set EP non busy since this is not taken care of right now in ep_close() - THIS IS A WORKAROUND!
0 commit comments