小学生
最后登录1970-1-1
在线时间 小时
注册时间2020-7-14
|
stm32l0xx hal Slave Address: 0x7C(Write) Regaddress:0x00,0x01,0x03,data:0x14,0x14,0x03
怎样向从机的寄存器写入数据?
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
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);
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
如下代码不起作用:
HAL_I2C_Mem_Write(&hi2c1, 0x7C, 0x00, I2C_MEMADD_SIZE_8BIT, (uint8_t *)0x14, 1, 1000);
HAL_I2C_Mem_Write(&hi2c1, 0x7C, 0x01, I2C_MEMADD_SIZE_8BIT, (uint8_t *)0x14, 1, 1000);
HAL_I2C_Mem_Write(&hi2c1, 0x7C, 0x03, I2C_MEMADD_SIZE_8BIT, (uint8_t *)0x03, 1, 1000);
|
|