请问drv10987芯片手册第47页的IIC协议中,读和写的顺序是从高位到低位还是从低位到高位?我这样写的程序对不对?

void a10987_Write(u8 RegAdd,u8 DataToWriteH,u8 DataToWriteL)
{
IIC_Start();
IIC_Send_Byte(0xA4); 
IIC_Wait_Ack();
IIC_Send_Byte(RegAdd); 
IIC_Wait_Ack();
IIC_Send_Byte(DataToWriteH);  
IIC_Wait_Ack();
IIC_Send_Byte(DataToWriteL); 
IIC_Wait_Ack();
IIC_Stop();//²úÉúÒ»¸öÍ£Ö¹Ìõ¼þ
delay_ms(10);
}

u16 a10987_Read(u8 RegAdd)
{
u8 temp[2]={0};
u16 readdata;
IIC_Start();
IIC_Send_Byte(0xA4); //DRV10987µÄslave addressÊÇ101 0010,R/WλΪ0±íʾоƬ½øÐÐд²Ù×÷£¬ÈôÊǶÁ²Ù×÷ÔòΪ0xA5
IIC_Wait_Ack();
IIC_Send_Byte(RegAdd);
IIC_Wait_Ack();
IIC_Start();
IIC_Send_Byte(0xA5); 
temp[0]=IIC_Read_Byte(1);
temp[1]=IIC_Read_Byte(1);
readdata=((temp[0]<<8)|(temp[1]));
IIC_Stop();
delay_ms(10);
return readdata;
}

1 个回复