update ep_buffer.xc to support 1024 mclk

This commit is contained in:
Steven Dan
2026-05-22 12:52:23 +08:00
parent 3445b028e9
commit d1c16909e8

View File

@@ -737,8 +737,15 @@ void XUA_Buffer_Ep(
if(usb_speed != XUD_SPEED_HS)
feedbackMul = 8ULL; /* TODO Use 4 instead of 8 to avoid windows LSB issues? */
/* Number of MCLK ticks in this SOF period (E.g = 125 * 24.576 = 3072) */
int count = (int) ((short)(u_tmp - lastClock));
/* Number of MCLK ticks in this SOF period (E.g = 125 * 24.576 = 3072)
* 改动原因:原 (short) 截断只能处理 MCLK 计数 < 32768 的情况。
* UAC1 使用 FS USBSOF 周期 1ms1024x MCLK49.152MHz)时
* 每个 SOF 产生 49152 ticks > 32767(short) 溢出为 -16384负数
* 导致 feedback 计算错误,录音 IN endpoint 缓冲区管理失败,录音卡住。
* 改为 (unsigned short) 后49152 = 0xC000truncate 后仍为 49152
* 同时保留对 16-bit 端口计时器回绕wraparound的正确处理。
* UAC2 HS SOF125µs下最大 6144 ticks < 32768两者等价无副作用。 */
int count = (int) ((unsigned short)(u_tmp - lastClock));
unsigned long long full_result = count * feedbackMul * sampleFreq;