37 u32Div = (uint32_t) (((
SystemCoreClock * 10)/(u32BusClock * 4) + 5) / 10 - 1);
41 i2c->
I2CON |= I2C_I2CON_ENSI_Msk;
54 SYS->IPRSTC2 |= SYS_IPRSTC2_I2C_RST_Msk;
55 SYS->IPRSTC2 &= ~SYS_IPRSTC2_I2C_RST_Msk;
58 i2c->
I2CON &= ~I2C_I2CON_ENSI_Msk;
68 i2c->
I2CTOC |= I2C_I2CTOC_TIF_Msk;
80void I2C_Trigger(
I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack)
103 i2c->
I2CON &= ~I2C_I2CON_EI_Msk;
113 i2c->
I2CON |= I2C_I2CON_EI_Msk;
123 uint32_t u32Divider =
I2C->I2CLK;
138 u32Div = (uint32_t) (((
SystemCoreClock * 10)/(u32BusClock * 4) + 5) / 10 - 1);
153 return ( (i2c->
I2CON & I2C_I2CON_SI_Msk) == I2C_I2CON_SI_Msk ? 1:0 );
200 i2c->
I2CADDR0 = (u8SlaveAddr << 1) | u8GCMode;
203 i2c->
I2CADDR1 = (u8SlaveAddr << 1) | u8GCMode;
206 i2c->
I2CADDR2 = (u8SlaveAddr << 1) | u8GCMode;
209 i2c->
I2CADDR3 = (u8SlaveAddr << 1) | u8GCMode;
212 i2c->
I2CADDR0 = (u8SlaveAddr << 1) | u8GCMode;
228 i2c->
I2CADM0 = u8SlaveAddrMask << 1;
231 i2c->
I2CADM1 = u8SlaveAddrMask << 1;
234 i2c->
I2CADM2 = u8SlaveAddrMask << 1;
237 i2c->
I2CADM3 = u8SlaveAddrMask << 1;
240 i2c->
I2CADM0 = u8SlaveAddrMask << 1;
253 i2c->
I2CTOC |= I2C_I2CTOC_DIV4_Msk;
255 i2c->
I2CTOC &= ~I2C_I2CTOC_DIV4_Msk;
257 i2c->
I2CTOC |= I2C_I2CTOC_ENTI_Msk;
267 i2c->
I2CTOC &= ~I2C_I2CTOC_ENTI_Msk;
277 i2c->
I2CON2 |= I2C_I2CON2_WKUPEN_Msk;
287 i2c->
I2CON2 &= ~I2C_I2CON2_WKUPEN_Msk;
NUC029FAE peripheral access layer header file. This file contains all the peripheral register's defin...
void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask)
Configure the mask of slave address. The corresponding address bit is "Don't Care".
void I2C_Close(I2C_T *i2c)
This function closes the I2C module.
uint32_t I2C_SetBusClockFreq(I2C_T *i2c, uint32_t u32BusClock)
This function enables the interrupt (EI bit) of I2C module.
void I2C_Trigger(I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack)
This function sets the control bit of the I2C module.
void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout)
This function enables timeout function and configures DIV4 function to support long timeout.
void I2C_ClearTimeoutFlag(I2C_T *i2c)
This function clears the timeout flag.
void I2C_SetSlaveAddr(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddr, uint8_t u8GCMode)
Configure slave address and enable GC mode.
void I2C_SetData(I2C_T *i2c, uint8_t u8Data)
This function writes the data to data register of I2C module.
uint32_t I2C_GetBusClockFreq(I2C_T *i2c)
This function returns the real bus clock of I2C module.
void I2C_EnableInt(I2C_T *i2c)
This function enables the interrupt (EI bit) of I2C module.
void I2C_DisableWakeup(I2C_T *i2c)
This function disables the wakeup function of I2C module.
uint32_t I2C_GetStatus(I2C_T *i2c)
This function returns the status of I2C module.
void I2C_DisableInt(I2C_T *i2c)
This function disables the interrupt (EI bit) of I2C module.
uint32_t I2C_GetData(I2C_T *i2c)
This function returns the data stored in data register of I2C module.
void I2C_EnableWakeup(I2C_T *i2c)
This function enables the wakeup function of I2C module.
uint32_t I2C_GetIntFlag(I2C_T *i2c)
This function gets the interrupt flag (SI bit) of I2C module.
uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock)
This function make I2C module be ready and set the wanted bus clock.
void I2C_DisableTimeout(I2C_T *i2c)
This function disables timeout function.
#define I2C
Pointer to I2C register structure.
#define SYS
Pointer to SYS register structure.