运行 EEPROM_Read(0x00, gRxData, 8);会卡死,什么也不输出
例程代码如下
main.c:
s32 main(void)
{
CONSOLE_Init(115200);
DELAY_Init();
I2C_WR_EepromInit();
I2C_WR_EepromTest();
while(1);
}
i2c.c:
void EEPROM_Read(u8 sub, u8* ptr, u16 len)
{
do {
//read data
EEPROM_ReadPacket(sub, ptr, len);
//till I2C is not work
while(gEeprom.busy);
} while(!gEeprom.ack);
}
void I2C_WR_EepromTest(void)
{
u32 cnt;
//Write 16 bytes from buffer0[128] to 0x10 of EEPROM
EEPROM_Write(0x00, gTxData, 8);
DELAY_Ms(1);
for(cnt = 0; cnt < 8 ; cnt ++)
{
printf("TX data%d is: %x \r\n", cnt, gTxData[cnt]);
}
//Read 16 bytes from 0x10 of EEPROM to buffer1[128]
EEPROM_Read(0x00, gRxData, 8);
for(cnt = 0; cnt < 8; cnt++) {
printf("RX data%d is : %x \r\n", cnt, gRxData[cnt]);
}
printf("i2c1 polling test over\r\n");
}
|