Hello Mike,
- "And the API needs to be written such that it hits a Completion State on a I2C stop rather than rxData counting down to 0." - Yes, this demo just shows raData down to 0. If you want to hit a completion state on Stop, just need to add the "case kI2C_SlaveDeselectedEvent " in i2c_slave_callback function, for example :
In i2c salve callback function:
static void i2c_slave_callback(I2C_Type *base, volatile i2c_slave_transfer_t *xfer, void *userData)
{
switch (xfer->event)
{
...
case kI2C_SlaveDeselectedEvent:
g_SlaveCompletionFlag = true;
// Your own code
break;
...
}
}
And in transfer function. we need add kI2C_SlaveDeselectedEvent:
/* Start accepting I2C transfers on the I2C slave peripheral */
reVal = I2C_SlaveTransferNonBlocking(EXAMPLE_I2C_SLAVE, &g_s_handle,
kI2C_SlaveAddressMatchEvent | kI2C_SlaveCompletionEvent|kI2C_SlaveDeselectedEvent);
- when Master send Stop, the Slave Deselected flag of STAT will set to 1 , then in the function of I2C_SlaveTransferHandleIRQ invoke kI2C_SlaveDeselectedEvent .
Please check the driver code :
void I2C_SlaveTransferHandleIRQ(I2C_Type *base, i2c_slave_handle_t *handle)
{
uint32_t i2cStatus = base->STAT;
if (i2cStatus & I2C_STAT_SLVDESEL_MASK)
{
I2C_SlaveInvokeEvent(base, handle, kI2C_SlaveDeselectedEvent);
I2C_SlaveClearStatusFlags(base, I2C_STAT_SLVDESEL_MASK);
}
...
}
Also have a look at the LPC546xx Reference Manual page 445.

Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------