TDA7415除錯小結

2021-09-30 05:50:53 字數 4513 閱讀 3528

tda7415內部的暫存器比較少,共32個,實際只會使用0~23和31這25個。其中0~23是功能暫存器,31暫存器是用於測試的。除錯這個**,建議先從測試暫存器入手,在其內部寫入0x3e,這樣就可以在相應的引腳上測得乙個200khz的訊號。如果順利到這一步,基本可以放心了,iic通訊沒有問題,寫暫存器沒有問題。千萬記住,不要想當然的通過讀取暫存器的方法來確定iic通訊是否有問題。接下來就是按照它的文件配置那24個暫存器。

/**  init part

*/  

static const struct i2c_device_id tda7415_id = ,

{}, };

module_device_table(i2c, tda7415_id);

static struct i2c_driver tda7415_i2c_driver = ,

.probe = tda7415_i2c_probe,

.remove = __devexit_p(tda7415_i2c_remove),

.id_table = tda7415_id, };

static int __init alsa_tda7415t_init(void)

static void __exit alsa_tda7415t_exit(void)

module_init(alsa_tda7415t_init);

module_exit(alsa_tda7415t_exit);

static __devinit int tda7415_i2c_probe(struct i2c_client *client,

const struct i2c_device_id *id)

struct tda7415_drvdata *drv_data;

struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);

printk("debug at func %s(),line %d by tongjiang/n",__function__,__line__);

drv_data = kmalloc(sizeof(struct tda7415_drvdata), gfp_kernel);

if (drv_data == null) 

printk(&client->dev, "dev %s,lack of kernel memory!/n");

return -enomem;

if (!i2c_check_functionality(adapter, i2c_func_smbus_byte_data)) 

printk(&adapter->dev,

"dev %s,i2c-adapter doesn't support i2c_func_smbus_word/n");

return -eio;

drv_data->client = client;

i2c_set_clientdata(client, drv_data);

mutex_init(&drv_data->lock);

tda7415_init_client(client);

return 0;

static struct i2c_board_info mxc_i2c0_board_info __initdata = {

.type = "ov3640",

.addr = 0x3c,

.platform_data = (void *)&camera_data,

.type = "tda7415-i2c",

.addr = 0x46, 

static int tda7415_init_client(struct i2c_client *client)

int i;

struct tda7415_drvdata *tda7415_data = i2c_get_clientdata(client);

u8 reg;

u8 data;

int ret = 0;

if (null == tda7415_data)

return -enomem;

printk("debug at func %s(),line %d by tongjiang/n",__function__,__line__);

tda7415_data->audio7415_regbuf[0] = 0xff;

tda7415_data->audio7415_regbuf[1] = 0xd0;

tda7415_data->audio7415_regbuf[2] = 0xfe; //bass:40hz

tda7415_data->audio7415_regbuf[3] = 0xff;

tda7415_data->audio7415_regbuf[4] = 0xff;

tda7415_data->audio7415_regbuf[5] = 0xfe;

tda7415_data->audio7415_regbuf[6] = 0xff; //full mute

tda7415_data->audio7415_regbuf[7] = 0xff; //full mute

tda7415_data->audio7415_regbuf[8] = 0xff; //full mute

tda7415_data->audio7415_regbuf[9] = 0x30; //fast charge: must be setting release

tda7415_data->audio7415_regbuf[10] = 0x7c;

tda7415_data->audio7415_regbuf[11] = 0xec; //center, subwoof of the mix channel from ac3; jowen.xiao091112

tda7415_data->audio7415_regbuf[12] = 0x76; //left & right channel high filter bypass

tda7415_data->audio7415_regbuf[13] = 0x70;

tda7415_data->audio7415_regbuf[14] = 0x70;

tda7415_data->audio7415_regbuf[15] = 0x70;

tda7415_data->audio7415_regbuf[16] = 0x70;

tda7415_data->audio7415_regbuf[17] = 0xf6; //stereo bypass

tda7415_data->audio7415_regbuf[18] = 0x70;

tda7415_data->audio7415_regbuf[19] = 0x70;

tda7415_data->audio7415_regbuf[20] = 0xfe;

tda7415_data->audio7415_regbuf[21] = 0xc8;

tda7415_data->audio7415_regbuf[22] = 0xf6;//y11110110;//sotf-mute time 5ms, soft-step 2.56ms

tda7415_data->audio7415_regbuf[23] = 0xf1;

memset(&tda7415_data->audio7415.curr_ch, 0, sizeof(audio7415struct));

tda7415_data->audio7415.bas = 0;

tda7415_data->audio7415.tre = 0;

tda7415_data->audio7415.mid = 0;

tda7415_data->audio7415.balance = 0;

tda7415_data->audio7415.fader = 0;

tda7415_data->audio7415.subwoof = 0;

tda7415_data->audio7415.center = 0;

reg = 0x5f;

data = 0x3e;

ret = tda7415_reg_write(client,reg,data);

printk("initial write of tda7415 write over ret = %d/n",ret);

for (i = 0; i < array_size(tda7415_data->audio7415_regcache); i++) 

int v = i2c_smbus_read_byte_data(client, i);

if (v < 0)

return -enodev;

tda7415_data->audio7415_regcache[i] = v;

for (i = 0; i < array_size(tda7415_data->audio7415_regcache); i++) 

printk("debug read byte 0 is %d",tda7415_data->audio7415_regcache[i]);

return 0;

串列埠除錯小結

這個專案是將藍芽模組與nfc模組整合在一起,做乙個demo。兩個模組之間使用串列埠通訊,兩個模組上的mcu均為stm32系列,nfc模組上還有兩個串列埠,乙個作為log,乙個作為at通道,與上位機通訊。之前由於nfc模組與上位機的串列埠通訊,以及log都調通,所以這次只需要將與藍芽模組的串列埠通訊調...

gdb除錯小結

二 資訊顯示 三 斷點 四 其他參考 當以gdb方式啟動gdb後,gdb會在path路徑和當前目錄中搜尋的原始檔。如要確認gdb是否讀到原始檔,可使用l或list命令,看看gdb是否能列出源 使用 gdb r或run命令執行程式。gdb p pid是程序id,可以通過 ps aux grep 程式名...

gdb除錯小結

gdb 最基本的除錯命令.1以除錯程式test.cpp 為例 進入除錯環境 gdb test 2.b 12 在檔案的第12 行設定斷點。刪除斷點 info b 列出所有的斷點資訊 gdb info b num type disp enb address what 1 breakpoint keep ...