void IIC_Continus_Write(u8 WriteAddrs,u8 *Num,u16 NumToWrite)
{
IIC_Start(); //开始信号
IIC_Send_Byte(0xA0); //写入器件地址+0
IIC_Wait_Ack(); //等待应答
IIC_Send_Byte(WriteAddrs); //写入目标内存地址
IIC_Wait_Ack();
while(NumToWrite) //开始写入
{
IIC_Send_Byte(*Num);
IIC_Wait_Ack();
++Num;
NumToWrite--;
}
IIC_Stop(); //结束IIC
}
void IIC_Continus_Read(u8 ReadAddrs,u8 *Array,u16 Len)
{
IIC_Start(); //开始信号
IIC_Send_Byte(0xA0); //写入器件地址+0
IIC_Wait_Ack(); //等待应答
IIC_Send_Byte(ReadAddrs); //写入要读取的内存地址
IIC_Wait_Ack();
IIC_Start(); //重新发送开始信号
IIC_Send_Byte(0xA1); //写入器件地址+1
IIC_Wait_Ack();
while(Len)
{
*Array=IIC_Read_Byte();
IIC_Ack();
++Array;
Len--;
}
IIC_Stop();
}
|