//那位高手帮忙解读一下该段代码
NTSTATUS CDeviceBoardIWI::SetToMode(ULONG Mode)
{
if(GetCurrentMode() == Mode) return STATUS_SUCCESS;
NTSTATUS Status = STATUS_SUCCESS;
switch(Mode) {
case MODE_DTv:
case MODE_Standby:
m_Device->EP_SetGPIORegister(3, 1);
m_Device->EP_SetGPIORegister(2, 1);
if(m_AudioADCType == AUDIO_WM8775) {
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x19, 0x02);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x2a, 0x01);
}
else if(m_AudioADCType == AUDIO_WM8950) {
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x00, 0x00);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x02, 0x1B);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x04, 0x15);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x09, 0x10);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x0C, 0x09);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x36, 0x80);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x41, 0x38);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x46, 0x0F);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x58, 0x03);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x5A, 0x10);
Status |= m_Device->EP_I2CWrite(0x01, 0x34, 0x5F, 0x00);
}
if(m_VideoDecoder) m_VideoDecoder->ModeSavePower();
break;
case MODE_Video:
m_Device->EP_SetGPIORegister(3, 1);
m_Device->EP_Sleep(500000);
if(m_VideoDecoder) Status |= m_VideoDecoder->ModePowerUp();
else Status = STATUS_INSUFFICIENT_RESOURCES;
if(!NT_SUCCESS (Status)) {
SetDeviceStatus(STATUS_Error);
return Status;
}
break;
}
CDeviceBoard::SetToMode(Mode);
m_Device->EP_ProgramWriteKey(g_RegProgram_AudioMonoToStereo, 1);
return Status;
}
通过i2c总线,发送指令,写audio或video芯片的寄存器,设置工作模式。你的是什么板呀? 多媒体播放器?
你不明白的地方可能就是那些数字的参数吧,比如3,1,0xXX等,这个需要你去查看你手头拥有的相关的文档,一般都有说明的.最好去查看调用的函数及其详细的说明,就可以了,如EP_SetGPIORegister,EP_I2CWrite等函数.