diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-11-07 00:27:21 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-11-25 22:30:47 +0100 |
| commit | 7b838d03369f94e09d652982f994c5013e81457e (patch) | |
| tree | 446239a627583d0d20513d8feba2024f72de62ec /tests | |
| parent | fa374523591266f7f5abdd0f02f994174553df71 (diff) | |
rp/uart: use lockfree ringbuffer.
This gets rid of another PeripheralMutex usage.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rp/src/bin/uart_buffered.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs index 9cc20bb98..bea9283e7 100644 --- a/tests/rp/src/bin/uart_buffered.rs +++ b/tests/rp/src/bin/uart_buffered.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::{assert_eq, *}; | 5 | use defmt::{assert_eq, *}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::interrupt; | 7 | use embassy_rp::interrupt; |
| 8 | use embassy_rp::uart::{BufferedUart, Config, State, Uart}; | 8 | use embassy_rp::uart::{BufferedUart, Config}; |
| 9 | use embedded_io::asynch::{Read, Write}; | 9 | use embedded_io::asynch::{Read, Write}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -17,25 +17,22 @@ async fn main(_spawner: Spawner) { | |||
| 17 | let (tx, rx, uart) = (p.PIN_0, p.PIN_1, p.UART0); | 17 | let (tx, rx, uart) = (p.PIN_0, p.PIN_1, p.UART0); |
| 18 | 18 | ||
| 19 | let config = Config::default(); | 19 | let config = Config::default(); |
| 20 | let uart = Uart::new_blocking(uart, tx, rx, config); | ||
| 21 | |||
| 22 | let irq = interrupt::take!(UART0_IRQ); | 20 | let irq = interrupt::take!(UART0_IRQ); |
| 23 | let tx_buf = &mut [0u8; 16]; | 21 | let tx_buf = &mut [0u8; 16]; |
| 24 | let rx_buf = &mut [0u8; 16]; | 22 | let rx_buf = &mut [0u8; 16]; |
| 25 | let mut state = State::new(); | 23 | let mut uart = BufferedUart::new(uart, irq, tx, rx, tx_buf, rx_buf, config); |
| 26 | let mut uart = BufferedUart::new(&mut state, uart, irq, tx_buf, rx_buf); | ||
| 27 | 24 | ||
| 28 | // Make sure we send more bytes than fits in the FIFO, to test the actual | 25 | // Make sure we send more bytes than fits in the FIFO, to test the actual |
| 29 | // bufferedUart. | 26 | // bufferedUart. |
| 30 | 27 | ||
| 31 | let data = [ | 28 | let data = [ |
| 32 | 1_u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, | 29 | 1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, |
| 33 | 30, 31, 32, | 30 | 30, 31, |
| 34 | ]; | 31 | ]; |
| 35 | uart.write_all(&data).await.unwrap(); | 32 | uart.write_all(&data).await.unwrap(); |
| 36 | info!("Done writing"); | 33 | info!("Done writing"); |
| 37 | 34 | ||
| 38 | let mut buf = [0; 32]; | 35 | let mut buf = [0; 31]; |
| 39 | uart.read_exact(&mut buf).await.unwrap(); | 36 | uart.read_exact(&mut buf).await.unwrap(); |
| 40 | assert_eq!(buf, data); | 37 | assert_eq!(buf, data); |
| 41 | 38 | ||
