NOTE: Only if all the counters are in same size (here uint32_t), the calculation is safe (when the shared register overflows). NOTE: If Slave resets the counters, Master needs to reset its counter accordingly. NOTE: You can also implement your own synchronization method, BUT DO MIND the parallelled issue. To write the size of the TX buffer that is loaded to the hardware (DMA) This callback function will be called when each TX buffer is loaded to the DMA. - For Slave, ``s_tx_ready_buf_size`` is a counter of the loaded buffer size and will be written to the pre-negotiated shared register. - For Master, it also needs a counter for the size of buffers that have been received. - The difference between these 2 counters will be the number that Master can read, without concern of reading meaningless data. There are 3 conditions: 1. Master reads same length as Slave loaded size. 2. If Master reads longer than the Slave loaded size, the extra bits that Master reads from the bus would be meaningless. 3. If Master reads shorter than the Slave loaded size, Master should still increase its counter by the Slave loaded size (here ``event->trans->len``), because the extra bits that Slave sends to the bus would be missed by the Master.
To write the number of the RX buffers that are loaded to the hardware (DMA) This callback function will be called when each RX buffer is loaded to the DMA. - For Slave, ``s_rx_ready_buf_num`` is a counter for the loaded buffer and will be written to the pre-negotiated shared register - For Master, it also needs a counter for the number of buffers that have been sent out. - The difference between these 2 counters will be the number that Master can send.