| M480 BSP V3.05.001 The Board Support Package for M480 Series

Macros | Functions
USCI_I2C Exported Functions
Standard Driver » USCI_I2C Driver

## Macros
#define | UI2C_SET_CONTROL_REG(ui2c, u8Ctrl)
| This macro sets the USCI_I2C protocol control register at one time. More...
#define | UI2C_START(ui2c)
| This macro only set START bit to protocol control register of USCI_I2C module. More...
#define | UI2C_STOP(ui2c)
| This macro only set STOP bit to the control register of USCI_I2C module. More...
#define | UI2C_GET_DATA(ui2c)
| This macro returns the data stored in data register of USCI_I2C module. More...
#define | UI2C_SET_DATA(ui2c, u8Data)
| This macro writes the data to data register of USCI_I2C module. More...
#define | UI2C_GET_TIMEOUT_FLAG(ui2c)
| This macro returns time-out flag. More...
#define | UI2C_GET_WAKEUP_FLAG(ui2c)
| This macro returns wake-up flag. More...
#define | UI2C_CLR_WAKEUP_FLAG(ui2c)
| This macro is used to clear USCI_I2C wake-up flag. More...
#define | UI2C_DISABLE_10BIT_ADDR_MODE(ui2c)
| This macro disables the USCI_I2C 10-bit address mode. More...
#define | UI2C_ENABLE_10BIT_ADDR_MODE(ui2c)
| This macro enables the 10-bit address mode. More...
#define | UI2C_GET_PROT_STATUS(ui2c)
| This macro gets USCI_I2C protocol interrupt flag or bus status. More...
#define | UI2C_CLR_PROT_INT_FLAG(ui2c, u32IntTypeFlag)
| This macro clears specified protocol interrupt flag. More...
#define | UI2C_ENABLE_PROT_INT(ui2c, u32IntSel)
| This macro enables specified protocol interrupt. More...
#define | UI2C_DISABLE_PROT_INT(ui2c, u32IntSel)
| This macro disables specified protocol interrupt. More...

## Functions
uint32_t | UI2C_Open (UI2C_T *ui2c, uint32_t u32BusClock)
| This function makes USCI_I2C module be ready and set the wanted bus clock. More...
void | UI2C_Close (UI2C_T *ui2c)
| This function closes the USCI_I2C module. More...
void | UI2C_ClearTimeoutFlag (UI2C_T *ui2c)
| This function clears the time-out flag. More...
void | UI2C_Trigger (UI2C_T *ui2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Ptrg, uint8_t u8Ack)
| This function sets the control bit of the USCI_I2C module. More...
void | UI2C_DisableInt (UI2C_T *ui2c, uint32_t u32Mask)
| This function disables the interrupt of USCI_I2C module. More...
void | UI2C_EnableInt (UI2C_T *ui2c, uint32_t u32Mask)
| This function enables the interrupt of USCI_I2C module. More...
uint32_t | UI2C_GetBusClockFreq (UI2C_T *ui2c)
| This function returns the real bus clock of USCI_I2C module. More...
uint32_t | UI2C_SetBusClockFreq (UI2C_T *ui2c, uint32_t u32BusClock)
| This function sets bus clock frequency of USCI_I2C module. More...
uint32_t | UI2C_GetIntFlag (UI2C_T *ui2c, uint32_t u32Mask)
| This function gets the interrupt flag of USCI_I2C module. More...
void | UI2C_ClearIntFlag (UI2C_T *ui2c, uint32_t u32Mask)
| This function clears the interrupt flag of USCI_I2C module. More...
uint32_t | UI2C_GetData (UI2C_T *ui2c)
| This function returns the data stored in data register of USCI_I2C module. More...
void | UI2C_SetData (UI2C_T *ui2c, uint8_t u8Data)
| This function writes a byte data to data register of USCI_I2C module. More...
void | UI2C_SetSlaveAddr (UI2C_T *ui2c, uint8_t u8SlaveNo, uint16_t u16SlaveAddr, uint8_t u8GCMode)
| Configure slave address and enable GC mode. More...
void | UI2C_SetSlaveAddrMask (UI2C_T *ui2c, uint8_t u8SlaveNo, uint16_t u16SlaveAddrMask)
| Configure the mask bit of slave address. More...
void | UI2C_EnableTimeout (UI2C_T *ui2c, uint32_t u32TimeoutCnt)
| This function enables time-out function and configures timeout counter. More...
void | UI2C_DisableTimeout (UI2C_T *ui2c)
| This function disables time-out function. More...
void | UI2C_EnableWakeup (UI2C_T *ui2c, uint8_t u8WakeupMode)
| This function enables the wakeup function of USCI_I2C module. More...
void | UI2C_DisableWakeup (UI2C_T *ui2c)
| This function disables the wakeup function of USCI_I2C module. More...
uint8_t | UI2C_WriteByte (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t data)
| Write a byte to Slave. More...
uint32_t | UI2C_WriteMultiBytes (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t *data, uint32_t u32wLen)
| Write multi bytes to Slave. More...
uint8_t | UI2C_WriteByteOneReg (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t data)
| Specify a byte register address and write a byte to Slave. More...
uint32_t | UI2C_WriteMultiBytesOneReg (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t *data, uint32_t u32wLen)
| Specify a byte register address and write multi bytes to Slave. More...
uint8_t | UI2C_WriteByteTwoRegs (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t data)
| Specify two bytes register address and Write a byte to Slave. More...
uint32_t | UI2C_WriteMultiBytesTwoRegs (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t *data, uint32_t u32wLen)
| Specify two bytes register address and write multi bytes to Slave. More...
uint8_t | UI2C_ReadByte (UI2C_T *ui2c, uint8_t u8SlaveAddr)
| Read a byte from Slave. More...
uint32_t | UI2C_ReadMultiBytes (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t *rdata, uint32_t u32rLen)
| Read multi bytes from Slave. More...
uint8_t | UI2C_ReadByteOneReg (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr)
| Specify a byte register address and read a byte from Slave. More...
uint32_t | UI2C_ReadMultiBytesOneReg (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t *rdata, uint32_t u32rLen)
| Specify a byte register address and read multi bytes from Slave. More...
uint8_t | UI2C_ReadByteTwoRegs (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr)
| Specify two bytes register address and read a byte from Slave. More...
uint32_t | UI2C_ReadMultiBytesTwoRegs (UI2C_T *ui2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t *rdata, uint32_t u32rLen)
| Specify two bytes register address and read multi bytes from Slave. More...

## Detailed Description

## Macro Definition Documentation

## ◆ UI2C_CLR_PROT_INT_FLAG

#define UI2C_CLR_PROT_INT_FLAG | ( |  | ui2c,
|  |  | u32IntTypeFlag
| ) |  |

This macro clears specified protocol interrupt flag.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32IntTypeFlag | Interrupt Type Flag, should be UI2C_PROTSTS_ACKIF_Msk UI2C_PROTSTS_ERRIF_Msk UI2C_PROTSTS_ARBLOIF_Msk UI2C_PROTSTS_NACKIF_Msk UI2C_PROTSTS_STORIF_Msk UI2C_PROTSTS_STARIF_Msk UI2C_PROTSTS_TOIF_Msk

Returns
  None

To clear interrupt flag when USCI_I2C occurs interrupt and set interrupt flag.

Definition at line 250 of file usci_i2c.h.

## ◆ UI2C_CLR_WAKEUP_FLAG

#define UI2C_CLR_WAKEUP_FLAG | ( |  | ui2c | ) |

This macro is used to clear USCI_I2C wake-up flag.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

If USCI_I2C wake-up flag is set, use this macro to clear it.

Definition at line 196 of file usci_i2c.h.

## ◆ UI2C_DISABLE_10BIT_ADDR_MODE

#define UI2C_DISABLE_10BIT_ADDR_MODE | ( |  | ui2c | ) |

This macro disables the USCI_I2C 10-bit address mode.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

The UI2C_I2C is 7-bit address mode, when disable USCI_I2C 10-bit address match function.

Definition at line 208 of file usci_i2c.h.

## ◆ UI2C_DISABLE_PROT_INT

#define UI2C_DISABLE_PROT_INT | ( |  | ui2c,
|  |  | u32IntSel
| ) |  |

This macro disables specified protocol interrupt.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32IntSel | Interrupt Type, should be UI2C_PROTIEN_ACKIEN_Msk UI2C_PROTIEN_ERRIEN_Msk UI2C_PROTIEN_ARBLOIEN_Msk UI2C_PROTIEN_NACKIEN_Msk UI2C_PROTIEN_STORIEN_Msk UI2C_PROTIEN_STARIEN_Msk UI2C_PROTIEN_TOIEN_Msk

Returns
  None

Clear specified USCI_I2C protocol interrupt bits to disable interrupt function.

Definition at line 286 of file usci_i2c.h.

## ◆ UI2C_ENABLE_10BIT_ADDR_MODE

#define UI2C_ENABLE_10BIT_ADDR_MODE | ( |  | ui2c | ) |

This macro enables the 10-bit address mode.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

To enable USCI_I2C 10-bit address match function.

Definition at line 220 of file usci_i2c.h.

## ◆ UI2C_ENABLE_PROT_INT

#define UI2C_ENABLE_PROT_INT | ( |  | ui2c,
|  |  | u32IntSel
| ) |  |

This macro enables specified protocol interrupt.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32IntSel | Interrupt Type, should be UI2C_PROTIEN_ACKIEN_Msk UI2C_PROTIEN_ERRIEN_Msk UI2C_PROTIEN_ARBLOIEN_Msk UI2C_PROTIEN_NACKIEN_Msk UI2C_PROTIEN_STORIEN_Msk UI2C_PROTIEN_STARIEN_Msk UI2C_PROTIEN_TOIEN_Msk

Returns
  None

Set specified USCI_I2C protocol interrupt bits to enable interrupt function.

Definition at line 268 of file usci_i2c.h.

## ◆ UI2C_GET_DATA

#define UI2C_GET_DATA | ( |  | ui2c | ) |

This macro returns the data stored in data register of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  Data

Read a byte data value of UI2C_RXDAT register from USCI_I2C bus

Definition at line 145 of file usci_i2c.h.

## ◆ UI2C_GET_PROT_STATUS

#define UI2C_GET_PROT_STATUS | ( |  | ui2c | ) |

This macro gets USCI_I2C protocol interrupt flag or bus status.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  A word data of USCI_I2C_PROTSTS register

Read a word data of USCI_I2C PROTSTS register to get USCI_I2C bus Interrupt flags or status.

Definition at line 232 of file usci_i2c.h.

## ◆ UI2C_GET_TIMEOUT_FLAG

#define UI2C_GET_TIMEOUT_FLAG | ( |  | ui2c | ) |

This macro returns time-out flag.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Return values

  0 | USCI_I2C bus time-out is not happened
  1 | USCI_I2C bus time-out is happened

USCI_I2C bus occurs time-out event, the time-out flag will be set. If not occurs time-out event, this bit is cleared.

Definition at line 171 of file usci_i2c.h.

## ◆ UI2C_GET_WAKEUP_FLAG

#define UI2C_GET_WAKEUP_FLAG | ( |  | ui2c | ) |

This macro returns wake-up flag.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Return values

  0 | Chip is not woken-up from power-down mode
  1 | Chip is woken-up from power-down mode

USCI_I2C controller wake-up flag will be set when USCI_I2C bus occurs wake-up from deep-sleep.

Definition at line 184 of file usci_i2c.h.

## ◆ UI2C_SET_CONTROL_REG

#define UI2C_SET_CONTROL_REG | ( |  | ui2c,
|  |  | u8Ctrl
| ) |  |

This macro sets the USCI_I2C protocol control register at one time.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8Ctrl | Set the register value of USCI_I2C control register.

Returns
  None

Set UI2C_PROTCTL register to control USCI_I2C bus conditions of START, STOP, SI, ACK.

Definition at line 109 of file usci_i2c.h.

## ◆ UI2C_SET_DATA

#define UI2C_SET_DATA | ( |  | ui2c,
|  |  | u8Data
| ) |  |

This macro writes the data to data register of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8Data | The data which will be written to data register of USCI_I2C module.

Returns
  None

Write a byte data value of UI2C_TXDAT register, then sends address or data to USCI I2C bus

Definition at line 158 of file usci_i2c.h.

## ◆ UI2C_START

#define UI2C_START | ( |  | ui2c | ) |

This macro only set START bit to protocol control register of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

Set the USCI_I2C bus START condition in UI2C_PROTCTL register.

Definition at line 121 of file usci_i2c.h.

## ◆ UI2C_STOP

#define UI2C_STOP | ( |  | ui2c | ) |

This macro only set STOP bit to the control register of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

Set the USCI_I2C bus STOP condition in UI2C_PROTCTL register.

Definition at line 133 of file usci_i2c.h.

## Function Documentation

## ◆ UI2C_ClearIntFlag()

void UI2C_ClearIntFlag | ( | UI2C_T * | ui2c,
|  | uint32_t | u32Mask
| ) |  |

This function clears the interrupt flag of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32Mask | The combination of all related interrupt sources. Each bit corresponds to a interrupt source. This parameter decides which interrupt flags will be cleared. It is combination of: UI2C_TO_INT_MASK UI2C_STAR_INT_MASK UI2C_STOR_INT_MASK UI2C_NACK_INT_MASK UI2C_ARBLO_INT_MASK UI2C_ERR_INT_MASK UI2C_ACK_INT_MASK

Returns
  None

Use this function to clear USCI_I2C interrupt flag when module occurs interrupt event and set flag.

Definition at line 418 of file usci_i2c.c.

## ◆ UI2C_ClearTimeoutFlag()

void UI2C_ClearTimeoutFlag | ( | UI2C_T * | ui2c | ) |

This function clears the time-out flag.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

Clear time-out flag when time-out flag is set.

Definition at line 94 of file usci_i2c.c.

## ◆ UI2C_Close()

void UI2C_Close | ( | UI2C_T * | ui2c | ) |

This function closes the USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

Close USCI_I2C protocol function.

Definition at line 79 of file usci_i2c.c.

## ◆ UI2C_DisableInt()

void UI2C_DisableInt | ( | UI2C_T * | ui2c,
|  | uint32_t | u32Mask
| ) |  |

This function disables the interrupt of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32Mask | The combination of all related interrupt enable bits. Each bit corresponds to an interrupt enable bit. This parameter decides which interrupts will be disabled. It is combination of: UI2C_TO_INT_MASK UI2C_STAR_INT_MASK UI2C_STOR_INT_MASK UI2C_NACK_INT_MASK UI2C_ARBLO_INT_MASK UI2C_ERR_INT_MASK UI2C_ACK_INT_MASK

Returns
  None

The function is used to disable USCI_I2C bus interrupt events.

Definition at line 156 of file usci_i2c.c.

## ◆ UI2C_DisableTimeout()

void UI2C_DisableTimeout | ( | UI2C_T * | ui2c | ) |

This function disables time-out function.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

To disable USCI_I2C bus time-out function.

Definition at line 569 of file usci_i2c.c.

## ◆ UI2C_DisableWakeup()

void UI2C_DisableWakeup | ( | UI2C_T * | ui2c | ) |

This function disables the wakeup function of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  None

To disable USCI_I2C module wake-up function.

Definition at line 601 of file usci_i2c.c.

## ◆ UI2C_EnableInt()

void UI2C_EnableInt | ( | UI2C_T * | ui2c,
|  | uint32_t | u32Mask
| ) |  |

This function enables the interrupt of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32Mask | The combination of all related interrupt enable bits. Each bit corresponds to a interrupt enable bit. This parameter decides which interrupts will be enabled. It is combination of: UI2C_TO_INT_MASK UI2C_STAR_INT_MASK UI2C_STOR_INT_MASK UI2C_NACK_INT_MASK UI2C_ARBLO_INT_MASK UI2C_ERR_INT_MASK UI2C_ACK_INT_MASK

Returns
  None

The function is used to enable USCI_I2C bus interrupt events.

Definition at line 218 of file usci_i2c.c.

## ◆ UI2C_EnableTimeout()

void UI2C_EnableTimeout | ( | UI2C_T * | ui2c,
|  | uint32_t | u32TimeoutCnt
| ) |  |

This function enables time-out function and configures timeout counter.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32TimeoutCnt | Timeout counter. Valid values are between 0~0x3FF

Returns
  None

To enable USCI_I2C bus time-out function and set time-out counter.

Definition at line 554 of file usci_i2c.c.

## ◆ UI2C_EnableWakeup()

void UI2C_EnableWakeup | ( | UI2C_T * | ui2c,
|  | uint8_t | u8WakeupMode
| ) |  |

This function enables the wakeup function of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8WakeupMode | The wake-up mode selection. Valid values are: UI2C_DATA_TOGGLE_WK UI2C_ADDR_MATCH_WK

Returns
  None

To enable USCI_I2C module wake-up function.

Definition at line 587 of file usci_i2c.c.

## ◆ UI2C_GetBusClockFreq()

uint32_t UI2C_GetBusClockFreq | ( | UI2C_T * | ui2c | ) |

This function returns the real bus clock of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  Actual USCI_I2C bus clock frequency.

The function returns the actual USCI_I2C module bus clock.

Definition at line 272 of file usci_i2c.c.

## ◆ UI2C_GetData()

uint32_t UI2C_GetData | ( | UI2C_T * | ui2c | ) |

This function returns the data stored in data register of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.

Returns
  USCI_I2C data.

To read a byte data from USCI_I2C module receive data register.

Definition at line 472 of file usci_i2c.c.

## ◆ UI2C_GetIntFlag()

uint32_t UI2C_GetIntFlag | ( | UI2C_T * | ui2c,
|  | uint32_t | u32Mask
| ) |  |

This function gets the interrupt flag of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32Mask | The combination of all related interrupt sources. Each bit corresponds to a interrupt source. This parameter decides which interrupt flags will be read. It is combination of: UI2C_TO_INT_MASK UI2C_STAR_INT_MASK UI2C_STOR_INT_MASK UI2C_NACK_INT_MASK UI2C_ARBLO_INT_MASK UI2C_ERR_INT_MASK UI2C_ACK_INT_MASK

Returns
  Interrupt flags of selected sources.

Use this function to get USCI_I2C interrupt flag when module occurs interrupt event.

Definition at line 343 of file usci_i2c.c.

## ◆ UI2C_Open()

uint32_t UI2C_Open | ( | UI2C_T * | ui2c,
|  | uint32_t | u32BusClock
| ) |  |

This function makes USCI_I2C module be ready and set the wanted bus clock.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32BusClock | The target bus speed of USCI_I2C module.

Returns
  Actual USCI_I2C bus clock frequency.

Enable USCI_I2C module and configure USCI_I2C module(bus clock, data format).

Definition at line 34 of file usci_i2c.c.

## ◆ UI2C_ReadByte()

uint8_t UI2C_ReadByte | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr
| ) |  |

Read a byte from Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)

Returns
  Read a byte data from Slave

The function is used for USCI_I2C Master to read a byte data from Slave.

Definition at line 1092 of file usci_i2c.c.

## ◆ UI2C_ReadByteOneReg()

uint8_t UI2C_ReadByteOneReg | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint8_t | u8DataAddr
| ) |  |

Specify a byte register address and read a byte from Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u8DataAddr | Specify a address(1 byte) of data read from

Returns
  Read a byte data from Slave

The function is used for USCI_I2C Master specify a byte address that a data byte read from Slave.

Definition at line 1253 of file usci_i2c.c.

## ◆ UI2C_ReadByteTwoRegs()

uint8_t UI2C_ReadByteTwoRegs | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint16_t | u16DataAddr
| ) |  |

Specify two bytes register address and read a byte from Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u16DataAddr | Specify a address(2 byte) of data read from

Returns
  Read a byte data from Slave

The function is used for USCI_I2C Master specify two bytes address that a data byte read from Slave.

Definition at line 1463 of file usci_i2c.c.

## ◆ UI2C_ReadMultiBytes()

uint32_t UI2C_ReadMultiBytes | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint8_t * | rdata,
|  | uint32_t | u32rLen
| ) |  |

Read multi bytes from Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [out] | *rdata | Point to array to store data from Slave
  [in] | u32rLen | How many bytes need to read from Slave

Returns
  A length of how many bytes have been received

The function is used for USCI_I2C Master to read multi data bytes from Slave.

Definition at line 1170 of file usci_i2c.c.

## ◆ UI2C_ReadMultiBytesOneReg()

uint32_t UI2C_ReadMultiBytesOneReg | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint8_t | u8DataAddr,
|  | uint8_t * | rdata,
|  | uint32_t | u32rLen
| ) |  |

Specify a byte register address and read multi bytes from Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u8DataAddr | Specify a address (1 bytes) of data read from
  [out] | *rdata | Point to array to store data from Slave
  [in] | u32rLen | How many bytes need to read from Slave

Returns
  A length of how many bytes have been received

The function is used for USCI_I2C Master specify a byte address that multi data bytes read from Slave.

Definition at line 1359 of file usci_i2c.c.

## ◆ UI2C_ReadMultiBytesTwoRegs()

uint32_t UI2C_ReadMultiBytesTwoRegs | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint16_t | u16DataAddr,
|  | uint8_t * | rdata,
|  | uint32_t | u32rLen
| ) |  |

Specify two bytes register address and read multi bytes from Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u16DataAddr | Specify a address (2 bytes) of data read from
  [out] | *rdata | Point to array to store data from Slave
  [in] | u32rLen | How many bytes need to read from Slave

Returns
  A length of how many bytes have been received

The function is used for USCI_I2C Master specify two bytes address that multi data bytes read from Slave.

Definition at line 1576 of file usci_i2c.c.

## ◆ UI2C_SetBusClockFreq()

uint32_t UI2C_SetBusClockFreq | ( | UI2C_T * | ui2c,
|  | uint32_t | u32BusClock
| ) |  |

This function sets bus clock frequency of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u32BusClock | The target bus speed of USCI_I2C module.

Returns
  Actual USCI_I2C bus clock frequency.

Use this function set USCI_I2C bus clock frequency and return actual bus clock.

Definition at line 301 of file usci_i2c.c.

## ◆ UI2C_SetData()

void UI2C_SetData | ( | UI2C_T * | ui2c,
|  | uint8_t | u8Data
| ) |  |

This function writes a byte data to data register of USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8Data | The data which will be written to data register of USCI_I2C module.

Returns
  None

To write a byte data to transmit data register to transmit data.

Definition at line 487 of file usci_i2c.c.

## ◆ UI2C_SetSlaveAddr()

void UI2C_SetSlaveAddr | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveNo,
|  | uint16_t | u16SlaveAddr,
|  | uint8_t | u8GCMode
| ) |  |

Configure slave address and enable GC mode.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveNo | Slave channel number [0/1]
  [in] | u16SlaveAddr | The slave address.
  [in] | u8GCMode | GC mode enable or not. Valid values are: UI2C_GCMODE_ENABLE UI2C_GCMODE_DISABLE

Returns
  None

To configure USCI_I2C module slave address and GC mode.

Definition at line 506 of file usci_i2c.c.

## ◆ UI2C_SetSlaveAddrMask()

void UI2C_SetSlaveAddrMask | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveNo,
|  | uint16_t | u16SlaveAddrMask
| ) |  |

Configure the mask bit of slave address.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveNo | Slave channel number [0/1]
  [in] | u16SlaveAddrMask | The slave address mask.

Returns
  None

To configure USCI_I2C module slave address mask bit.

Note
  The corresponding address bit is "Don't Care".

Definition at line 532 of file usci_i2c.c.

## ◆ UI2C_Trigger()

void UI2C_Trigger | ( | UI2C_T * | ui2c,
|  | uint8_t | u8Start,
|  | uint8_t | u8Stop,
|  | uint8_t | u8Ptrg,
|  | uint8_t | u8Ack
| ) |  |

This function sets the control bit of the USCI_I2C module.

Parameters

  [in] | ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8Start | Set START bit to USCI_I2C module.
  [in] | u8Stop | Set STOP bit to USCI_I2C module.
  [in] | u8Ptrg | Set PTRG bit to USCI_I2C module.
  [in] | u8Ack | Set ACK bit to USCI_I2C module.

Returns
  None

The function set USCI_I2C control bit of USCI_I2C bus protocol.

Definition at line 112 of file usci_i2c.c.

## ◆ UI2C_WriteByte()

uint8_t UI2C_WriteByte | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint8_t | data
| ) |  |

Write a byte to Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | data | Write a byte data to Slave

Return values

  0 | Write data success
  1 | Write data fail, or bus occurs error events

The function is used for USCI_I2C Master write a byte data to Slave.

Definition at line 620 of file usci_i2c.c.

## ◆ UI2C_WriteByteOneReg()

uint8_t UI2C_WriteByteOneReg | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint8_t | u8DataAddr,
|  | uint8_t | data
| ) |  |

Specify a byte register address and write a byte to Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u8DataAddr | Specify a address (1 byte) of data write to
  [in] | data | A byte data to write it to Slave

Return values

  0 | Write data success
  1 | Write data fail, or bus occurs error events

The function is used for USCI_I2C Master specify a address that data write to in Slave.

Definition at line 763 of file usci_i2c.c.

## ◆ UI2C_WriteByteTwoRegs()

uint8_t UI2C_WriteByteTwoRegs | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint16_t | u16DataAddr,
|  | uint8_t | data
| ) |  |

Specify two bytes register address and Write a byte to Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u16DataAddr | Specify a address (2 byte) of data write to
  [in] | data | Write a byte data to Slave

Return values

  0 | Write data success
  1 | Write data fail, or bus occurs error events

The function is used for USCI_I2C Master specify two bytes address that data write to in Slave.

Definition at line 922 of file usci_i2c.c.

## ◆ UI2C_WriteMultiBytes()

uint32_t UI2C_WriteMultiBytes | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint8_t * | data,
|  | uint32_t | u32wLen
| ) |  |

Write multi bytes to Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | *data | Pointer to array to write data to Slave
  [in] | u32wLen | How many bytes need to write to Slave

Returns
  A length of how many bytes have been transmitted.

The function is used for USCI_I2C Master write multi bytes data to Slave.

Definition at line 694 of file usci_i2c.c.

## ◆ UI2C_WriteMultiBytesOneReg()

uint32_t UI2C_WriteMultiBytesOneReg | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint8_t | u8DataAddr,
|  | uint8_t * | data,
|  | uint32_t | u32wLen
| ) |  |

Specify a byte register address and write multi bytes to Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u8DataAddr | Specify a address (1 byte) of data write to
  [in] | *data | Pointer to array to write data to Slave
  [in] | u32wLen | How many bytes need to write to Slave

Returns
  A length of how many bytes have been transmitted.

The function is used for USCI_I2C Master specify a byte address that multi data bytes write to in Slave.

Definition at line 843 of file usci_i2c.c.

## ◆ UI2C_WriteMultiBytesTwoRegs()

uint32_t UI2C_WriteMultiBytesTwoRegs | ( | UI2C_T * | ui2c,
|  | uint8_t | u8SlaveAddr,
|  | uint16_t | u16DataAddr,
|  | uint8_t * | data,
|  | uint32_t | u32wLen
| ) |  |

Specify two bytes register address and write multi bytes to Slave.

Parameters

  [in] | *ui2c | The pointer of the specified USCI_I2C module.
  [in] | u8SlaveAddr | Access Slave address(7-bit)
  [in] | u16DataAddr | Specify a address (2 bytes) of data write to
  [in] | *data | Pointer to array to write data to Slave
  [in] | u32wLen | How many bytes need to write to Slave

Returns
  A length of how many bytes have been transmitted.

The function is used for USCI_I2C Master specify a byte address that multi data write to in Slave.

Definition at line 1007 of file usci_i2c.c.