|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
函数如下:这个函数是原厂提供的,没有问题
SMBUS_STATUS MCU_IIC_Access(BYTE IICAddr, BYTE RegAddr, void *Data, WORD Size)
{
// Not realy a Robust Algorithm for multi-master arbitration retry
for(i=10, j=0; j<IIC_MAX_RETRY; ++j) { // Time-Out to prevent dead lock
if(IICAddr & 0x01) { // Read
status = SMBUS_master_rw_synchronous(MCU_IIC_Bus, IICAddr-1, &RegAddr, 1, SMBUS_SkipStop);
status |= SMBUS_master_rw_synchronous(MCU_IIC_Bus, IICAddr, Data, Size, SMBUS_Normal);
}
else { // Write
status = SMBUS_master_rw_synchronous(MCU_IIC_Bus, IICAddr, &RegAddr, 1, SMBUS_SkipStop);
status |= SMBUS_master_rw_synchronous(MCU_IIC_Bus, IICAddr, Data, Size, SMBUS_SkipStart);
}
if(status) { // failed and retry
delay_1ms(i);
if(i>0) i-= 10/IIC_MAX_RETRY; // Become faster to prevent starvation
//RS232_printf("Err: IIC(H) %bu, Addr=0x%02bX, Reg=0x%02bX, retry %d\n", status, IICAddr, RegAddr, i);
}
else break;
}
if(status) {
RS232_printf("Err: IIC(H)%bu,Addr=%02bX,Reg=%02bX\n", status, IICAddr, RegAddr);
}
return status;
}
我自己编写的函数:
MCU_IIC_Write(I2C_FMS6502_ADR_rgb,VIDEO_OUT65,0x11,1);
但是没有配置成功,请教这样的写法有什么不对? |
|