From 20830eee121a1e2080bb1b5e3dbfd5ad70185a6e Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Tue, 15 Oct 2024 13:47:58 +0200 Subject: [PATCH] RP2040 Compile Errors --- .gitignore | 2 ++ examples/device/CMakeLists.txt | 1 + examples/device/uac2_speaker_fb/CMakeLists.txt | 1 + examples/device/uac2_speaker_fb/src/main.c | 4 ++-- src/class/audio/audio_device.c | 8 ++++---- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f2150a26fb..309d7466af 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ __pycache__ cmake-build-* sdkconfig .PVS-Studio +.vscode/ +build/ diff --git a/examples/device/CMakeLists.txt b/examples/device/CMakeLists.txt index 6384407951..26a808a217 100644 --- a/examples/device/CMakeLists.txt +++ b/examples/device/CMakeLists.txt @@ -28,6 +28,7 @@ family_add_subdirectory(midi_test) family_add_subdirectory(msc_dual_lun) family_add_subdirectory(net_lwip_webserver) family_add_subdirectory(uac2_headset) +family_add_subdirectory(uac2_speaker_fb) family_add_subdirectory(usbtmc) family_add_subdirectory(video_capture) family_add_subdirectory(video_capture_2ch) diff --git a/examples/device/uac2_speaker_fb/CMakeLists.txt b/examples/device/uac2_speaker_fb/CMakeLists.txt index e92a571488..f40ca87166 100644 --- a/examples/device/uac2_speaker_fb/CMakeLists.txt +++ b/examples/device/uac2_speaker_fb/CMakeLists.txt @@ -21,6 +21,7 @@ add_executable(${PROJECT}) target_sources(${PROJECT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/quirk_os_guessing.c ) # Example include diff --git a/examples/device/uac2_speaker_fb/src/main.c b/examples/device/uac2_speaker_fb/src/main.c index 53bbec9b60..ea5a2941d5 100644 --- a/examples/device/uac2_speaker_fb/src/main.c +++ b/examples/device/uac2_speaker_fb/src/main.c @@ -418,7 +418,7 @@ void audio_task(void) if ( start_ms == curr_ms ) return; // not enough time start_ms = curr_ms; - uint16_t length = current_sample_rate/1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX; + uint16_t length = (uint16_t) (current_sample_rate/1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX); if (current_sample_rate == 44100 && (curr_ms % 10 == 0)) { @@ -469,7 +469,7 @@ void audio_debug_task(void) debug_info.alt_settings = current_alt_settings; debug_info.fifo_size = CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ; debug_info.fifo_count = fifo_count; - debug_info.fifo_count_avg = fifo_count_avg >> 16; + debug_info.fifo_count_avg = (uint16_t) (fifo_count_avg >> 16); for (int i = 0; i < CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX + 1; i++) { debug_info.mute[i] = mute[i]; diff --git a/src/class/audio/audio_device.c b/src/class/audio/audio_device.c index 8c86de4337..136f658df3 100644 --- a/src/class/audio/audio_device.c +++ b/src/class/audio/audio_device.c @@ -2066,8 +2066,8 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const * // Avoid 64bit division uint32_t nominal = ((fb_param.sample_freq / 100) << 16) / (frame_div / 100); audio->feedback.compute.fifo_count.nom_value = nominal; - audio->feedback.compute.fifo_count.rate_const[0] = (audio->feedback.max_value - nominal) / fifo_lvl_thr; - audio->feedback.compute.fifo_count.rate_const[1] = (nominal - audio->feedback.min_value) / fifo_lvl_thr; + audio->feedback.compute.fifo_count.rate_const[0] = (uint16_t) ((audio->feedback.max_value - nominal) / fifo_lvl_thr); + audio->feedback.compute.fifo_count.rate_const[1] = (uint16_t) ((nominal - audio->feedback.min_value) / fifo_lvl_thr); // On HS feedback is more sensitive since packet size can vary every MSOF, could cause instability if(tud_speed_get() == TUSB_SPEED_HIGH) { audio->feedback.compute.fifo_count.rate_const[0] /= 8; @@ -2376,11 +2376,11 @@ static bool audiod_set_fb_params_freq(audiod_function_t* audio, uint32_t sample_ if ((mclk_freq % sample_freq) == 0 && tu_is_power_of_two(mclk_freq / sample_freq)) { audio->feedback.compute_method = AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2; - audio->feedback.compute.power_of_2 = 16 - (audio->feedback.frame_shift - 1) - tu_log2(mclk_freq / sample_freq); + audio->feedback.compute.power_of_2 = (uint8_t) (16 - (audio->feedback.frame_shift - 1) - tu_log2(mclk_freq / sample_freq)); } else if ( audio->feedback.compute_method == AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT) { - audio->feedback.compute.float_const = (float)sample_freq / mclk_freq * (1UL << (16 - (audio->feedback.frame_shift - 1))); + audio->feedback.compute.float_const = (float)sample_freq / (float) mclk_freq * (1UL << (16 - (audio->feedback.frame_shift - 1))); } else {