Explicit feedback explanation
mcginty opened this issue · 2 comments
Hi there! I'm trying to understand the feedback mechanism, and this code seems to have a number of different formulae in comments, and I'm not sure if these are just magic numbers you got to through experimentation or if they're from some constants about the hardware.
It seems like the current formula can be simplified as
given the code:
fb_value += audio_buf_writable_size_dev_from_nom * audio_buf_writable_size_dev_from_nom / 912673 * 128 * audio_buf_writable_size_dev_from_nom;
These are magic numbers. The way I did feedback was by monitoring the remaining capacity of the audio buffer array, and telling the host to send more/less data in future packets, to ensure no buffer overrun/underrun happen.
This is not the conventional way to do feedback. The standard way is to set up a timer that monitors the I2S output buffer, measuring the exact feedback value, as defined in USB Specification 5.10.4.2. But I was too lazy to set up and debug another piece of peripheral device, so I came up with this formula that mimicked the behavior.
Btw I guess the reason I didn't combine the multiplication into
Ahhh gotcha, that makes sense. Thanks for clarifying, I appreciate it. And thanks for releasing this project, it's been very helpful.