K82 : cancel I2C transfer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

K82 : cancel I2C transfer

585 次查看
EugeneHiihtaja
Senior Contributor I

Hello !

I should be able to cancel any ongoing transaction  for I2C Master and Slave interfaces.

1.

In case of slave I'm using I2C_SlaveTransferAbort() what should cancel any read/write operation on I2C bus.

Is this OK ?

2. For I2C master I'm using freeRTOS wrappers and they dosn't have any API for aborting transfers.

 Should I use I2C_MasterStop(I2C_Type *base) ?

I'm using interrupt driver I2C master and slave interfaces and nonblocking transfers. DMA is disabled.

Regards,

Eugene

0 项奖励
1 回复

493 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Eugene Hiihtaja,

    

   1.In case of slave I'm using I2C_SlaveTransferAbort() what should cancel any read/write operation on I2C bus.

   Answer:

      You can check the I2C_SlaveTransferAbort function.

void I2C_SlaveTransferAbort(I2C_Type *base, i2c_slave_handle_t *handle)
{
    assert(handle);

    if (handle->isBusy)
    {
        /* Disable interrupts. */
        I2C_DisableInterrupts(base, kIrqFlags);

        /* Reset transfer info. */
        memset(&handle->transfer, 0, sizeof(handle->transfer));

        /* Reset the state to idle. */
        handle->isBusy = false;
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 It disable the interrupt, so if your slave is using the interrupt to receive and write the I2C data, of course this code can used to cancel the operation.

2. For I2C master I'm using freeRTOS wrappers and they dosn't have any API for aborting transfers.

 Should I use I2C_MasterStop(I2C_Type *base) ?

Answer:About the master, you can use  I2C_MasterTransferAbort to stop the sending, I2C_MasterStop just send the STOP signal to the I2C bus.

Wish it helps you!

If you still have question about it, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励