这是我整个函数的所有代码,单步仿真就只有读取麦克风和喇叭状态这部分的判断出现这个问题。
//从CX20709读取USB,麦克风,喇叭状态
void Read_Status(void)
{
//读取USB状态
while (!Rx)
{
IWDG->KR = 0xAA;
Rx = I2CRcvStr(BQ24168_IIC_PORT, POW_SDA, POW_SCL, 0xd6, 0x00, CX20709, 2); // 2
}
Rx = 0;
if (((0x40 & CX20709[0]) == 0x40) || ((0x20 & CX20709[0]) == 0x20))
{
USB_Reg = 1; //USB存在
}
else
{
USB_Reg = 0; //USB不存在
USB_Output = 1; //USB拔出状态,没有检测到USB
}
//读取音量等级状态
if (IRcvStr(GPIOB, SDA, SDL, 0x28, 0x12, 0xCE, &CX20709[4], 1))
{
if (IRcvStr(GPIOB, SDA, SDL, 0x28, 0x12, 0xCF, &CX20709[5], 1))
{
Spk_Sign = (CX20709[5] << 8) | CX20709[4];
}
}
//读取麦克风和喇叭状态
while (!Rx)
{
IWDG->KR = 0xAA;
Rx = IRcvStr(GPIOB, SDA, SDL, 0x28, 0x10, 0x18, &CX20709[3], 1); // 2
}
Rx = 0;
if ((0x01 & CX20709[3]) == 0x01)
{
Spk_Mute = 1;
}
else
{
Spk_Mute = 0;
}
if ((0x08 & CX20709[3]) == 0x08)
{
Mic_Mute = 1;
}
else
{
Mic_Mute = 0;
}
if (Spk_Mute == 1)
{
if (Mic_Mute == 1)
{
flash = 2; //蓝灯红灯闪烁
}
else
{
flash = 1; //蓝灯闪烁
}
}
else
{
flash = 0;
}
//同时连接所有外设
if ((Blu_Reg == 1) && (USB_Reg == 1))
{
Phone_Job = 3;
}
//只有蓝牙连接
else if ((Blu_Reg == 1) && (USB_Reg == 0))
{
Phone_Job = 2;
}
//只有USB连接
else if ((Blu_Reg == 0) && (USB_Reg == 1))
{
Phone_Job = 1;
}
//没有外设连接
else
{
Phone_Job = 0;
}
} |