void I2C0_IRQHandler(void) {
if (Chip_I2C_IsMasterActive(I2C0)) {
Chip_I2C_MasterStateHandler(I2C0);
}
else {
Chip_I2C_SlaveStateHandler(I2C0);
}
}
void test(void) {
Chip_IOCON_Init(LPC_IOCON);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 30, IOCON_FUNC4 | IOCON_OPENDRAIN_EN);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 31, IOCON_FUNC4 | IOCON_OPENDRAIN_EN);
Chip_I2C_Init(I2C0);
Chip_I2C_SetClockRate(I2C0, 400000);
Chip_I2C_SetMasterEventHandler(I2C0, Chip_I2C_EventHandler);
NVIC_ClearPendingIRQ(I2C0_IRQn);
NVIC_EnableIRQ(I2C0_IRQn);
static uint8_t buf[10];
static I2C_XFER_T xfer={.slaveAddr=I2C_ADDR_7BIT, .txBuff=buf, .txSz=sizeof(buf)};
Chip_I2C_MasterSend(I2C0, xfer.slaveAddr, xfer.txBuff, xfer.txSz);
} |