Skip to main content
askari.nima
Associate III
January 22, 2015
Question

I2C HAL driver and Word data

  • January 22, 2015
  • 1 reply
  • 528 views
Posted on January 22, 2015 at 09:44

Hi

How can I send and receive  word data  in I2c bus. ( in new  HAL LIBRARY   STM32F1cube)

some sensor need word data.

thanks.
    This topic has been closed for replies.

    1 reply

    Montassar BEN ROMDHANE_O
    Visitor II
    February 26, 2015
    Posted on February 26, 2015 at 16:16

    Hi askari.nima,

    If you need to send word data to slave a device, you can use these interfaces :

     1-  No need repeated start condition, prefer to use one of these interfaces with a size equal to “2�? mean “2 bytes to send�? :

    HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)

    HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)

    HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)

     2- Need a repeated start condition, prefer to use one of these interfaces with a size equal to “2�? mean “2 bytes to send�? :

    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_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)

    HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)

    Hope that help,

    Regards,

    Heisenberg.