2019-07-31 08:03 AM
When I use the I2C DMA receive mode, how could I know the data has been received? I found if I use the delay to check the data, it seems it could work, but actually, we don't know when the data will be coming. so there should have a mechanism to tell the user app that the data has been received. I tried to use the call back function (eg. HAL_I2C_SlaveRxCpltCallback() ), but it seems no one could be tracing in.
2019-07-31 12:39 PM
You can check the CNDTR register of the DMA channel you are using.
you can use:
__HAL_DMA_GET_COUNTER(hi2cN.hdmarx);
or
hi2cN.hdmarx->Instance->CNDTR;
If nothing has been received it will hold the dma rx buffersize - 1
it will count down to zero as the buffer fills.
2019-07-31 04:39 PM
The interesting thing if we’re going to use DMA, it also means we don’t want to pending with polling status, just want to do something else, and after DMA completion, it could send out a semaphore to back.
2019-08-02 10:03 AM
DMA rx complete is not going to help much unless you have fixed message size.
2019-08-03 06:45 AM
Normally it can be done by combining DMA/interrupt buffer's "Rx complete" with I2C peripherals STOP interrupt. With HAL... Well, it's one more reason to not use that crippled and bloated bug library.