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: nrfx_uarte: UART shim based on nrfx_uarte driver #65155

Merged
merged 8 commits into from Jan 18, 2024

Conversation

nordic-krch
Copy link
Contributor

PR adds new Nordic UART shim which is based on the nrfx_uarte driver. Legacy shim is kept for now and can be used after CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=y.

New shim implements only polling and asynchronous API. Interrupt driven API is implemented via generic asynchronous to interrupt driven adaptation layer. New shim is using different approach to RX bytes counting (legacy shim was using RXDRDY interrupt or dedicated TIMER peripheral).

New approach changes the behavior of the RX while being compliant with the API. When there is no RX activity for the specified amount of time UART RX is restarted (stopped with ENDRX_STARTRX short being set). With this approach there is no need for byte counting since DMA transfer ends on timeout and AMOUNT register is updated. However, it means that every UART_RX_RDY event comes with the new buffer (offset in uart_rx_event is always 0).

PR contains asynchronous to interrupt driven adaptation layer which is using uart_async_rx helper added by #63967.

PR is based on #65113 and #63967.

@nordic-krch nordic-krch force-pushed the new_nrfx_uarte branch 2 times, most recently from b027a7a to 83e124b Compare November 15, 2023 14:30
@zephyrbot
Copy link
Collaborator

zephyrbot commented Nov 15, 2023

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_nordic DNM This PR should not be merged (Do Not Merge) labels Nov 15, 2023
@nordic-krch nordic-krch force-pushed the new_nrfx_uarte branch 3 times, most recently from a6e25db to c92d171 Compare November 20, 2023 12:28
@nordic-krch nordic-krch force-pushed the new_nrfx_uarte branch 4 times, most recently from 946e8e6 to d58bbf3 Compare December 13, 2023 15:39
@nordic-krch nordic-krch marked this pull request as ready for review January 3, 2024 14:19
@zephyrbot zephyrbot added area: Base OS Base OS Library (lib/os) platform: nRF Nordic nRFx area: UART Universal Asynchronous Receiver-Transmitter labels Jan 3, 2024
drivers/serial/Kconfig Outdated Show resolved Hide resolved
anangl
anangl previously approved these changes Jan 17, 2024
Comment on lines 878 to 879
if ((IS_INT_DRIVEN_API(dev) || IS_POLLING_API(dev)) &&
!(cfg->flags & UARTE_CFG_FLAG_NO_RX)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with PM_DEVICE_ACTION_RESUME:

Suggested change
if ((IS_INT_DRIVEN_API(dev) || IS_POLLING_API(dev)) &&
!(cfg->flags & UARTE_CFG_FLAG_NO_RX)) {
if (!IS_ASYNC_API(dev) && !(cfg->flags & UARTE_CFG_FLAG_NO_RX)) {


static const struct uart_async_to_irq_config *get_config(const struct device *dev)
{
const struct uart_async_to_irq_config **config = dev->config;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed that one const in my previous comment.

Suggested change
const struct uart_async_to_irq_config **config = dev->config;
const struct uart_async_to_irq_config *const *config = dev->config;

@nordic-krch nordic-krch force-pushed the new_nrfx_uarte branch 2 times, most recently from 560afe1 to d882b8e Compare January 17, 2024 11:56
@zephyrbot zephyrbot added the platform: nRF BSIM Nordic Semiconductors, nRF BabbleSim label Jan 17, 2024
Add adaptation layer which allows to provide interrupt driven
API for drivers which exposes only asynchronous API.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Since it takes 400 bytes of code and it is rarely used disable
by default this feature.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add Kconfig options to new configuration flags for nrfx_uarte.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
gmarull
gmarull previously approved these changes Jan 17, 2024
Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this should be fixed better https://github.com/zephyrproject-rtos/zephyr/pull/65155/files#r1450353386, but let's move on.

k_msleep(1);
}
Z_SPIN_DELAY(3);
} while (err != NRFX_ERROR_BUSY);
Copy link
Member

@aescolar aescolar Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a bug? shouldn't it be
} while (err != NRFX_SUCCESS); ?
Otherwise the same byte would be enqueued again if nrfx_uarte_tx() enqueued it right away, or?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be while (err == NRFX_ERROR_BUSY).

Copy link
Member

@anangl anangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new shim which is based on nrfx driver.

Legacy shim is kept for transition period. It can be used after
setting CONFIG_UART_NRFX_UARTE_LEGACY_SHIM.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Align test configurations to the new uart driver based on nrfx_uarte.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add configuration which tests legacy nrf uart driver.
Prevent tests on nrf52_bsim of the new driver (it is requiring
adjustments for the simulation). It will be fixed by another
patch.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
New nrf uart shim requires addiotional work around PM. Use legacy
version for those tests until it is fixed.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
New UART shim must be adapted to work in the simulated environment.
Use legacy version until it is fixed.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
@carlescufi carlescufi merged commit e2dccab into zephyrproject-rtos:main Jan 18, 2024
22 checks passed
magp-nordic pushed a commit to magp-nordic/zephyr that referenced this pull request Jan 18, 2024
Add adaptation layer which allows to provide interrupt driven
API for drivers which exposes only asynchronous API.

Cherry-picked from zephyrproject-rtos#65155. This commit should not be reviewed in this PR.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
magp-nordic pushed a commit to magp-nordic/zephyr that referenced this pull request Jan 18, 2024
Since it takes 400 bytes of code and it is rarely used disable
by default this feature.

Cherry picked from zephyrproject-rtos#65155. This commit should not be reviewed in this PR.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
magp-nordic pushed a commit to magp-nordic/zephyr that referenced this pull request Jan 18, 2024
Add new shim which is based on nrfx driver.

Legacy shim is kept for transition period. It can be used after
setting CONFIG_UART_NRFX_UARTE_LEGACY_SHIM.

Cherry-picked from zephyrproject-rtos#65155. This commit should not be reviewd in this PR.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
magp-nordic pushed a commit to magp-nordic/zephyr that referenced this pull request Jan 18, 2024
Align test configurations to the new uart driver based on nrfx_uarte.

Cherry picked from zephyrproject-rtos#65155. This commit should not be review in this PR.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
magp-nordic pushed a commit to magp-nordic/zephyr that referenced this pull request Jan 18, 2024
Check was complaining when Kconfig flag was build using concatenation
via a macro (it was covering explicit token pasting ##). Added
negative lookbehind for CAT( which should cover exisiting concatenation
macros (UTIL_CAT, CONCAT, CAT).

Cherry picked from zephyrproject-rtos#65155. This commit should not be review in this PR.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: Coding Guidelines Coding guidelines and style area: Continuous Integration area: Device Model area: Power Management area: UART Universal Asynchronous Receiver-Transmitter platform: nRF BSIM Nordic Semiconductors, nRF BabbleSim platform: nRF Nordic nRFx Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants