Skip to content

Commit 5920d15

Browse files
authored
Merge pull request #466 from adafruit/update-tinyusb-fix-esp32-build
update tinyusb to fix esp32 build with v3.0.7
2 parents a529a74 + 71e2c4a commit 5920d15

40 files changed

+1544
-1023
lines changed

src/class/audio/audio_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,8 +2071,8 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
20712071
// Avoid 64bit division
20722072
uint32_t nominal = ((fb_param.sample_freq / 100) << 16) / (frame_div / 100);
20732073
audio->feedback.compute.fifo_count.nom_value = nominal;
2074-
audio->feedback.compute.fifo_count.rate_const[0] = (audio->feedback.max_value - nominal) / fifo_lvl_thr;
2075-
audio->feedback.compute.fifo_count.rate_const[1] = (nominal - audio->feedback.min_value) / fifo_lvl_thr;
2074+
audio->feedback.compute.fifo_count.rate_const[0] = (uint16_t) ((audio->feedback.max_value - nominal) / fifo_lvl_thr);
2075+
audio->feedback.compute.fifo_count.rate_const[1] = (uint16_t) ((nominal - audio->feedback.min_value) / fifo_lvl_thr);
20762076
// On HS feedback is more sensitive since packet size can vary every MSOF, could cause instability
20772077
if(tud_speed_get() == TUSB_SPEED_HIGH) {
20782078
audio->feedback.compute.fifo_count.rate_const[0] /= 8;
@@ -2381,11 +2381,11 @@ static bool audiod_set_fb_params_freq(audiod_function_t* audio, uint32_t sample_
23812381
if ((mclk_freq % sample_freq) == 0 && tu_is_power_of_two(mclk_freq / sample_freq))
23822382
{
23832383
audio->feedback.compute_method = AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2;
2384-
audio->feedback.compute.power_of_2 = 16 - (audio->feedback.frame_shift - 1) - tu_log2(mclk_freq / sample_freq);
2384+
audio->feedback.compute.power_of_2 = (uint8_t) (16 - (audio->feedback.frame_shift - 1) - tu_log2(mclk_freq / sample_freq));
23852385
}
23862386
else if ( audio->feedback.compute_method == AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT)
23872387
{
2388-
audio->feedback.compute.float_const = (float)sample_freq / mclk_freq * (1UL << (16 - (audio->feedback.frame_shift - 1)));
2388+
audio->feedback.compute.float_const = (float)sample_freq / (float) mclk_freq * (1UL << (16 - (audio->feedback.frame_shift - 1)));
23892389
}
23902390
else
23912391
{

src/class/cdc/cdc_device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* This file is part of the TinyUSB stack.
2525
*/
2626

27-
#ifndef _TUSB_CDC_DEVICE_H_
28-
#define _TUSB_CDC_DEVICE_H_
27+
#ifndef TUSB_CDC_DEVICE_H_
28+
#define TUSB_CDC_DEVICE_H_
2929

3030
#include "cdc.h"
3131

src/class/cdc/cdc_host.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,14 @@ uint32_t tuh_cdc_write(uint8_t idx, void const* buffer, uint32_t bufsize) {
373373
cdch_interface_t* p_cdc = get_itf(idx);
374374
TU_VERIFY(p_cdc);
375375

376-
return tu_edpt_stream_write(&p_cdc->stream.tx, buffer, bufsize);
376+
return tu_edpt_stream_write(p_cdc->daddr, &p_cdc->stream.tx, buffer, bufsize);
377377
}
378378

379379
uint32_t tuh_cdc_write_flush(uint8_t idx) {
380380
cdch_interface_t* p_cdc = get_itf(idx);
381381
TU_VERIFY(p_cdc);
382382

383-
return tu_edpt_stream_write_xfer(&p_cdc->stream.tx);
383+
return tu_edpt_stream_write_xfer(p_cdc->daddr, &p_cdc->stream.tx);
384384
}
385385

386386
bool tuh_cdc_write_clear(uint8_t idx) {
@@ -394,7 +394,7 @@ uint32_t tuh_cdc_write_available(uint8_t idx) {
394394
cdch_interface_t* p_cdc = get_itf(idx);
395395
TU_VERIFY(p_cdc);
396396

397-
return tu_edpt_stream_write_available(&p_cdc->stream.tx);
397+
return tu_edpt_stream_write_available(p_cdc->daddr, &p_cdc->stream.tx);
398398
}
399399

400400
//--------------------------------------------------------------------+
@@ -405,7 +405,7 @@ uint32_t tuh_cdc_read (uint8_t idx, void* buffer, uint32_t bufsize) {
405405
cdch_interface_t* p_cdc = get_itf(idx);
406406
TU_VERIFY(p_cdc);
407407

408-
return tu_edpt_stream_read(&p_cdc->stream.rx, buffer, bufsize);
408+
return tu_edpt_stream_read(p_cdc->daddr, &p_cdc->stream.rx, buffer, bufsize);
409409
}
410410

411411
uint32_t tuh_cdc_read_available(uint8_t idx) {
@@ -427,7 +427,7 @@ bool tuh_cdc_read_clear (uint8_t idx) {
427427
TU_VERIFY(p_cdc);
428428

429429
bool ret = tu_edpt_stream_clear(&p_cdc->stream.rx);
430-
tu_edpt_stream_read_xfer(&p_cdc->stream.rx);
430+
tu_edpt_stream_read_xfer(p_cdc->daddr, &p_cdc->stream.rx);
431431
return ret;
432432
}
433433

@@ -709,10 +709,10 @@ bool cdch_xfer_cb(uint8_t daddr, uint8_t ep_addr, xfer_result_t event, uint32_t
709709
// invoke tx complete callback to possibly refill tx fifo
710710
if (tuh_cdc_tx_complete_cb) tuh_cdc_tx_complete_cb(idx);
711711

712-
if ( 0 == tu_edpt_stream_write_xfer(&p_cdc->stream.tx) ) {
712+
if ( 0 == tu_edpt_stream_write_xfer(daddr, &p_cdc->stream.tx) ) {
713713
// If there is no data left, a ZLP should be sent if:
714714
// - xferred_bytes is multiple of EP Packet size and not zero
715-
tu_edpt_stream_write_zlp_if_needed(&p_cdc->stream.tx, xferred_bytes);
715+
tu_edpt_stream_write_zlp_if_needed(daddr, &p_cdc->stream.tx, xferred_bytes);
716716
}
717717
} else if ( ep_addr == p_cdc->stream.rx.ep_addr ) {
718718
#if CFG_TUH_CDC_FTDI
@@ -730,7 +730,7 @@ bool cdch_xfer_cb(uint8_t daddr, uint8_t ep_addr, xfer_result_t event, uint32_t
730730
if (tuh_cdc_rx_cb) tuh_cdc_rx_cb(idx);
731731

732732
// prepare for next transfer if needed
733-
tu_edpt_stream_read_xfer(&p_cdc->stream.rx);
733+
tu_edpt_stream_read_xfer(daddr, &p_cdc->stream.rx);
734734
}else if ( ep_addr == p_cdc->ep_notif ) {
735735
// TODO handle notification endpoint
736736
}else {
@@ -751,9 +751,9 @@ static bool open_ep_stream_pair(cdch_interface_t* p_cdc, tusb_desc_endpoint_t co
751751
TU_ASSERT(tuh_edpt_open(p_cdc->daddr, desc_ep));
752752

753753
if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN) {
754-
tu_edpt_stream_open(&p_cdc->stream.rx, p_cdc->daddr, desc_ep);
754+
tu_edpt_stream_open(&p_cdc->stream.rx, desc_ep);
755755
} else {
756-
tu_edpt_stream_open(&p_cdc->stream.tx, p_cdc->daddr, desc_ep);
756+
tu_edpt_stream_open(&p_cdc->stream.tx, desc_ep);
757757
}
758758

759759
desc_ep = (tusb_desc_endpoint_t const*) tu_desc_next(desc_ep);
@@ -795,7 +795,7 @@ static void set_config_complete(cdch_interface_t * p_cdc, uint8_t idx, uint8_t i
795795
if (tuh_cdc_mount_cb) tuh_cdc_mount_cb(idx);
796796

797797
// Prepare for incoming data
798-
tu_edpt_stream_read_xfer(&p_cdc->stream.rx);
798+
tu_edpt_stream_read_xfer(p_cdc->daddr, &p_cdc->stream.rx);
799799

800800
// notify usbh that driver enumeration is complete
801801
usbh_driver_set_config_complete(p_cdc->daddr, itf_num);

0 commit comments

Comments
 (0)