57 SYS->IPRST2 &= ~SYS_IPRST2_I2C0RST_Msk;
62 SYS->IPRST2 &= ~SYS_IPRST2_I2C1RST_Msk;
66 i2c->
CTL &= ~I2C_CTL_I2CEN_Msk;
88void I2C_Trigger(
I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack)
102 i2c->
CTL = u32Val | u32Reg;
112 i2c->
CTL &= ~I2C_CTL_INTEN_Msk;
132 uint32_t u32Divider = i2c->
CLKDIV;
149 uint32_t
volatile u32Pclk;
160 u32Div = (uint32_t) (((u32Pclk * 10)/(u32BusClock * 4) + 5) / 10 - 1);
163 return ( u32Pclk / ((u32Div+1)<<2) );
234 i2c->
ADDR0 = (u8SlaveAddr << 1) | u8GCMode;
237 i2c->
ADDR1 = (u8SlaveAddr << 1) | u8GCMode;
240 i2c->
ADDR0 = (u8SlaveAddr << 1) | u8GCMode;
256 i2c->
ADDRMSK0 = u8SlaveAddrMask << 1;
259 i2c->
ADDRMSK1 = u8SlaveAddrMask << 1;
262 i2c->
ADDRMSK0 = u8SlaveAddrMask << 1;
277 i2c->
TOCTL &= ~I2C_TOCTL_TOCDIV4_Msk;
289 i2c->
TOCTL &= ~I2C_TOCTL_TOCEN_Msk;
309 i2c->
CTL2 &= ~I2C_CTL2_WKUPEN_Msk;
NANO103 peripheral access layer header file. This file contains all the peripheral register's definit...
#define I2C_INTSTS_TOIF_Msk
#define I2C_CTL_INTEN_Msk
#define I2C_INTSTS_INTSTS_Msk
#define I2C_TOCTL_TOCEN_Msk
#define I2C_CTL2_WKUPEN_Msk
#define I2C_CTL_I2CEN_Msk
#define I2C_TOCTL_TOCDIV4_Msk
uint32_t CLK_GetPCLK1Freq(void)
This function get PCLK1 frequency. The frequency unit is Hz.
uint32_t CLK_GetPCLK0Freq(void)
This function get PCLK0 frequency. The frequency unit is Hz.
#define SYS_IPRST2_I2C1RST_Msk
#define SYS_IPRST2_I2C0RST_Msk
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 sets bus frequency 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 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.
void I2C_ClearIntFlag(I2C_T *i2c)
This function clears the interrupt flag of I2C module.
uint32_t I2C_GetIntFlag(I2C_T *i2c)
This function gets the interrupt flag 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 I2C0
Pointer to I2C0 register structure.
#define SYS
Pointer to SYS register structure.
#define I2C0_BASE
I2C0 register base address.