diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-07-28 13:38:26 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-07-28 13:38:26 +0200 |
| commit | d5f9d17b7c12c73cf16aa7414ce819bbd06efc2e (patch) | |
| tree | b472cc2a85f540d3a5ab0da1c9c30aaa488587fc /examples | |
| parent | 146c744223056561c6be61dda791993d939d0ae0 (diff) | |
Make pipes local vars.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp/src/bin/pio_uart.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/examples/rp/src/bin/pio_uart.rs b/examples/rp/src/bin/pio_uart.rs index c978f8f06..ca1c7f394 100644 --- a/examples/rp/src/bin/pio_uart.rs +++ b/examples/rp/src/bin/pio_uart.rs | |||
| @@ -18,7 +18,7 @@ use embassy_rp::bind_interrupts; | |||
| 18 | use embassy_rp::peripherals::{PIO0, USB}; | 18 | use embassy_rp::peripherals::{PIO0, USB}; |
| 19 | use embassy_rp::pio::InterruptHandler as PioInterruptHandler; | 19 | use embassy_rp::pio::InterruptHandler as PioInterruptHandler; |
| 20 | use embassy_rp::usb::{Driver, Instance, InterruptHandler}; | 20 | use embassy_rp::usb::{Driver, Instance, InterruptHandler}; |
| 21 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 21 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 22 | use embassy_sync::pipe::Pipe; | 22 | use embassy_sync::pipe::Pipe; |
| 23 | use embassy_usb::class::cdc_acm::{CdcAcmClass, Receiver, Sender, State}; | 23 | use embassy_usb::class::cdc_acm::{CdcAcmClass, Receiver, Sender, State}; |
| 24 | use embassy_usb::driver::EndpointError; | 24 | use embassy_usb::driver::EndpointError; |
| @@ -91,13 +91,13 @@ async fn main(_spawner: Spawner) { | |||
| 91 | let (mut uart_tx, mut uart_rx) = uart.split(); | 91 | let (mut uart_tx, mut uart_rx) = uart.split(); |
| 92 | 92 | ||
| 93 | // Pipe setup | 93 | // Pipe setup |
| 94 | static USB_PIPE: Pipe<ThreadModeRawMutex, 20> = Pipe::new(); | 94 | let usb_pipe: Pipe<NoopRawMutex, 20> = Pipe::new(); |
| 95 | let mut usb_pipe_writer = USB_PIPE.writer(); | 95 | let mut usb_pipe_writer = usb_pipe.writer(); |
| 96 | let mut usb_pipe_reader = USB_PIPE.reader(); | 96 | let mut usb_pipe_reader = usb_pipe.reader(); |
| 97 | 97 | ||
| 98 | static UART_PIPE: Pipe<ThreadModeRawMutex, 20> = Pipe::new(); | 98 | let uart_pipe: Pipe<NoopRawMutex, 20> = Pipe::new(); |
| 99 | let mut uart_pipe_writer = UART_PIPE.writer(); | 99 | let mut uart_pipe_writer = uart_pipe.writer(); |
| 100 | let mut uart_pipe_reader = UART_PIPE.reader(); | 100 | let mut uart_pipe_reader = uart_pipe.reader(); |
| 101 | 101 | ||
| 102 | let (mut usb_tx, mut usb_rx) = class.split(); | 102 | let (mut usb_tx, mut usb_rx) = class.split(); |
| 103 | 103 | ||
| @@ -141,7 +141,7 @@ impl From<EndpointError> for Disconnected { | |||
| 141 | /// Read from the USB and write it to the UART TX pipe | 141 | /// Read from the USB and write it to the UART TX pipe |
| 142 | async fn usb_read<'d, T: Instance + 'd>( | 142 | async fn usb_read<'d, T: Instance + 'd>( |
| 143 | usb_rx: &mut Receiver<'d, Driver<'d, T>>, | 143 | usb_rx: &mut Receiver<'d, Driver<'d, T>>, |
| 144 | uart_pipe_writer: &mut embassy_sync::pipe::Writer<'static, ThreadModeRawMutex, 20>, | 144 | uart_pipe_writer: &mut embassy_sync::pipe::Writer<'_, NoopRawMutex, 20>, |
| 145 | ) -> Result<(), Disconnected> { | 145 | ) -> Result<(), Disconnected> { |
| 146 | let mut buf = [0; 64]; | 146 | let mut buf = [0; 64]; |
| 147 | loop { | 147 | loop { |
| @@ -155,7 +155,7 @@ async fn usb_read<'d, T: Instance + 'd>( | |||
| 155 | /// Read from the USB TX pipe and write it to the USB | 155 | /// Read from the USB TX pipe and write it to the USB |
| 156 | async fn usb_write<'d, T: Instance + 'd>( | 156 | async fn usb_write<'d, T: Instance + 'd>( |
| 157 | usb_tx: &mut Sender<'d, Driver<'d, T>>, | 157 | usb_tx: &mut Sender<'d, Driver<'d, T>>, |
| 158 | usb_pipe_reader: &mut embassy_sync::pipe::Reader<'d, ThreadModeRawMutex, 20>, | 158 | usb_pipe_reader: &mut embassy_sync::pipe::Reader<'_, NoopRawMutex, 20>, |
| 159 | ) -> Result<(), Disconnected> { | 159 | ) -> Result<(), Disconnected> { |
| 160 | let mut buf = [0; 64]; | 160 | let mut buf = [0; 64]; |
| 161 | loop { | 161 | loop { |
| @@ -167,9 +167,9 @@ async fn usb_write<'d, T: Instance + 'd>( | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | /// Read from the UART and write it to the USB TX pipe | 169 | /// Read from the UART and write it to the USB TX pipe |
| 170 | async fn uart_read<'a>( | 170 | async fn uart_read( |
| 171 | uart_rx: &mut PioUartRx<'a>, | 171 | uart_rx: &mut PioUartRx<'_>, |
| 172 | usb_pipe_writer: &mut embassy_sync::pipe::Writer<'static, ThreadModeRawMutex, 20>, | 172 | usb_pipe_writer: &mut embassy_sync::pipe::Writer<'_, NoopRawMutex, 20>, |
| 173 | ) -> ! { | 173 | ) -> ! { |
| 174 | let mut buf = [0; 64]; | 174 | let mut buf = [0; 64]; |
| 175 | loop { | 175 | loop { |
| @@ -184,9 +184,9 @@ async fn uart_read<'a>( | |||
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | /// Read from the UART TX pipe and write it to the UART | 186 | /// Read from the UART TX pipe and write it to the UART |
| 187 | async fn uart_write<'a>( | 187 | async fn uart_write( |
| 188 | uart_tx: &mut PioUartTx<'a>, | 188 | uart_tx: &mut PioUartTx<'_>, |
| 189 | uart_pipe_reader: &mut embassy_sync::pipe::Reader<'a, ThreadModeRawMutex, 20>, | 189 | uart_pipe_reader: &mut embassy_sync::pipe::Reader<'_, NoopRawMutex, 20>, |
| 190 | ) -> ! { | 190 | ) -> ! { |
| 191 | let mut buf = [0; 64]; | 191 | let mut buf = [0; 64]; |
| 192 | loop { | 192 | loop { |
