drivers: serial: stm32: Fixes uart_event_tx len calculation
Resetting the dma_tx.buffer_length after the dma_tx.counter calculation, instead of before. We need to reset the buffer_length when the transmission is finished, but in order to give the correct value to the uart_event_tx struct, we use the dma_tx.buffer_length in the calculation of the dma_tx.counter, used for the len of the event (number of bytes sent). I found this problem, when I wanted to use the uart_event_tx.len for freeing the used space inside a ring buffer (ring_buf_get_finish), and it didn't work, I logged the values of the uart_event_tx struct, and found out it always was 0, because the buffer_length was 0, and the whole buffer was transmitted (stat.pending_length also 0). Signed-off-by: Prema Jonathan van Win <jonathanvanwin@gmail.com>
This commit is contained in:
parent
53d00dc29f
commit
76dee395d8
1 changed files with 2 additions and 2 deletions
|
@ -923,14 +923,14 @@ void uart_stm32_dma_tx_cb(const struct device *dma_dev, void *user_data,
|
|||
|
||||
(void)k_work_cancel_delayable(&data->dma_tx.timeout_work);
|
||||
|
||||
data->dma_tx.buffer_length = 0;
|
||||
|
||||
if (!dma_get_status(data->dma_tx.dma_dev,
|
||||
data->dma_tx.dma_channel, &stat)) {
|
||||
data->dma_tx.counter = data->dma_tx.buffer_length -
|
||||
stat.pending_length;
|
||||
}
|
||||
|
||||
data->dma_tx.buffer_length = 0;
|
||||
|
||||
irq_unlock(key);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue