commit | 6b0b9c2f3ca1b6cce24bac5572d80521ad7024ac | [log] [tgz] |
---|---|---|
author | Christoph Klee <chklee@google.com> | Wed Feb 28 00:51:52 2024 +0000 |
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Feb 28 00:51:52 2024 +0000 |
tree | 72422f2e9b334c1ad826f20e36b7d64c2da7d9f1 | |
parent | 3ca23db2114f54240f7d045a5a6723281a67ce19 [diff] |
pw_stream_uart_mcuxpresso: Implement DoRead DMA This change implements the DoRead version for USART DMA transfers. The DoRead function copies data from the RX ring buffer into the caller provided buffer. The RX ring buffer gets filled through DMA RX requests that are getting started when the UsartStreamDmaMcuxpresso::Init function executes. Each RX transaction is usually kUsartDmaTransferCount bytes long, but may be truncated to deal with the wrap around of the ring buffer, or when a caller's DoRead request couldn't be completely satisifed by the ring buffer itself, but further transactions have to complete. If a caller waits for transactions to complete to satisfy its request, it depends whether the current transaction will satisfy the request, or whether at least one more transaction in addition to the in-flight transaction have to complete. If only the current transaction has to complete, we will abort the current transaction, so that a transaction can be started that waits to receive exactly as many bytes as are required by the caller. Since the abort may take some time, it might be that the entire transaction still completes. If that is the case the DMA interrupt will be delivered and the callback will be executed. If the abort request completes before the transaction has completed, the transfer's dataSize will be fixed up to account for the data that hasn't been transferred yet and the completion_size will be set, so that the completion callback can be executed by the DoRead caller itself and wake up the DoRead caller when the remaining data has been received. If more than one transaction is required to satisfy the DoRead request, we don't need to abort the current transaction, since we know that we can safely set completion_size and that it will be picked up by the RX completion callback. Change-Id: Ib5764edfd630a8d6cd21e1d82108c135a7bd0df4 Bug: 325514698 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/192893 Commit-Queue: Christoph Klee <chklee@google.com> Reviewed-by: Austin Foxley <afoxley@google.com>
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/.