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/usb_serial.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/usb_serial.rs')
| -rw-r--r-- | examples/rp/src/bin/usb_serial.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/rp/src/bin/usb_serial.rs b/examples/rp/src/bin/usb_serial.rs index 8160a1875..ca728536c 100644 --- a/examples/rp/src/bin/usb_serial.rs +++ b/examples/rp/src/bin/usb_serial.rs | |||
| @@ -5,13 +5,18 @@ | |||
| 5 | use defmt::{info, panic}; | 5 | use defmt::{info, panic}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_rp::interrupt; | 8 | use embassy_rp::bind_interrupts; |
| 9 | use embassy_rp::usb::{Driver, Instance}; | 9 | use embassy_rp::peripherals::USB; |
| 10 | use embassy_rp::usb::{Driver, Instance, InterruptHandler}; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::{Builder, Config}; | 13 | use embassy_usb::{Builder, Config}; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | ||
| 17 | USBCTRL_IRQ => InterruptHandler<USB>; | ||
| 18 | }); | ||
| 19 | |||
| 15 | #[embassy_executor::main] | 20 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner) { | 21 | async fn main(_spawner: Spawner) { |
| 17 | info!("Hello there!"); | 22 | info!("Hello there!"); |
| @@ -19,8 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 19 | let p = embassy_rp::init(Default::default()); | 24 | let p = embassy_rp::init(Default::default()); |
| 20 | 25 | ||
| 21 | // Create the driver, from the HAL. | 26 | // Create the driver, from the HAL. |
| 22 | let irq = interrupt::take!(USBCTRL_IRQ); | 27 | let driver = Driver::new(p.USB, Irqs); |
| 23 | let driver = Driver::new(p.USB, irq); | ||
| 24 | 28 | ||
| 25 | // Create embassy-usb Config | 29 | // Create embassy-usb Config |
| 26 | let mut config = Config::new(0xc0de, 0xcafe); | 30 | let mut config = Config::new(0xc0de, 0xcafe); |
