Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: serial: uart_async_rx: Improvements in uart_async_rx module #68403

Merged
merged 5 commits into from
Mar 26, 2024

Conversation

nordic-krch
Copy link
Contributor

Add few improvements.

@zephyrbot zephyrbot added area: UART Universal Asynchronous Receiver-Transmitter area: Shell Shell subsystem labels Feb 1, 2024
Removing a field which was redundant. It was only incremented but
never read.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Add buffer releasing to consuming function to allow better buffer
utilization since buffer is available earlier.

Note that releasing in claiming function is still needed as there
are cases when there are empty but completed buffers and those
need to be consumed in claiming phase.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Return availability of free buffers after data is consumed. This
information may be important for the module using uart_async_rx to
schedule next reception if there is a new buffer available.

Signed-off-by: Krzysztof Chruściński <[email protected]>
There was a wrong order of conditions checking. First indexes were
compared and then completed flag was checked. It was possible that
after checking first condition context is preempted and new data
is written to the buffer and completed flag is set. In that case
both conditions are met but data added in preemption is dropped.
In order to avoid that completed flag must be checked first.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Since there is only one consumer of the data stored in the buffers,
it is enough to have one read index variable which can be stored in
the data associated with the module and not in the buffer space (where
there is a read index for each buffer).

Additionally, we can safely assume that module works with small buffers
so 127 byte limit is enough. Based on that assumption completed flag
can be stored on a single byte together with write index. After this
change, control data for each buffer takes 1 byte (3 bytes previously).

Signed-off-by: Krzysztof Chruściński <[email protected]>
@nashif nashif merged commit 8bc5111 into zephyrproject-rtos:main Mar 26, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Shell Shell subsystem area: UART Universal Asynchronous Receiver-Transmitter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants