update EQ_EN mode
This commit is contained in:
@@ -302,6 +302,7 @@ static inline void CODEC_IC_REGREAD(unsigned reg, unsigned &val, client interfac
|
||||
}
|
||||
data[0] = val;
|
||||
|
||||
debug_printf("CODEC_IC_REGREAD reg: %d, val: %d\n", reg, data[0]);
|
||||
if (res == I2C_ACK)
|
||||
{
|
||||
result = I2C_REGOP_SUCCESS;
|
||||
@@ -330,6 +331,7 @@ static inline void CODEC_IC_REGWRITE(unsigned reg, unsigned val, client interfac
|
||||
return I2C_REGOP_INCOMPLETE;
|
||||
}
|
||||
|
||||
debug_printf("CODEC_IC_REGWRITE reg: %d, val: %d\n", reg, val);
|
||||
return I2C_REGOP_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -381,8 +383,10 @@ extern void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_u
|
||||
|
||||
void AudioHwRemote(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol)
|
||||
{
|
||||
delay_milliseconds(200);
|
||||
i2c_master_if i2c[1];
|
||||
unsigned page_ctrl;
|
||||
board_setup();
|
||||
delay_milliseconds(200);
|
||||
par {
|
||||
i2c_master(i2c, 1, p_scl, p_sda, 100);
|
||||
{
|
||||
@@ -390,12 +394,16 @@ void AudioHwRemote(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vo
|
||||
|
||||
// Initiate SW reset (PLL is powered off as part of reset)
|
||||
CODEC_IC_REGWRITE(AIC3204_SW_RST, 0x01, i2c[0]);
|
||||
delay_milliseconds(10);
|
||||
|
||||
// Program clock settings
|
||||
|
||||
// Default is CODEC_CLKIN is from MCLK pin. Don't need to change this.
|
||||
// Power up NDAC and set to 1
|
||||
CODEC_IC_REGWRITE(AIC3204_NDAC, 0x81, i2c[0]);
|
||||
|
||||
CODEC_IC_REGREAD(AIC3204_NDAC, page_ctrl, i2c[0]);
|
||||
debug_printf("page_ctrl: %d\n", page_ctrl);
|
||||
// Power up MDAC and set to 4
|
||||
CODEC_IC_REGWRITE(AIC3204_MDAC, 0x84, i2c[0]);
|
||||
// Power up NADC and set to 1
|
||||
@@ -474,7 +482,7 @@ void AudioHwRemote(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vo
|
||||
//CODEC_REGWRITE(AIC3204_OP_PWR_CTRL, 0x0C); // LO powerUP
|
||||
// Wait for 2.5 sec for soft stepping to take effect
|
||||
//vTaskDelay(pdMS_TO_TICKS(2500));
|
||||
delay_milliseconds(10);
|
||||
delay_milliseconds(20);
|
||||
|
||||
CODEC_IC_REGWRITE(AIC3204_PAGE_CTRL, 0x00, i2c[0]);
|
||||
// Power up the Left and Right DAC Channels. Route Left data to Left DAC and Right data to Right DAC.
|
||||
@@ -505,72 +513,10 @@ void AudioHwRemote(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vo
|
||||
button_task(c_hidSendData, cc_mic_level, c_uac_vol);
|
||||
}
|
||||
|
||||
#define EQ_MODE_DELAY (20000000) //100ms delay
|
||||
#define EQ_SYNC_DELAY (50000000) //500ms delay for EQ parameter syn
|
||||
|
||||
// 改动原因:EQ模式切换和参数存储已整合到button_task,AudioHwRemote2函数不再需要处理EQ相关逻辑
|
||||
void AudioHwRemote2(chanend c, client interface i2c_master_if i2c)
|
||||
{
|
||||
unsigned cmd;
|
||||
unsigned eq_mode_time = 0;
|
||||
timer eq_mode_timer, eq_sync_timer;
|
||||
unsigned eq_sync_time = 0;
|
||||
|
||||
eq_mode_timer :> eq_mode_time;
|
||||
eq_mode_time += EQ_MODE_DELAY;
|
||||
eq_sync_timer :> eq_sync_time;
|
||||
eq_sync_time += EQ_SYNC_DELAY;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
||||
if EQ_EN
|
||||
case eq_mode_timer when timerafter(eq_mode_time) :> void :
|
||||
eq_mode_time += EQ_MODE_DELAY;
|
||||
unsigned request_eq_mode, new_eq_mode;
|
||||
unsigned force_request_mode_change;
|
||||
GET_SHARED_GLOBAL(request_eq_mode, g_request_eq_mode);
|
||||
GET_SHARED_GLOBAL(new_eq_mode, g_new_eq_mode);
|
||||
GET_SHARED_GLOBAL(force_request_mode_change, g_force_request_eq_mode_change);
|
||||
if (new_eq_mode != request_eq_mode)
|
||||
{
|
||||
// debug_printf("new eq mode != request eq mode\n");
|
||||
SET_SHARED_GLOBAL(g_new_eq_mode, request_eq_mode);
|
||||
}
|
||||
|
||||
if (force_request_mode_change == 1)
|
||||
{
|
||||
debug_printf("force request mode change\n");
|
||||
SET_SHARED_GLOBAL(g_force_eq_mode_change, 1);
|
||||
SET_SHARED_GLOBAL(g_force_request_eq_mode_change, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case eq_sync_timer when timerafter(eq_sync_time) :> void :
|
||||
eq_sync_time += EQ_SYNC_DELAY;
|
||||
|
||||
// 使用单参数存储系统保存脏参数(独立保存EQ参数)
|
||||
if (eq_save_dirty_params() == 0) {
|
||||
//debug_printf("Single EQ parameters synced to Flash successfully\n");
|
||||
} else {
|
||||
//debug_printf("Failed to sync single EQ parameters to Flash\n");
|
||||
}
|
||||
|
||||
// 独立保存脏的增益
|
||||
if (eq_save_dirty_gain() == 0) {
|
||||
// debug_printf("Gain synced to Flash successfully\n");
|
||||
} else {
|
||||
//debug_printf("Failed to sync gain to Flash\n");
|
||||
}
|
||||
|
||||
// 独立保存脏的模式名称
|
||||
if (eq_save_dirty_names() == 0) {
|
||||
// debug_printf("Mode names synced to Flash successfully\n");
|
||||
} else {
|
||||
//debug_printf("Failed to sync mode names to Flash\n");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
// 改动原因:EQ模式切换和参数存储已移动到button_task中处理,此函数为空函数
|
||||
}
|
||||
|
||||
|
||||
@@ -582,7 +528,7 @@ void AudioHwInit()
|
||||
sw_pll_fixed_clock(MCLK_48);
|
||||
|
||||
// Wait for power supply to come up.
|
||||
delay_milliseconds(100);
|
||||
delay_milliseconds(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
// 改动原因:添加user_func.h头文件,用于调用save_value和load_value函数保存/加载模式到/从flash
|
||||
extern void save_value(unsigned char *path, unsigned char value);
|
||||
extern unsigned char load_value(unsigned char *path);
|
||||
#if EQ_EN
|
||||
// 改动原因:添加EQ相关头文件和函数声明,用于在button_task中处理EQ模式切换和参数存储
|
||||
#include "eq_flash_storage.h"
|
||||
extern unsigned g_request_eq_mode, g_new_eq_mode;
|
||||
extern unsigned g_force_request_eq_mode_change, g_force_eq_mode_change;
|
||||
#endif
|
||||
// 改动原因:添加g_host_os外部声明,用于检测主机操作系统类型(Windows或非Windows)
|
||||
extern unsigned g_host_os; // 1 -> Windows, 2 -> Others
|
||||
extern void device_reboot(void);
|
||||
@@ -150,29 +156,6 @@ void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudi
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
#if defined (SPATIAL_GAME) || defined (SPATIAL_MUSIC) || defined (SPATIAL_VIDEO) || defined (SPATIAL_DRAMA)
|
||||
// re-map the samples, downmix to 2ch; L -> SL; R -> SR
|
||||
if (is_3d == UBM_A3D_VON) {
|
||||
for (int idx=0;idx<8;idx++) {
|
||||
tmp[idx] = sampsFromUsbToAudio[idx];
|
||||
if (tmp[idx] & 0x80000000) {
|
||||
downmix[idx] = ((tmp[idx] >> 1) | 0xc0000000);
|
||||
} else {
|
||||
downmix[idx] = (tmp[idx] >> 1);
|
||||
}
|
||||
}
|
||||
ubm_egress[0][frame_index] = 0;
|
||||
ubm_egress[1][frame_index] = 0;
|
||||
ubm_egress[2][frame_index] = 0;
|
||||
ubm_egress[3][frame_index] = 0;
|
||||
ubm_egress[4][frame_index] = 0;
|
||||
ubm_egress[5][frame_index] = 0;
|
||||
ubm_egress[6][frame_index] = downmix[0] + downmix[2] + downmix[3] + downmix[4] + downmix[6];
|
||||
ubm_egress[7][frame_index] = downmix[1] + downmix[2] + downmix[3] + downmix[5] + downmix[7];
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if (NUM_USB_CHAN_IN == 2)
|
||||
|
||||
#if AIZIP_DNR == 1
|
||||
@@ -1218,6 +1201,10 @@ void button_task(chanend_t c_hidSendData, chanend_t cc_mic_level, chanend_t c_ua
|
||||
{
|
||||
hwtimer_t timer = hwtimer_alloc();
|
||||
static int uac_vol=0, last_uac_vol=0;
|
||||
#if EQ_EN
|
||||
// 改动原因:添加EQ参数存储计数器,用于每500ms保存一次EQ参数
|
||||
static unsigned eq_sync_counter = 0; // EQ参数存储计数器(每100ms递增,5次后保存)
|
||||
#endif
|
||||
port_t p_ctrl_keys = XS1_PORT_8C;
|
||||
|
||||
uint32_t port_ctrl_keys = 0, curr_ctrl_keys = 0, last_ctrl_keys = 0, keys_changed = 0;
|
||||
@@ -1473,6 +1460,56 @@ void button_task(chanend_t c_hidSendData, chanend_t cc_mic_level, chanend_t c_ua
|
||||
last_uac_vol = uac_vol;
|
||||
}
|
||||
|
||||
#if 0// EQ_EN
|
||||
// 改动原因:EQ模式切换处理(每100ms检查一次),从AudioHwRemote2整合到button_task
|
||||
{
|
||||
unsigned request_eq_mode, new_eq_mode;
|
||||
unsigned force_request_mode_change;
|
||||
GET_SHARED_GLOBAL(request_eq_mode, g_request_eq_mode);
|
||||
GET_SHARED_GLOBAL(new_eq_mode, g_new_eq_mode);
|
||||
GET_SHARED_GLOBAL(force_request_mode_change, g_force_request_eq_mode_change);
|
||||
if (new_eq_mode != request_eq_mode)
|
||||
{
|
||||
// debug_printf("new eq mode != request eq mode\n");
|
||||
SET_SHARED_GLOBAL(g_new_eq_mode, request_eq_mode);
|
||||
}
|
||||
|
||||
if (force_request_mode_change == 1)
|
||||
{
|
||||
debug_printf("force request mode change\n");
|
||||
SET_SHARED_GLOBAL(g_force_eq_mode_change, 1);
|
||||
SET_SHARED_GLOBAL(g_force_request_eq_mode_change, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// 改动原因:EQ参数存储处理(每500ms保存一次),从AudioHwRemote2整合到button_task
|
||||
eq_sync_counter++;
|
||||
if (eq_sync_counter >= 5) { // 5 * 100ms = 500ms
|
||||
eq_sync_counter = 0;
|
||||
|
||||
// 使用单参数存储系统保存脏参数(独立保存EQ参数)
|
||||
if (eq_save_dirty_params() == 0) {
|
||||
//debug_printf("Single EQ parameters synced to Flash successfully\n");
|
||||
} else {
|
||||
//debug_printf("Failed to sync single EQ parameters to Flash\n");
|
||||
}
|
||||
|
||||
// 独立保存脏的增益
|
||||
if (eq_save_dirty_gain() == 0) {
|
||||
// debug_printf("Gain synced to Flash successfully\n");
|
||||
} else {
|
||||
//debug_printf("Failed to sync gain to Flash\n");
|
||||
}
|
||||
|
||||
// 独立保存脏的模式名称
|
||||
if (eq_save_dirty_names() == 0) {
|
||||
// debug_printf("Mode names synced to Flash successfully\n");
|
||||
} else {
|
||||
//debug_printf("Failed to sync mode names to Flash\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ extern void key_receiver(chanend c_key);
|
||||
{ \
|
||||
unsafe\
|
||||
{\
|
||||
board_setup();\
|
||||
key_receiver(c_key);\
|
||||
}\
|
||||
AudioHwRemote(c_hidSendData, cc_mic_level, c_uac_vol);\
|
||||
|
||||
Reference in New Issue
Block a user