Hi @Maciek,
1. Yes, that is correct - for the transfer to be considered complete and the received data to be accurate, the user callback function must be called - for that a synchronization mechanism between the data transfer block and the callback block should be used - a flag to signal that the callback has completed, otherwise it will most probably result in an LPI2C Busy Status, or the data will be outdated.
2. The problem here is that you need to make sure that the interrupt routine where the Receive is handled has finished (more precisely, the handle state has been reset to idle and transmission has thus completed - the reasoning is the same as in 1.) This may not happen immediately after the PC returns from the LPI2C_MasterTransferNonBlocking function. The callback function is invoked in the interrupt handler immediately after the LPI2C state has been reset to idle - so checking if the callback has been called should be a guarantee that the data is now available for use.
We plan to do a refactorization for the LPI2C Master Transfer in order to simplify the transmission: we are investigating the possibility of returning the received data using the Callback block instead of Data Transfer as you suggested - the Data Transfer block would then be used to update the transfer structure and start the transmission. Another approach we have in mind is adding the LPI2C_MasterTransferBlocking from the SDK, for the case where the user doesn't enable the Callback option in ConfigTools - this way the synchronization will be handled by the API, but you can still use the SDK transfer structure (you could try to use custom code to generate this behavior, to see if would benefit more your application).
3. The transfer status output will contain the last completed transfer status returned by the callback function - so yes, it can be considered outdated for the transfer that is in progress until the callback function is called and completed again.
4. You are correct about the operation scheme. In the current version of the toolbox, you can configure the subAddress, subaddressSize, and the flags fields of the master transfer structure with MCUXpresso ConfigTools, but this allows for only one initialization at the beginning of the program - we are aware of this limitation and plan to add those fields for next release as editable options in the LPI2C block, so that they can be updated as needed during transmission. My guess is that this update should solve the issue with the dummy transfers presented in (2), am I correct?
5. Yes, the approach is similar for the LPSPI peripheral.
Kind Regards,
Ioana