I want to make LPC82X to be a slave device.But when I study the the sample code I download,I Can't unstand the API function "Chip_I2CS_SetSlaveAddr".
The following is sample code:
static void setupI2CSlave(void)
{
/* Some common I2C init was performed in setupI2CMaster(), so it doesn't need to be done again for the slave setup. */
/* Emulated EEPROM 0 is on slave index 0 */
Chip_I2CS_SetSlaveAddr(LPC_I2C_PORT, 0, EEPROM0SLVADD);
/* Disable Qualifier for Slave Address 0 */
Chip_I2CS_SetSlaveQual0(LPC_I2C_PORT, false, 0);
/* Enable Slave Address 0 */
Chip_I2CS_EnableSlaveAddr(LPC_I2C_PORT, 0);
/* Emulated EEPROM 1 is on slave index 1 */
Chip_I2CS_SetSlaveAddr(LPC_I2C_PORT, 1, EEPROM1SLVADD);
/* Enable Slave Address 1 */
Chip_I2CS_EnableSlaveAddr(LPC_I2C_PORT, 1);
/* Clear interrupt status and enable slave interrupts */
Chip_I2CS_ClearStatus(LPC_I2C_PORT, I2C_STAT_SLVDESEL);
Chip_I2C_EnableInt(LPC_I2C_PORT, I2C_INTENSET_SLVPENDING | I2C_INTENSET_SLVDESEL);
/* Enable I2C slave interface */
Chip_I2CS_Enable(LPC_I2C_PORT);
My confusion is that one I2C port can be used as two slave devices?Just only set two different slave addresses?
Original Attachment has been moved to: periph_i2cs_interrupt.zip