-
Notifications
You must be signed in to change notification settings - Fork 8.4k
STM32 UART DRIVER : add support for buffer circular mode #80921
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
Merged
kartben
merged 3 commits into
zephyrproject-rtos:main
from
djiatsaf-st:uart_circular_mode
Jan 10, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(circular_dma) | ||
|
|
||
| target_sources(app PRIVATE src/main.c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| .. zephyr:code-sample:: uart | ||
| :name: UART circular mode | ||
| :relevant-api: uart_interface | ||
|
|
||
| Read data from the console and echo it back using a circular dma configuration. | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| This sample demonstrates how to use STM32 UART serial driver with DMA in circular mode. | ||
| It reads data from the console and echoes it back. | ||
|
|
||
| By default, the UART peripheral that is normally assigned to the Zephyr shell | ||
| is used, hence the majority of boards should be able to run this sample. | ||
|
|
||
| Building and Running | ||
| ******************** | ||
|
|
||
| Build and flash the sample as follows, changing ``nucleo_g071rb`` for | ||
| your board: | ||
|
|
||
| .. zephyr-app-commands:: | ||
| :zephyr-app: samples/boards/st/uart/circular_dma | ||
| :board: nucleo_g071rb | ||
| :goals: build flash | ||
| :compact: | ||
|
|
||
| Sample Output | ||
| ============= | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| Enter message to fill RX buffer size and press enter : | ||
| # Type e.g. : | ||
| # "Lorem Ipsum is simply dummy text of the printing and typesetting industry. | ||
| # Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, | ||
| # when an unknown printer took a galley of type and scrambled it to make a type specimen book. | ||
| # It has survived not only five centuries, but also the leap into electronic typesetting, | ||
| # remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset | ||
| # sheets containing Lorem Ipsum passages, and more recently with desktop publishing software | ||
| # like Aldus PageMaker including versions of Lorem Ipsum." | ||
|
|
||
| Lorem Ipsum is simply dummy text of the printing and typesetting industry. | ||
| Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, | ||
| when an unknown printer took a galley of type and scrambled it to make a type specimen book. | ||
| It has survived not only five centuries, but also the leap into electronic typesetting, | ||
| remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset | ||
| sheets containing Lorem Ipsum passages, and more recently with desktop publishing software | ||
| like Aldus PageMaker including versions of Lorem Ipsum. |
20 changes: 20 additions & 0 deletions
20
samples/boards/st/uart/circular_dma/boards/nucleo_c031c6.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Copyright (c) 2024 STMicroelectronics | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| &usart2 { | ||
| dmas = <&dmamux1 0 53 (STM32_DMA_PERIPH_TX)>, | ||
| <&dmamux1 3 52 (STM32_DMA_PERIPH_RX | STM32_DMA_MEM_8BITS | STM32_DMA_MODE_CYCLIC)>; | ||
| dma-names = "tx", "rx"; | ||
| fifo-enable; | ||
| }; | ||
|
|
||
| &dma1 { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &dmamux1 { | ||
| status = "okay"; | ||
| }; |
16 changes: 16 additions & 0 deletions
16
samples/boards/st/uart/circular_dma/boards/nucleo_f091rc.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Copyright (c) 2024 STMicroelectronics | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| &usart2 { | ||
| dmas = <&dma1 4 (STM32_DMA_PERIPH_TX)>, | ||
| <&dma1 5 (STM32_DMA_PERIPH_RX | STM32_DMA_MEM_8BITS | STM32_DMA_MODE_CYCLIC)>; | ||
| dma-names = "tx", "rx"; | ||
| fifo-enable; | ||
| }; | ||
|
|
||
| &dma1 { | ||
| status = "okay"; | ||
| }; |
20 changes: 20 additions & 0 deletions
20
samples/boards/st/uart/circular_dma/boards/nucleo_g071rb.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Copyright (c) 2024 STMicroelectronics | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| &usart2 { | ||
| dmas = <&dmamux1 0 53 (STM32_DMA_PERIPH_TX)>, | ||
| <&dmamux1 3 52 (STM32_DMA_PERIPH_RX | STM32_DMA_MEM_8BITS | STM32_DMA_MODE_CYCLIC)>; | ||
| dma-names = "tx", "rx"; | ||
| fifo-enable; | ||
| }; | ||
|
|
||
| &dma1 { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &dmamux1 { | ||
| status = "okay"; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| CONFIG_SERIAL=y | ||
| CONFIG_UART_ASYNC_API=y | ||
| CONFIG_RING_BUFFER=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| sample: | ||
| name: UART driver sample | ||
| tests: | ||
| sample.boards.stm32.uart.circular_dma: | ||
| integration_platforms: | ||
| - nucleo_g071rb | ||
| tags: | ||
| - serial | ||
| - uart | ||
| filter: dt_chosen_enabled("zephyr,shell-uart") | ||
| harness: keyboard |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.