update modes

This commit is contained in:
Steven Dan
2026-05-27 14:47:03 +08:00
parent c47224eca0
commit fab8aabc84
6 changed files with 55 additions and 58 deletions

View File

@@ -377,7 +377,10 @@ void XUA_Buffer_Ep(
unsigned hid_ready_flag = 0U;
unsigned hid_ready_id = 1U;
/* 改动原因:记录最近一次通过 HID IN 发出的 Report ID主机读走 IN 包后只清除该 ID 的 change pending。
* 原先 hid_ready_id 固定为 1但上电首包是 Button Report(ID=2),主机读走后误清除了 ID=1 的 pending
* 导致 DFU/EQ 等通过 hidSetChangePending(0x1) 触发的 64 字节主动上报永远发不出去。 */
unsigned hid_last_in_report_id = HID_BUTTON_REPORT_ID;
XUD_SetReady_In(ep_hid, g_hidData, HID_BUTTON_REPORT_BYTES); // DFU_CONTROL_USB_HID related
#endif
@@ -989,9 +992,9 @@ void XUA_Buffer_Ep(
unsigned reportTime;
timer tmr;
tmr :> reportTime;
hidCaptureReportTime(hid_ready_id, reportTime);
hidCalcNextReportTime(hid_ready_id);
hidClearChangePending(hid_ready_id);
hidCaptureReportTime(hid_last_in_report_id, reportTime);
hidCalcNextReportTime(hid_last_in_report_id);
hidClearChangePending(hid_last_in_report_id);
break;
#endif
@@ -1244,11 +1247,13 @@ void XUA_Buffer_Ep(
{
// UserReadHIDButtons(&g_hidData[1]);
btn_start_time = now;
hid_last_in_report_id = HID_BUTTON_REPORT_ID;
XUD_SetReady_In(ep_hid, g_hidData, HID_BUTTON_REPORT_BYTES);
}
if (timeafter(now, btn_start_time + 2000000))
{
g_hidData[1] = 0;
hid_last_in_report_id = HID_BUTTON_REPORT_ID;
XUD_SetReady_In(ep_hid, g_hidData, HID_BUTTON_REPORT_BYTES);
hidClearChangePending(id);
btn_start_time = 0;
@@ -1259,6 +1264,7 @@ void XUA_Buffer_Ep(
unsafe {
user_read_hidpass(&g_hidPassData[1]);
}
hid_last_in_report_id = HID_PASS_REPORT_ID;
XUD_SetReady_In(ep_hid, g_hidPassData, HID_PASS_REPORT_BYTES);
hidClearChangePending(id);
}

View File

@@ -80,6 +80,13 @@ XUD_Result_t HidInterfaceClassRequests(
case HID_SET_REPORT:
result = XUD_GetBuffer(c_ep0_out, (buffer, unsigned char[]), datalength);
if(result == XUD_RES_OKAY) {
if (buffer[1] == 0x77 && ((buffer[2] >= 0x70) || (buffer[2] == 0x5b)))
{
process_send_params(&buffer[1], datalength - 1);
}
else
{
#if 0// USE_EX3D == 1
if(datalength > 0) {
unsafe
@@ -91,11 +98,6 @@ XUD_Result_t HidInterfaceClassRequests(
}
}
#endif
if (buffer[1] == 0x77 && ((buffer[2] >= 0x70) || (buffer[2] == 0x5b)))
{
process_send_params(&buffer[1], datalength - 1);
}
result = XUD_DoSetRequestStatus(c_ep0_in);

View File

@@ -172,7 +172,7 @@ on tile[0]: out port p_led_tile0 = PORT_LED_D10_8_11_9; // 8D bit7-4 = D10/D8/D
// TX1 Button timing thresholds (in 50ms ticks)
#define TX1_SHORT_PRESS_TICKS 1 // 50ms minimum press
#define TX1_LONG_PRESS_TICKS 20 // 1s = 20 * 50ms
/* 改动原因:TX1_LONG_PRESS_TICKS 已在文件顶部以 10ns 绝对时间定义(100000000ull);此处删除重复的 tick 计数版本 */
#define TX1_FACTORY_RESET_TICKS 212 // 10.6s = 212 * 50ms
// TX1 LED bit masks for tile[0] (XS1_PORT_8D bits 7-4)
@@ -782,11 +782,16 @@ unsigned char load_value(unsigned char * unsafe path);
/* 改动原因MIC 静音与 golden/phaten 一致——g_mute_switch 驱动定时器里 effective_adc_vol=0
* 并立即写 NAU88 ADC 寄存器old_adc_vol 与定时器分支保持同步避免重复 I2C。 */
/* 改动原因:前置声明,保证 tx1_sync_game_mode_state 内可直接调用xC 要求使用前有定义或原型) */
static void tx1_send_game_mode_to_tile1(chanend cc_mic_level, unsigned mode);
/**
* 改动原因:与 jok on_game_short_press 一致——更新 g_3d_fps、g_tx1_azimuth_mode
* 供 tile1 ex3d_task 轮询下发 EX3Dpersist=1 时写入 LFSGAME 键/需记忆时)。
*/
static void tx1_sync_game_mode_state(unsigned mode, unsigned persist,
chanend cc_mic_level,
client interface tx1_led_if led_if)
{
unsigned azimuth = TX1_AZIMUTH_MODE_FPS;
@@ -814,6 +819,7 @@ static void tx1_sync_game_mode_state(unsigned mode, unsigned persist,
SET_SHARED_GLOBAL(g_3d_fps, mode);
SET_SHARED_GLOBAL(g_tx1_azimuth_mode, azimuth);
SET_SHARED_GLOBAL(g_tx1_ex3d_resync_req, 1);
tx1_send_game_mode_to_tile1(cc_mic_level, mode);
/* 改动原因:切换 GAME 模式时清方位灯效衰减缓存,与 jok audio_azimuth_set_mode 一致 */
tx1_azimuth_clear_all_decay();
if (persist) {
@@ -916,12 +922,23 @@ static void tx1_apply_mic_mute_hw(unsigned mic_muted, unsigned &old_adc_vol,
old_adc_vol = adc_vol;
}
}
static void tx1_send_game_mode_to_tile1(chanend cc_mic_level, unsigned mode)
{
if (mode >= TX1_GAME_MODE_COUNT) {
mode = GAME_MODE_FPS20;
}
/* 改动原因:对齐 golden_6ch 通路AudioHwRemote2 通过 cc_mic_level 下发 0xFC + mode 给 tile1。 */
cc_mic_level <: 0xFC;
cc_mic_level <: mode;
debug_printf("cc_mic_level send game_mode=%u\n", mode);
}
/* 改动原因c_dfu 仅接收 FIRMWARE_UPGRADE_START在此线程执行 handle_firmware_upgrade_start。
* 移除未使用的 chanend c_erase原占位参数无任何 select/通信,会导致 main 侧被迫接 dummy 通道且与当前拓扑无关。 */
#if HID_DFU_EN
void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, streaming chanend c_dfu, client interface tx1_led_if led_if)
void AudioHwRemote2(streaming chanend c, chanend cc_mic_level, client interface i2c_master_if i2c, streaming chanend c_dfu, client interface tx1_led_if led_if)
#else
void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, client interface tx1_led_if led_if)
void AudioHwRemote2(streaming chanend c, chanend cc_mic_level, client interface i2c_master_if i2c, client interface tx1_led_if led_if)
#endif
{
unsigned cmd;
@@ -932,7 +949,6 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli
timer tmr, se_tmr, eq_mode_timer, eq_sync_timer, led_fx_tmr;
unsigned led_fx_time = 0;
unsigned eq_sync_time = 0;
unsigned old_format = 14;
unsigned unmute_dac_state;
unsigned old_dac_vol = 0;
unsigned old_adc_vol = 0;
@@ -1052,7 +1068,7 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli
{
unsigned char saved_gm = tx1_load_game_mode();
game_mode = (tx1_game_mode_t)saved_gm;
tx1_sync_game_mode_state((unsigned)game_mode, 0, led_if);
tx1_sync_game_mode_state((unsigned)game_mode, 0, cc_mic_level, led_if);
gpio_leds_dirty = 1;
debug_printf("TX1: Loaded game_mode from flash: %u\n", (unsigned)game_mode);
}
@@ -1080,8 +1096,6 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli
debug_printf("TX1: Loaded dac_hid=%u mic_hid=%u\n", (unsigned)saved_dac, (unsigned)saved_mic);
}
/* 改动原因:开机确保 tile1 按 Flash 恢复的 g_3d_fps 应用 EX3D */
SET_SHARED_GLOBAL(g_tx1_ex3d_resync_req, 1);
while(1)
{
select
@@ -1805,7 +1819,7 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli
/* 改动原因:三档循环 FPS20→FPS71→3A→FPS20只改 g_3d_fps/EX3D不 reboot */
game_mode = (tx1_game_mode_t)(((unsigned)game_mode + 1) % TX1_GAME_MODE_COUNT);
gpio_leds_dirty = 1;
tx1_sync_game_mode_state((unsigned)game_mode, 1, led_if);
tx1_sync_game_mode_state((unsigned)game_mode, 1, cc_mic_level, led_if);
debug_printf("TX1: GAME short press - game_mode=%d saved\n", game_mode);
}
}
@@ -2090,7 +2104,7 @@ extern void SetKeyFlag(unsigned x);
/* 改动原因:与 AudioHwRemote2 一致——HID_DFU_EN=0 时不声明 c_dfu避免 main 必须挂接无发送端的 streaming chan。 */
#if HID_DFU_EN
void AudioHwRemote(streaming chanend c, streaming chanend c_dfu, client interface tx1_led_if led_if)
void AudioHwRemote(streaming chanend c, chanend cc_mic_level, streaming chanend c_dfu, client interface tx1_led_if led_if)
{
i2c_master_if i2c[1];
@@ -2098,11 +2112,11 @@ void AudioHwRemote(streaming chanend c, streaming chanend c_dfu, client interfac
{
/* 改动原因:与 jok xk_audio_316_mc_ab 一致 100kHz300kHz 可能导致 HTR3236 长包异常 */
i2c_master(i2c, 1, p_scl, p_sda, 100);
AudioHwRemote2(c, i2c[0], c_dfu, led_if);
AudioHwRemote2(c, cc_mic_level, i2c[0], c_dfu, led_if);
}
}
#else
void AudioHwRemote(streaming chanend c, client interface tx1_led_if led_if)
void AudioHwRemote(streaming chanend c, chanend cc_mic_level, client interface tx1_led_if led_if)
{
i2c_master_if i2c[1];
@@ -2110,7 +2124,7 @@ void AudioHwRemote(streaming chanend c, client interface tx1_led_if led_if)
{
/* 改动原因:与 jok xk_audio_316_mc_ab 一致 100kHz */
i2c_master(i2c, 1, p_scl, p_sda, 100);
AudioHwRemote2(c, i2c[0], led_if);
AudioHwRemote2(c, cc_mic_level, i2c[0], led_if);
}
}
#endif

View File

@@ -67,14 +67,15 @@ void send_firmware_upgrade_response(uint8_t cmd, uint8_t *response_data, uint16_
g_hid_pass_data[0] = 0x77; // 同步头
g_hid_pass_data[1] = cmd; // 命令码
// 复制响应数据
// 改动原因copy_len 需在填充循环中复用,避免 data_len>61 时未清零尾部
uint16_t copy_len = 0;
if (response_data != NULL && data_len > 0) {
uint16_t copy_len = (data_len < 61) ? data_len : 61;
copy_len = (data_len < 61) ? data_len : 61;
memcpy(&g_hid_pass_data[2], response_data, copy_len);
}
// 其余字节填充为0
for (int i = 2 + data_len; i < 63; i++) {
for (int i = 2 + copy_len; i < 63; i++) {
g_hid_pass_data[i] = 0x00;
}

View File

@@ -97,7 +97,6 @@ static unsigned g_tx1_last_ex3d_game_applied = 0xFFFFFFFFu;
extern unsigned g_3d_fps;
extern unsigned g_request_game_mode;
extern unsigned g_tx1_azimuth_mode;
extern unsigned g_tx1_ex3d_resync_req;
/**
* 改动原因g_3d_fps 三档(0=FPS20,1=FPS71,2=3A),已去掉 BYPASS/IR_OFF映射 EX3D 声场。
@@ -154,28 +153,6 @@ static void tx1_apply_ex3d_for_game_mode(unsigned game_mode)
}
}
/**
* 改动原因hid_button_task 已注释,原 event_polling 不再监视 g_3d_on_off_t1
* 在 ex3d_task 主循环入口轮询 g_3d_fps / HID g_request_game_mode 并下发 EX3D。
*/
static void tx1_poll_ex3d_game_mode(void)
{
unsigned gm;
unsigned resync;
GET_SHARED_GLOBAL(resync, g_tx1_ex3d_resync_req);
if (resync) {
SET_SHARED_GLOBAL(g_tx1_ex3d_resync_req, 0);
g_tx1_last_ex3d_game_applied = 0xFFFFFFFFu;
}
GET_SHARED_GLOBAL(gm, g_3d_fps);
if (gm != g_tx1_last_ex3d_game_applied) {
tx1_apply_ex3d_for_game_mode(gm);
g_tx1_last_ex3d_game_applied = gm;
}
}
#endif /* USE_EX3D == 1 */
#else
@@ -1344,9 +1321,6 @@ void ex3d_task(chanend_t c_ex3d_to_ubm){
#endif
while (1) {
#if USE_EX3D == 1
tx1_poll_ex3d_game_mode();
#endif
OnProcessing(c_ex3d_to_ubm, uc_dsp_to_ex3d);
}
}

View File

@@ -434,9 +434,9 @@ extern void hid_button_task(chanend cc_mic_level, chanend c_hid, chanend c_hidSe
/* 改动原因:与 audiohw.xc 中 AudioHwRemote 一致。HID/音量/MIC 检测等已迁到 tile1 hid_button_task 与 AudioHwRemote2 内物理口;
* codec 仅经 streaming c_audiohwDFU 命令经 c_dfu仅 HID_DFU_EN=1。 */
#if HID_DFU_EN
extern void AudioHwRemote(streaming chanend c_audiohw_rx, streaming chanend c_dfu_rx, client interface tx1_led_if led_if);
extern void AudioHwRemote(streaming chanend c_audiohw_rx, chanend cc_mic_level, streaming chanend c_dfu_rx, client interface tx1_led_if led_if);
#else
extern void AudioHwRemote(streaming chanend c_audiohw_rx, client interface tx1_led_if led_if);
extern void AudioHwRemote(streaming chanend c_audiohw_rx, chanend cc_mic_level, client interface tx1_led_if led_if);
#endif
extern void dnr_dsp_proc_task(void);
@@ -546,7 +546,7 @@ int main()
USER_MAIN_DECLARATIONS
chan c_dsp_to_ex3d[DSP_WORKER_COUNT];
// chan cc_mic_level;
chan cc_mic_level;
streaming chan c_audiohw;
#if HID_DFU_EN
streaming chan c_dfu;
@@ -568,7 +568,7 @@ int main()
unsafe {
#if EQ_EN == 1 && USE_EX3D == 0
#endif
// hid_button_task(cc_mic_level, c_hidRcvData, c_hidSendData, c_uac_vol, c_ex3d_hid_cmd);
hid_button_task(cc_mic_level, c_hidRcvData, c_hidSendData, c_uac_vol, c_ex3d_hid_cmd);
}
#if USE_EX3D == 1
par(int i = 0; i < DSP_WORKER_COUNT; i++)
@@ -600,9 +600,9 @@ int main()
#endif
#if HID_DFU_EN
AudioHwRemote(c_audiohw, c_dfu, i_tx1_led);
AudioHwRemote(c_audiohw, cc_mic_level, c_dfu, i_tx1_led);
#else
AudioHwRemote(c_audiohw, i_tx1_led);
AudioHwRemote(c_audiohw, cc_mic_level, i_tx1_led);
#endif
}
}