diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-05-15 15:59:30 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-15 15:59:30 +0000 |
| commit | 1a87f7477abdb033d960a6af63c95a9e0575e670 (patch) | |
| tree | 0523c59fe3ef2bd406d44ab414f2903c68a918b9 /examples/rp/src/bin/uart_buffered_split.rs | |
| parent | 2bf2e54db925e1d8845deb5eaea737b6add95402 (diff) | |
| parent | 14a5d03af2a74eccaa9930bdf81eef43791a4b33 (diff) | |
Merge #1458
1458: rp: remove take!, add bind_interrupts! r=Dirbaio a=pennae
both of the uart interrupts now check a flag that only the dma rx path ever sets (and now unsets again on drop) to return early if it's not as they expect. this is ... not our preferred solution, but if bind_interrupts *must* allow mutiple handlers to be specified then this is the only way we can think of that doesn't break uarts.
Co-authored-by: pennae <[email protected]>
Diffstat (limited to 'examples/rp/src/bin/uart_buffered_split.rs')
| -rw-r--r-- | examples/rp/src/bin/uart_buffered_split.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/rp/src/bin/uart_buffered_split.rs b/examples/rp/src/bin/uart_buffered_split.rs index a8a682274..d6f01b4de 100644 --- a/examples/rp/src/bin/uart_buffered_split.rs +++ b/examples/rp/src/bin/uart_buffered_split.rs | |||
| @@ -5,13 +5,17 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::_export::StaticCell; | 7 | use embassy_executor::_export::StaticCell; |
| 8 | use embassy_rp::interrupt; | 8 | use embassy_rp::bind_interrupts; |
| 9 | use embassy_rp::peripherals::UART0; | 9 | use embassy_rp::peripherals::UART0; |
| 10 | use embassy_rp::uart::{BufferedUart, BufferedUartRx, Config}; | 10 | use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config}; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::{Duration, Timer}; |
| 12 | use embedded_io::asynch::{Read, Write}; | 12 | use embedded_io::asynch::{Read, Write}; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | ||
| 16 | UART0_IRQ => BufferedInterruptHandler<UART0>; | ||
| 17 | }); | ||
| 18 | |||
| 15 | macro_rules! singleton { | 19 | macro_rules! singleton { |
| 16 | ($val:expr) => {{ | 20 | ($val:expr) => {{ |
| 17 | type T = impl Sized; | 21 | type T = impl Sized; |
| @@ -26,10 +30,9 @@ async fn main(spawner: Spawner) { | |||
| 26 | let p = embassy_rp::init(Default::default()); | 30 | let p = embassy_rp::init(Default::default()); |
| 27 | let (tx_pin, rx_pin, uart) = (p.PIN_0, p.PIN_1, p.UART0); | 31 | let (tx_pin, rx_pin, uart) = (p.PIN_0, p.PIN_1, p.UART0); |
| 28 | 32 | ||
| 29 | let irq = interrupt::take!(UART0_IRQ); | ||
| 30 | let tx_buf = &mut singleton!([0u8; 16])[..]; | 33 | let tx_buf = &mut singleton!([0u8; 16])[..]; |
| 31 | let rx_buf = &mut singleton!([0u8; 16])[..]; | 34 | let rx_buf = &mut singleton!([0u8; 16])[..]; |
| 32 | let uart = BufferedUart::new(uart, irq, tx_pin, rx_pin, tx_buf, rx_buf, Config::default()); | 35 | let uart = BufferedUart::new(uart, Irqs, tx_pin, rx_pin, tx_buf, rx_buf, Config::default()); |
| 33 | let (rx, mut tx) = uart.split(); | 36 | let (rx, mut tx) = uart.split(); |
| 34 | 37 | ||
| 35 | unwrap!(spawner.spawn(reader(rx))); | 38 | unwrap!(spawner.spawn(reader(rx))); |
