diff options
Diffstat (limited to 'examples/nrf/src/bin')
| -rw-r--r-- | examples/nrf/src/bin/usb/cdc_acm.rs | 17 | ||||
| -rw-r--r-- | examples/nrf/src/bin/usb/main.rs | 15 |
2 files changed, 23 insertions, 9 deletions
diff --git a/examples/nrf/src/bin/usb/cdc_acm.rs b/examples/nrf/src/bin/usb/cdc_acm.rs index 345d00389..b7c112ae6 100644 --- a/examples/nrf/src/bin/usb/cdc_acm.rs +++ b/examples/nrf/src/bin/usb/cdc_acm.rs | |||
| @@ -38,14 +38,15 @@ const REQ_SET_CONTROL_LINE_STATE: u8 = 0x22; | |||
| 38 | /// can be sent if there is no other data to send. This is because USB bulk transactions must be | 38 | /// can be sent if there is no other data to send. This is because USB bulk transactions must be |
| 39 | /// terminated with a short packet, even if the bulk endpoint is used for stream-like data. | 39 | /// terminated with a short packet, even if the bulk endpoint is used for stream-like data. |
| 40 | pub struct CdcAcmClass<'d, D: Driver<'d>> { | 40 | pub struct CdcAcmClass<'d, D: Driver<'d>> { |
| 41 | comm_if: InterfaceNumber, | 41 | // TODO not pub |
| 42 | comm_ep: D::EndpointIn, | 42 | pub comm_if: InterfaceNumber, |
| 43 | data_if: InterfaceNumber, | 43 | pub comm_ep: D::EndpointIn, |
| 44 | read_ep: D::EndpointOut, | 44 | pub data_if: InterfaceNumber, |
| 45 | write_ep: D::EndpointIn, | 45 | pub read_ep: D::EndpointOut, |
| 46 | line_coding: LineCoding, | 46 | pub write_ep: D::EndpointIn, |
| 47 | dtr: bool, | 47 | pub line_coding: LineCoding, |
| 48 | rts: bool, | 48 | pub dtr: bool, |
| 49 | pub rts: bool, | ||
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | impl<'d, D: Driver<'d>> CdcAcmClass<'d, D> { | 52 | impl<'d, D: Driver<'d>> CdcAcmClass<'d, D> { |
diff --git a/examples/nrf/src/bin/usb/main.rs b/examples/nrf/src/bin/usb/main.rs index 21ca2ba4f..d175766bb 100644 --- a/examples/nrf/src/bin/usb/main.rs +++ b/examples/nrf/src/bin/usb/main.rs | |||
| @@ -14,7 +14,9 @@ use embassy_nrf::interrupt; | |||
| 14 | use embassy_nrf::pac; | 14 | use embassy_nrf::pac; |
| 15 | use embassy_nrf::usb::{self, Driver}; | 15 | use embassy_nrf::usb::{self, Driver}; |
| 16 | use embassy_nrf::Peripherals; | 16 | use embassy_nrf::Peripherals; |
| 17 | use embassy_usb::driver::EndpointOut; | ||
| 17 | use embassy_usb::{Config, UsbDeviceBuilder}; | 18 | use embassy_usb::{Config, UsbDeviceBuilder}; |
| 19 | use futures::future::{join, select}; | ||
| 18 | 20 | ||
| 19 | use crate::cdc_acm::CdcAcmClass; | 21 | use crate::cdc_acm::CdcAcmClass; |
| 20 | 22 | ||
| @@ -49,5 +51,16 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 49 | let mut class = CdcAcmClass::new(&mut builder, 64); | 51 | let mut class = CdcAcmClass::new(&mut builder, 64); |
| 50 | 52 | ||
| 51 | let mut usb = builder.build(); | 53 | let mut usb = builder.build(); |
| 52 | usb.run().await; | 54 | |
| 55 | let fut1 = usb.run(); | ||
| 56 | let fut2 = async { | ||
| 57 | let mut buf = [0; 64]; | ||
| 58 | loop { | ||
| 59 | let n = class.read_ep.read(&mut buf).await.unwrap(); | ||
| 60 | let data = &buf[..n]; | ||
| 61 | info!("data: {:x}", data); | ||
| 62 | } | ||
| 63 | }; | ||
| 64 | |||
| 65 | join(fut1, fut2).await; | ||
| 53 | } | 66 | } |
