普中科技F28335开发板的TLV320AIC23 芯片初始化
[复制链接]
本帖最后由 准音频算法工程师 于 2024-8-25 11:31 编辑
我不懂这段商家提供的代码:
void main()
{
AIC23Write(0x00,0x00);
Delay(100);
AIC23Write(0x02,0x00);
Delay(100);
AIC23Write(0x04,0x7f);
Delay(100);
AIC23Write(0x06,0x7f);
Delay(100);
AIC23Write(0x08,0x14);
Delay(100);
AIC23Write(0x0A,0x00);
Delay(100);
AIC23Write(0x0C,0x00);
Delay(100);
AIC23Write(0x0E,0x43);
Delay(100);
AIC23Write(0x10,0x23);
Delay(100);
AIC23Write(0x12,0x01);
Delay(100); //AIC23Init
}
Uint16 AIC23Write(int Address,int Data)
{
if (I2caRegs.I2CMDR.bit.STP == 1)
{
return I2C_STP_NOT_READY_ERROR;
}
// Setup slave address
I2caRegs.I2CSAR = 0x1A;
// Check if bus busy
if (I2caRegs.I2CSTR.bit.BB == 1)
{
return I2C_BUS_BUSY_ERROR;
}
// Setup number of bytes to send
// MsgBuffer + Address
I2caRegs.I2CCNT = 2;
I2caRegs.I2CDXR = Address;
I2caRegs.I2CDXR = Data;
// Send start as master transmitter
I2caRegs.I2CMDR.all = 0x6E20;
return I2C_SUCCESS;
}
根据注释,应该就是TLV320AIC23 芯片的初始化代码,但是我不是很能理解其中的含义。对照芯片资料的寄存器映射,发现不能和代码一一对应。比如AIC23Write(0x0A,0x00); 0x0A对应的二进制是1010,并不能在寄存器映射中找到这样的地址。
噢噢,我明白了。地址只有7位,是我输入16进制转2进制的高七位。原来如此,这下代码能和寄存器地址一一对应了。
|