在这里插入代码片
//写数据
void Eeprom_Write(uint16_t MemAddr,uint8_t *Wbuf,uint16_t len)
{
while(len--)
{
while(HAL_I2C_Mem_Write(&hi2c1, Write_Addr, MemAddr,I2C_MEMADD_SIZE_16BIT, Wbuf, 1, 100) != HAL_OK);
MemAddr++;
Wbuf++;
}
}
/*****************读数据****************/
void Eeprom_Read(uint16_t MemAddr, uint8_t *Rbuf,uint16_t len)
{
while(HAL_I2C_Mem_Read(&hi2c1, Read_Addr, MemAddr, I2C_MEMADD_SIZE_16BIT, Rbuf, len, 100) != HAL_OK);
}
//在main函数里面调用
Eeprom_Write(0,Wbuf,sizeof(Wbuf));
HAL_Delay(500);
Eeprom_Read(0,Rbuf,sizeof(Rbuf));
05-05
798
03-16
5050