static void SetupI2C(void) { I2C0_BASE = vmm_find_iomap("SOC_I2C_0_REGS"); /* Enable the clock for I2C0 */ I2C0ModuleClkConfig(); I2CPinMuxSetup(0); /* Put i2c in reset/disabled state */ I2CMasterDisable(I2C0_BASE); /* Disable auto Idle functionality */ I2CAutoIdleDisable(I2C0_BASE); /* Configure i2c bus speed to 100khz */ I2CMasterInitExpClk(I2C0_BASE, 48000000, 12000000, 100000); /* Set i2c slave address */ I2CMasterSlaveAddrSet(I2C0_BASE, I2C_SLAVE_ADDR); /* Bring I2C out of reset */ I2CMasterEnable(I2C0_BASE); }
/** * \brief Initializes the I2C interface for a codec * * \param baseAddr Base Address of the I2C Module Registers which * is used for the codec * slaveAddr Slave Address of the codec * * Note: This API enables the system interrupt for the given I2C module only. * It does not do any pin multiplexing or global interrupt enabling. * This shall be called only after AINTC initialization. * * \return None. * **/ void I2CCodecIfInit(unsigned int baseAddr, unsigned int slaveAddr) { /* Put i2c in reset/disabled state */ I2CMasterDisable(baseAddr); /* Disable the auto idle functionality */ I2CAutoIdleDisable(baseAddr); /* Configure i2c bus speed to 100khz */ I2CMasterInitExpClk(SOC_I2C_1_REGS, 48000000, 12000000, 100000); /* Set i2c slave address */ I2CMasterSlaveAddrSet(baseAddr, slaveAddr); I2CMasterEnable(baseAddr); IntRegister(SYS_INT_I2C1INT, I2CCodecIsr); IntPrioritySet(SYS_INT_I2C1INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_I2C1INT); }