QORC-SDK I2C HAL

This file contains API declaration for the I2C Controller(s) in the EOS S3.

Defines

I2C_PRELO
I2C_PREHI
I2C_MCR
I2C_TXRX_DR
I2C_CMD_SR
HAL_I2C_WRITE_PRESCALE(PRESCALE)
I2C_CR_EN_BIT
I2C_CR_IEN_BIT
HAL_I2C_ENABLE()
HAL_I2C_DISABLE()
HAL_I2C_INT_ENABLE()
HAL_I2C_INT_DISABLE()
HAL_I2C_WRITE_REQ(DEV_ADR)
HAL_I2C_READ_REQ(DEV_ADR)
CMD_START_BIT
CMD_STOP_BIT
CMD_READ_SLAVE_BIT
CMD_WRITE_SLAVE_BIT
CMD_NACK_BIT
CMD_IACK_BIT
HAL_I2C_SET_CMD(CMD_VAL)
SR_RXACK_BIT
SR_BUSY_BIT
SR_AL_BIT
SR_TIP_BIT
SR_IF_BIT
HAL_I2C_IS_RXACK_SET()
HAL_I2C_IS_BUSY_SET()
HAL_I2C_IS_AL_SET()
HAL_I2C_IS_TIP_SET()
HAL_I2C_IS_IF_SET()

Enums

enum I2C_State

Values:

enumerator I2C_RESET
enumerator I2C_READY
enumerator I2C_BUSY
enumerator I2C_TIMEOUT
enum I2C_FREQ

Values:

enumerator I2C_100KHZ
enumerator I2C_200KHZ
enumerator I2C_300Khz
enumerator I2C_400KHZ
enumerator I2C_INVALID
enum I2C_IntMode

Values:

enumerator I2C_DISABLE
enumerator I2C_ENABLE

Functions

HAL_StatusTypeDef HAL_I2C0_Select(void)

Select I2C0 device to use for all I2C init/read/write operation.

Returns:

HAL_StatusTypeDef status of device.

HAL_StatusTypeDef HAL_I2C1_Select(void)

Select I2C1 device to use for all I2C init/read/write operation.

Returns:

HAL_StatusTypeDef status of device.

HAL_StatusTypeDef HAL_I2C_Init(I2C_Config xI2CConfig)

Select I2C1 device to use for all I2C init/read/write operation.

Parameters:

xI2CConfig – I2C configuration structure

Returns:

HAL_StatusTypeDef status of device Init operation.

HAL_StatusTypeDef HAL_I2C_SetClockFreq(UINT32_t uiClkFreq)

Set clock frequency for I2C device. It may not be exact frequency when set.

Parameters:

uiClkFreq – I2C clock frequency to set.

Returns:

HAL_StatusTypeDef status of frequency set operation.

HAL_StatusTypeDef HAL_I2C_Write(UINT8_t ucDevAddress, UINT8_t ucAddress, UINT8_t *pucDataBuf, UINT32_t uiLength)

Write data to I2C device.

Parameters:
  • ucDevAddress – I2C device address.

  • ucAddress – offset address in device to write.

  • pucDataBuf – pointer to data array to write.

  • uiLength – Length of data to write (in bytes)

Returns:

HAL_StatusTypeDef status of I2C write operation.

HAL_StatusTypeDef HAL_I2C_Read(UINT8_t ucDevAddress, UINT8_t ucAddress, UINT8_t *pucDataBuf, UINT32_t uiLength)

Read data from I2C device.

Parameters:
  • ucDevAddress – I2C device address.

  • ucAddress – offset address in device to read.

  • pucDataBuf – pointer to data array to read.

  • uiLength – Length of data to read (in bytes)

Returns:

HAL_StatusTypeDef status of I2C read operation.

HAL_StatusTypeDef HAL_I2C_Read16(UINT8_t ucDevAddress, UINT16_t ucAddress, UINT8_t *pucDataBuf, UINT32_t uiLength)
HAL_StatusTypeDef HAL_I2C_Write16(UINT8_t ucDevAddress, UINT16_t ucAddress, UINT8_t *pucDataBuf, UINT32_t uiLength)
HAL_StatusTypeDef HAL_I2C_Read_UsingRestart(UINT8_t ucDevAddress, UINT8_t ucAddress, UINT8_t *pucDataBuf, UINT32_t uiLength)

Read data from I2C device using Restart

Parameters:
  • ucDevAddress[in] I2C device 7-bit address

  • ucAddress[in] register index to read data from

  • pucDataBuf[out] address of the buffer to store register data

  • uiLength[in] read uiLength bytes of data

HAL_StatusTypeDef HAL_I2C_WriteRawData(UINT8_t ucDevAddress, UINT8_t *pucDataBuf, UINT32_t uiLength, int stop)
HAL_StatusTypeDef HAL_I2C_ReadRawData(UINT8_t ucDevAddress, UINT8_t *pucDataBuf, UINT32_t uiLength)
struct I2C_Config

Public Members

I2C_FREQ eI2CFreq

I2C Frequency

I2C_IntMode eI2CInt

Interrupt enable

UINT8_t ucI2Cn