模拟I2C控制24C02(5)
发布时间:2021-06-06
发布时间:2021-06-06
使用STM32红牛开发的GPIO模拟I2C控制八个AT24C02的读写
else
{
/* If NumByteToWrite < I2C_PageSize */
if(NumOfPage== 0)
{
I2C_EE_PageRead(pBuffer, ReadAddr, NumOfSingle);
} /* If NumByteToWrite > I2C_PageSize */
else
{
NumByteToRead -= count;
NumOfPage = NumByteToRead / I2C_PageSize;
NumOfSingle = NumByteToRead % I2C_PageSize;
if(count != 0)
{
I2C_EE_PageRead(pBuffer, ReadAddr, count);
ReadAddr += count;
pBuffer += count;
}
while(NumOfPage--)
{
I2C_EE_PageRead(pBuffer, ReadAddr, I2C_PageSize);
ReadAddr += I2C_PageSize;
pBuffer += I2C_PageSize;
}
if(NumOfSingle != 0)
{
I2C_EE_PageRead(pBuffer, ReadAddr, NumOfSingle);
}
}
}
}
void I2C_EE_Current_Read(u8* pBuffer)
{
/* Send START condition */
I2C_GenerateSTART();
I2C_SendData(I2C_SLAVE_ADDRESS7_R);
Ack();
*pBuffer = I2C_ReceiveData();
NAck();
I2C_GenerateSTOP();
上一篇:汽车火灾探测研究现状及发展趋势
下一篇:Android Widget