63#define UI2C_CTL_PTRG 0x20UL
64#define UI2C_CTL_STA 0x08UL
65#define UI2C_CTL_STO 0x04UL
66#define UI2C_CTL_AA 0x02UL
71#define UI2C_GCMODE_ENABLE (1U)
72#define UI2C_GCMODE_DISABLE (0U)
77#define UI2C_DATA_TOGGLE_WK (0x0U << UI2C_WKCTL_WKADDREN_Pos)
78#define UI2C_ADDR_MATCH_WK (0x1U << UI2C_WKCTL_WKADDREN_Pos)
83#define UI2C_TO_INT_MASK (0x001U)
84#define UI2C_STAR_INT_MASK (0x002U)
85#define UI2C_STOR_INT_MASK (0x004U)
86#define UI2C_NACK_INT_MASK (0x008U)
87#define UI2C_ARBLO_INT_MASK (0x010U)
88#define UI2C_ERR_INT_MASK (0x020U)
89#define UI2C_ACK_INT_MASK (0x040U)
109#define UI2C_SET_CONTROL_REG(ui2c, u8Ctrl) ((ui2c)->PROTCTL = ((ui2c)->PROTCTL & ~0x2EU) | (u8Ctrl))
121#define UI2C_START(ui2c) ((ui2c)->PROTCTL = ((ui2c)->PROTCTL & ~UI2C_PROTCTL_PTRG_Msk) | UI2C_PROTCTL_STA_Msk)
133#define UI2C_STOP(ui2c) ((ui2c)->PROTCTL = ((ui2c)->PROTCTL & ~0x2E) | (UI2C_PROTCTL_PTRG_Msk | UI2C_PROTCTL_STO_Msk))
145#define UI2C_GET_DATA(ui2c) ((ui2c)->RXDAT)
158#define UI2C_SET_DATA(ui2c, u8Data) ((ui2c)->TXDAT = (u8Data))
171#define UI2C_GET_TIMEOUT_FLAG(ui2c) (((ui2c)->PROTSTS & UI2C_PROTSTS_TOIF_Msk) == UI2C_PROTSTS_TOIF_Msk ? 1:0)
184#define UI2C_GET_WAKEUP_FLAG(ui2c) (((ui2c)->WKSTS & UI2C_WKSTS_WKF_Msk) == UI2C_WKSTS_WKF_Msk ? 1:0)
196#define UI2C_CLR_WAKEUP_FLAG(ui2c) ((ui2c)->WKSTS = UI2C_WKSTS_WKF_Msk)
208#define UI2C_DISABLE_10BIT_ADDR_MODE(ui2c) ((ui2c)->PROTCTL &= ~(UI2C_PROTCTL_ADDR10EN_Msk))
220#define UI2C_ENABLE_10BIT_ADDR_MODE(ui2c) ((ui2c)->PROTCTL |= UI2C_PROTCTL_ADDR10EN_Msk)
232#define UI2C_GET_PROT_STATUS(ui2c) ((ui2c)->PROTSTS)
250#define UI2C_CLR_PROT_INT_FLAG(ui2c,u32IntTypeFlag) ((ui2c)->PROTSTS = (u32IntTypeFlag))
268#define UI2C_ENABLE_PROT_INT(ui2c, u32IntSel) ((ui2c)->PROTIEN |= (u32IntSel))
286#define UI2C_DISABLE_PROT_INT(ui2c, u32IntSel) ((ui2c)->PROTIEN &= ~ (u32IntSel))
292void UI2C_Trigger(
UI2C_T *ui2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Ptrg, uint8_t u8Ack);
@ MASTER_SEND_H_RD_ADDRESS
@ MASTER_SEND_H_WR_ADDRESS
@ MASTER_SEND_REPEAT_START
void UI2C_EnableInt(UI2C_T *ui2c, uint32_t u32Mask)
This function enables the interrupt of USCI_I2C module.
uint32_t UI2C_GetIntFlag(UI2C_T *ui2c, uint32_t u32Mask)
This function gets the interrupt flag of USCI_I2C module.
uint32_t UI2C_Open(UI2C_T *ui2c, uint32_t u32BusClock)
This function makes USCI_I2C module be ready and set the wanted bus clock.
void UI2C_DisableWakeup(UI2C_T *ui2c)
This function disables the wakeup function of USCI_I2C module.
uint32_t UI2C_GetData(UI2C_T *ui2c)
This function returns the data stored in data register of USCI_I2C module.
void UI2C_SetSlaveAddr(UI2C_T *ui2c, uint8_t u8SlaveNo, uint16_t u16SlaveAddr, uint8_t u8GCMode)
Configure slave address and enable GC mode.
uint8_t UI2C_WriteByte(UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t data)
Write a byte to Slave.
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.
void UI2C_DisableTimeout(UI2C_T *ui2c)
This function disables time-out function.
uint8_t UI2C_ReadByteTwoRegs(UI2C_T *ui2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr)
Specify two bytes register address and read a byte from Slave.
void UI2C_SetData(UI2C_T *ui2c, uint8_t u8Data)
This function writes a byte data to data register of USCI_I2C module.
uint8_t UI2C_ReadByteOneReg(UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr)
Specify a byte register address and read a byte from Slave.
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.
void UI2C_EnableTimeout(UI2C_T *ui2c, uint32_t u32TimeoutCnt)
This function enables time-out function and configures timeout counter.
void UI2C_EnableWakeup(UI2C_T *ui2c, uint8_t u8WakeupMode)
This function enables the wakeup function of USCI_I2C module.
uint32_t UI2C_WriteMultiBytes(UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t *data, uint32_t u32wLen)
Write multi bytes to Slave.
void UI2C_DisableInt(UI2C_T *ui2c, uint32_t u32Mask)
This function disables the interrupt of USCI_I2C module.
void UI2C_ClearIntFlag(UI2C_T *ui2c, uint32_t u32Mask)
This function clears the interrupt flag of USCI_I2C module.
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.
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.
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.
uint8_t UI2C_ReadByte(UI2C_T *ui2c, uint8_t u8SlaveAddr)
Read a byte from Slave.
uint32_t UI2C_GetBusClockFreq(UI2C_T *ui2c)
This function returns the real bus clock of USCI_I2C module.
void UI2C_ClearTimeoutFlag(UI2C_T *ui2c)
This function clears the time-out flag.
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.
void UI2C_Close(UI2C_T *ui2c)
This function closes the USCI_I2C module.
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.
void UI2C_SetSlaveAddrMask(UI2C_T *ui2c, uint8_t u8SlaveNo, uint16_t u16SlaveAddrMask)
Configure the mask bit of slave address.
uint32_t UI2C_SetBusClockFreq(UI2C_T *ui2c, uint32_t u32BusClock)
This function sets bus clock frequency of USCI_I2C module.
uint32_t UI2C_ReadMultiBytes(UI2C_T *ui2c, uint8_t u8SlaveAddr, uint8_t *rdata, uint32_t u32rLen)
Read multi bytes from Slave.