最近在做IIC读写程序,用到HAL库,发现利用HAL库 对IIC读写问题,求助一下!
在HA库对IIC读写操作的2个库函数如下:
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t timeout)
HAL_StatusTypeDef
HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
我利用库函数对EEPROM的多字节读写做了实验如下:
HAL_StatusTypeDef EEPROM_WriteData(uint16_t MemAddr,uint8_t *pData,uint16_t Size)
{
uint16_t i;
HAL_StatusTypeDef sta;
for(i=0;i