diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-03-10 01:05:33 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-04-06 05:38:11 +0200 |
| commit | 0320500f0f14d03aecfe3ee7482a5cf76ec8844c (patch) | |
| tree | 0e4fa8dd6f1b6bd84eb2232ea4b8ba86f5e1c80c /examples/nrf | |
| parent | 77ceced036d574c7d67259b85e1d61b96e82d0d3 (diff) | |
Working CDC-ACM device->host
Diffstat (limited to 'examples/nrf')
| -rw-r--r-- | examples/nrf/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/nrf/src/bin/usb/main.rs | 18 |
2 files changed, 15 insertions, 5 deletions
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index fb846b3a9..59e5de026 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | authors = ["Dario Nieuwenhuis <[email protected]>"] | 2 | authors = ["Dario Nieuwenhuis <[email protected]>"] |
| 3 | edition = "2018" | 3 | edition = "2021" |
| 4 | name = "embassy-nrf-examples" | 4 | name = "embassy-nrf-examples" |
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | 6 | ||
diff --git a/examples/nrf/src/bin/usb/main.rs b/examples/nrf/src/bin/usb/main.rs index d175766bb..014ad5c6e 100644 --- a/examples/nrf/src/bin/usb/main.rs +++ b/examples/nrf/src/bin/usb/main.rs | |||
| @@ -10,13 +10,14 @@ mod cdc_acm; | |||
| 10 | use core::mem; | 10 | use core::mem; |
| 11 | use defmt::*; | 11 | use defmt::*; |
| 12 | use embassy::executor::Spawner; | 12 | use embassy::executor::Spawner; |
| 13 | use embassy::time::{Duration, Timer}; | ||
| 13 | use embassy_nrf::interrupt; | 14 | use embassy_nrf::interrupt; |
| 14 | use embassy_nrf::pac; | 15 | use embassy_nrf::pac; |
| 15 | use embassy_nrf::usb::{self, Driver}; | 16 | use embassy_nrf::usb::Driver; |
| 16 | use embassy_nrf::Peripherals; | 17 | use embassy_nrf::Peripherals; |
| 17 | use embassy_usb::driver::EndpointOut; | 18 | use embassy_usb::driver::{EndpointIn, EndpointOut}; |
| 18 | use embassy_usb::{Config, UsbDeviceBuilder}; | 19 | use embassy_usb::{Config, UsbDeviceBuilder}; |
| 19 | use futures::future::{join, select}; | 20 | use futures::future::join3; |
| 20 | 21 | ||
| 21 | use crate::cdc_acm::CdcAcmClass; | 22 | use crate::cdc_acm::CdcAcmClass; |
| 22 | 23 | ||
| @@ -61,6 +62,15 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 61 | info!("data: {:x}", data); | 62 | info!("data: {:x}", data); |
| 62 | } | 63 | } |
| 63 | }; | 64 | }; |
| 65 | let fut3 = async { | ||
| 66 | loop { | ||
| 67 | info!("writing..."); | ||
| 68 | class.write_ep.write(b"Hello World!\r\n").await.unwrap(); | ||
| 69 | info!("written"); | ||
| 70 | |||
| 71 | Timer::after(Duration::from_secs(1)).await; | ||
| 72 | } | ||
| 73 | }; | ||
| 64 | 74 | ||
| 65 | join(fut1, fut2).await; | 75 | join3(fut1, fut2, fut3).await; |
| 66 | } | 76 | } |
