Skip to content

audio: manage ISO transfer in ISR #3150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

HiFiPhile
Copy link
Collaborator

@HiFiPhile HiFiPhile commented Jun 14, 2025

Describe the PR
2nd part of #3133, ISO transfer management is moved into USB ISR to avoid timing conflict with other classes.

Transfer callbacks become tud_audio_tx_done_isr/tud_audio_rx_done_isr and not recommended to use, data should be read/write from audio process callback (I2S IRQ) instead.

Meanwhile logging for ISR transfer is not easy to implement:

Tested on NUCLEO-H7S3L8 and NUCLEO-C071RB with all audio examples.

Demo

  1. Take audio_test_freertos example, add some processing delay to volume change request
diff --git a/examples/device/audio_test_freertos/src/main.c b/examples/device/audio_test_freertos/src/main.c
index 0a6cdfd4f..67d56b640 100644
--- a/examples/device/audio_test_freertos/src/main.c
+++ b/examples/device/audio_test_freertos/src/main.c
@@ -299,6 +299,7 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *p
         TU_VERIFY(p_request->wLength == sizeof(audio_control_cur_2_t));

         volume[channelNum] = (uint16_t) ((audio_control_cur_2_t *) pBuff)->bCur;
+        vTaskDelay(10); // Simulate some processing delay
         TU_LOG1("    Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
         return true;
  1. Adjust volume on PC while recording with plot_audio_samples.py script (increase recording duration if your hand is slow ;))
  2. The recorded data should be distortion-free
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant