aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-03-30 01:18:37 +0200
committerDario Nieuwenhuis <[email protected]>2022-04-06 05:38:11 +0200
commitd1e4b3d7d5a931cd6e04b7e2fe467945ef862477 (patch)
treeefe3199292133306c20b27da7442cadf8592f3b4
parentc06488eb2978d9eaa8dc6a2669a6ce279638f4b2 (diff)
usb: add -usb-serial crate, fix warnings and stable build.
-rw-r--r--embassy-nrf/Cargo.toml4
-rw-r--r--embassy-nrf/src/chips/nrf52820.rs1
-rw-r--r--embassy-nrf/src/chips/nrf52833.rs1
-rw-r--r--embassy-nrf/src/chips/nrf52840.rs1
-rw-r--r--embassy-nrf/src/chips/nrf5340_app.rs1
-rw-r--r--embassy-nrf/src/lib.rs1
-rw-r--r--embassy-nrf/src/usb.rs11
-rw-r--r--embassy-usb-serial/Cargo.toml11
-rw-r--r--embassy-usb-serial/src/fmt.rs225
-rw-r--r--embassy-usb-serial/src/lib.rs (renamed from examples/nrf/src/bin/usb/cdc_acm.rs)13
-rw-r--r--embassy-usb/Cargo.toml2
-rw-r--r--embassy-usb/src/descriptor.rs1
-rw-r--r--embassy-usb/src/lib.rs10
-rw-r--r--examples/nrf/Cargo.toml1
-rw-r--r--examples/nrf/src/bin/usb_serial.rs (renamed from examples/nrf/src/bin/usb/main.rs)9
15 files changed, 265 insertions, 27 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml
index 36c61c651..858ff1f6e 100644
--- a/embassy-nrf/Cargo.toml
+++ b/embassy-nrf/Cargo.toml
@@ -18,7 +18,7 @@ flavors = [
18[features] 18[features]
19 19
20# Enable nightly-only features 20# Enable nightly-only features
21nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async"] 21nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async", "embassy-usb"]
22 22
23# Reexport the PAC for the currently enabled chip at `embassy_nrf::pac`. 23# Reexport the PAC for the currently enabled chip at `embassy_nrf::pac`.
24# This is unstable because semver-minor (non-breaking) releases of embassy-nrf may major-bump (breaking) the PAC version. 24# This is unstable because semver-minor (non-breaking) releases of embassy-nrf may major-bump (breaking) the PAC version.
@@ -64,7 +64,7 @@ _gpio-p1 = []
64embassy = { version = "0.1.0", path = "../embassy" } 64embassy = { version = "0.1.0", path = "../embassy" }
65embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]} 65embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]}
66embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } 66embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
67embassy-usb = {version = "0.1.0", path = "../embassy-usb" } 67embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true }
68 68
69embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } 69embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
70embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} 70embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true}
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs
index aa2b2e61d..136ef4ec9 100644
--- a/embassy-nrf/src/chips/nrf52820.rs
+++ b/embassy-nrf/src/chips/nrf52820.rs
@@ -125,6 +125,7 @@ embassy_hal_common::peripherals! {
125 TEMP, 125 TEMP,
126} 126}
127 127
128#[cfg(feature = "nightly")]
128impl_usb!(USBD, USBD, USBD); 129impl_usb!(USBD, USBD, USBD);
129 130
130impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); 131impl_uarte!(UARTE0, UARTE0, UARTE0_UART0);
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs
index 498a3c307..35cf4224d 100644
--- a/embassy-nrf/src/chips/nrf52833.rs
+++ b/embassy-nrf/src/chips/nrf52833.rs
@@ -157,6 +157,7 @@ embassy_hal_common::peripherals! {
157 TEMP, 157 TEMP,
158} 158}
159 159
160#[cfg(feature = "nightly")]
160impl_usb!(USBD, USBD, USBD); 161impl_usb!(USBD, USBD, USBD);
161 162
162impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); 163impl_uarte!(UARTE0, UARTE0, UARTE0_UART0);
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs
index 411768146..d20abbfbd 100644
--- a/embassy-nrf/src/chips/nrf52840.rs
+++ b/embassy-nrf/src/chips/nrf52840.rs
@@ -160,6 +160,7 @@ embassy_hal_common::peripherals! {
160 TEMP, 160 TEMP,
161} 161}
162 162
163#[cfg(feature = "nightly")]
163impl_usb!(USBD, USBD, USBD); 164impl_usb!(USBD, USBD, USBD);
164 165
165impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); 166impl_uarte!(UARTE0, UARTE0, UARTE0_UART0);
diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs
index ae6887b3c..89579b69f 100644
--- a/embassy-nrf/src/chips/nrf5340_app.rs
+++ b/embassy-nrf/src/chips/nrf5340_app.rs
@@ -348,6 +348,7 @@ embassy_hal_common::peripherals! {
348 P1_15, 348 P1_15,
349} 349}
350 350
351#[cfg(feature = "nightly")]
351impl_usb!(USBD, USBD, USBD); 352impl_usb!(USBD, USBD, USBD);
352 353
353impl_uarte!(UARTETWISPI0, UARTE0, SERIAL0); 354impl_uarte!(UARTETWISPI0, UARTE0, SERIAL0);
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs
index 06e8235e3..667e8ea38 100644
--- a/embassy-nrf/src/lib.rs
+++ b/embassy-nrf/src/lib.rs
@@ -91,6 +91,7 @@ pub mod uarte;
91 feature = "nrf52833", 91 feature = "nrf52833",
92 feature = "nrf52840" 92 feature = "nrf52840"
93))] 93))]
94#[cfg(feature = "nightly")]
94pub mod usb; 95pub mod usb;
95#[cfg(not(feature = "_nrf5340"))] 96#[cfg(not(feature = "_nrf5340"))]
96pub mod wdt; 97pub mod wdt;
diff --git a/embassy-nrf/src/usb.rs b/embassy-nrf/src/usb.rs
index 1cd5a9ebb..b26e40272 100644
--- a/embassy-nrf/src/usb.rs
+++ b/embassy-nrf/src/usb.rs
@@ -4,6 +4,7 @@ use core::marker::PhantomData;
4use core::mem::MaybeUninit; 4use core::mem::MaybeUninit;
5use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; 5use core::sync::atomic::{compiler_fence, AtomicU32, Ordering};
6use core::task::Poll; 6use core::task::Poll;
7use cortex_m::peripheral::NVIC;
7use embassy::interrupt::InterruptExt; 8use embassy::interrupt::InterruptExt;
8use embassy::time::{with_timeout, Duration}; 9use embassy::time::{with_timeout, Duration};
9use embassy::util::Unborrow; 10use embassy::util::Unborrow;
@@ -14,7 +15,6 @@ use embassy_usb::driver::{self, Event, ReadError, WriteError};
14use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection}; 15use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection};
15use futures::future::poll_fn; 16use futures::future::poll_fn;
16use futures::Future; 17use futures::Future;
17use pac::NVIC;
18 18
19pub use embassy_usb; 19pub use embassy_usb;
20 20
@@ -617,7 +617,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
617 fn data_out<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::DataOutFuture<'a> { 617 fn data_out<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::DataOutFuture<'a> {
618 async move { 618 async move {
619 let req = self.request.unwrap(); 619 let req = self.request.unwrap();
620 assert_eq!(req.direction, UsbDirection::Out); 620 assert!(req.direction == UsbDirection::Out);
621 assert!(req.length > 0); 621 assert!(req.length > 0);
622 622
623 let req_length = usize::from(req.length); 623 let req_length = usize::from(req.length);
@@ -644,9 +644,12 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
644 644
645 fn accept_in<'a>(&'a mut self, buf: &'a [u8]) -> Self::AcceptInFuture<'a> { 645 fn accept_in<'a>(&'a mut self, buf: &'a [u8]) -> Self::AcceptInFuture<'a> {
646 async move { 646 async move {
647 info!("control accept {=[u8]:x}", buf); 647 #[cfg(feature = "defmt")]
648 info!("control accept {:x}", buf);
649 #[cfg(not(feature = "defmt"))]
650 info!("control accept {:x?}", buf);
648 let req = self.request.unwrap(); 651 let req = self.request.unwrap();
649 assert_eq!(req.direction, UsbDirection::In); 652 assert!(req.direction == UsbDirection::In);
650 653
651 let req_len = usize::from(req.length); 654 let req_len = usize::from(req.length);
652 let len = buf.len().min(req_len); 655 let len = buf.len().min(req_len);
diff --git a/embassy-usb-serial/Cargo.toml b/embassy-usb-serial/Cargo.toml
new file mode 100644
index 000000000..16e03046e
--- /dev/null
+++ b/embassy-usb-serial/Cargo.toml
@@ -0,0 +1,11 @@
1[package]
2name = "embassy-usb-serial"
3version = "0.1.0"
4edition = "2021"
5
6[dependencies]
7embassy = { version = "0.1.0", path = "../embassy" }
8embassy-usb = { version = "0.1.0", path = "../embassy-usb" }
9
10defmt = { version = "0.3", optional = true }
11log = { version = "0.4.14", optional = true }
diff --git a/embassy-usb-serial/src/fmt.rs b/embassy-usb-serial/src/fmt.rs
new file mode 100644
index 000000000..066970813
--- /dev/null
+++ b/embassy-usb-serial/src/fmt.rs
@@ -0,0 +1,225 @@
1#![macro_use]
2#![allow(unused_macros)]
3
4#[cfg(all(feature = "defmt", feature = "log"))]
5compile_error!("You may not enable both `defmt` and `log` features.");
6
7macro_rules! assert {
8 ($($x:tt)*) => {
9 {
10 #[cfg(not(feature = "defmt"))]
11 ::core::assert!($($x)*);
12 #[cfg(feature = "defmt")]
13 ::defmt::assert!($($x)*);
14 }
15 };
16}
17
18macro_rules! assert_eq {
19 ($($x:tt)*) => {
20 {
21 #[cfg(not(feature = "defmt"))]
22 ::core::assert_eq!($($x)*);
23 #[cfg(feature = "defmt")]
24 ::defmt::assert_eq!($($x)*);
25 }
26 };
27}
28
29macro_rules! assert_ne {
30 ($($x:tt)*) => {
31 {
32 #[cfg(not(feature = "defmt"))]
33 ::core::assert_ne!($($x)*);
34 #[cfg(feature = "defmt")]
35 ::defmt::assert_ne!($($x)*);
36 }
37 };
38}
39
40macro_rules! debug_assert {
41 ($($x:tt)*) => {
42 {
43 #[cfg(not(feature = "defmt"))]
44 ::core::debug_assert!($($x)*);
45 #[cfg(feature = "defmt")]
46 ::defmt::debug_assert!($($x)*);
47 }
48 };
49}
50
51macro_rules! debug_assert_eq {
52 ($($x:tt)*) => {
53 {
54 #[cfg(not(feature = "defmt"))]
55 ::core::debug_assert_eq!($($x)*);
56 #[cfg(feature = "defmt")]
57 ::defmt::debug_assert_eq!($($x)*);
58 }
59 };
60}
61
62macro_rules! debug_assert_ne {
63 ($($x:tt)*) => {
64 {
65 #[cfg(not(feature = "defmt"))]
66 ::core::debug_assert_ne!($($x)*);
67 #[cfg(feature = "defmt")]
68 ::defmt::debug_assert_ne!($($x)*);
69 }
70 };
71}
72
73macro_rules! todo {
74 ($($x:tt)*) => {
75 {
76 #[cfg(not(feature = "defmt"))]
77 ::core::todo!($($x)*);
78 #[cfg(feature = "defmt")]
79 ::defmt::todo!($($x)*);
80 }
81 };
82}
83
84macro_rules! unreachable {
85 ($($x:tt)*) => {
86 {
87 #[cfg(not(feature = "defmt"))]
88 ::core::unreachable!($($x)*);
89 #[cfg(feature = "defmt")]
90 ::defmt::unreachable!($($x)*);
91 }
92 };
93}
94
95macro_rules! panic {
96 ($($x:tt)*) => {
97 {
98 #[cfg(not(feature = "defmt"))]
99 ::core::panic!($($x)*);
100 #[cfg(feature = "defmt")]
101 ::defmt::panic!($($x)*);
102 }
103 };
104}
105
106macro_rules! trace {
107 ($s:literal $(, $x:expr)* $(,)?) => {
108 {
109 #[cfg(feature = "log")]
110 ::log::trace!($s $(, $x)*);
111 #[cfg(feature = "defmt")]
112 ::defmt::trace!($s $(, $x)*);
113 #[cfg(not(any(feature = "log", feature="defmt")))]
114 let _ = ($( & $x ),*);
115 }
116 };
117}
118
119macro_rules! debug {
120 ($s:literal $(, $x:expr)* $(,)?) => {
121 {
122 #[cfg(feature = "log")]
123 ::log::debug!($s $(, $x)*);
124 #[cfg(feature = "defmt")]
125 ::defmt::debug!($s $(, $x)*);
126 #[cfg(not(any(feature = "log", feature="defmt")))]
127 let _ = ($( & $x ),*);
128 }
129 };
130}
131
132macro_rules! info {
133 ($s:literal $(, $x:expr)* $(,)?) => {
134 {
135 #[cfg(feature = "log")]
136 ::log::info!($s $(, $x)*);
137 #[cfg(feature = "defmt")]
138 ::defmt::info!($s $(, $x)*);
139 #[cfg(not(any(feature = "log", feature="defmt")))]
140 let _ = ($( & $x ),*);
141 }
142 };
143}
144
145macro_rules! warn {
146 ($s:literal $(, $x:expr)* $(,)?) => {
147 {
148 #[cfg(feature = "log")]
149 ::log::warn!($s $(, $x)*);
150 #[cfg(feature = "defmt")]
151 ::defmt::warn!($s $(, $x)*);
152 #[cfg(not(any(feature = "log", feature="defmt")))]
153 let _ = ($( & $x ),*);
154 }
155 };
156}
157
158macro_rules! error {
159 ($s:literal $(, $x:expr)* $(,)?) => {
160 {
161 #[cfg(feature = "log")]
162 ::log::error!($s $(, $x)*);
163 #[cfg(feature = "defmt")]
164 ::defmt::error!($s $(, $x)*);
165 #[cfg(not(any(feature = "log", feature="defmt")))]
166 let _ = ($( & $x ),*);
167 }
168 };
169}
170
171#[cfg(feature = "defmt")]
172macro_rules! unwrap {
173 ($($x:tt)*) => {
174 ::defmt::unwrap!($($x)*)
175 };
176}
177
178#[cfg(not(feature = "defmt"))]
179macro_rules! unwrap {
180 ($arg:expr) => {
181 match $crate::fmt::Try::into_result($arg) {
182 ::core::result::Result::Ok(t) => t,
183 ::core::result::Result::Err(e) => {
184 ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e);
185 }
186 }
187 };
188 ($arg:expr, $($msg:expr),+ $(,)? ) => {
189 match $crate::fmt::Try::into_result($arg) {
190 ::core::result::Result::Ok(t) => t,
191 ::core::result::Result::Err(e) => {
192 ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e);
193 }
194 }
195 }
196}
197
198#[derive(Debug, Copy, Clone, Eq, PartialEq)]
199pub struct NoneError;
200
201pub trait Try {
202 type Ok;
203 type Error;
204 fn into_result(self) -> Result<Self::Ok, Self::Error>;
205}
206
207impl<T> Try for Option<T> {
208 type Ok = T;
209 type Error = NoneError;
210
211 #[inline]
212 fn into_result(self) -> Result<T, NoneError> {
213 self.ok_or(NoneError)
214 }
215}
216
217impl<T, E> Try for Result<T, E> {
218 type Ok = T;
219 type Error = E;
220
221 #[inline]
222 fn into_result(self) -> Self {
223 self
224 }
225}
diff --git a/examples/nrf/src/bin/usb/cdc_acm.rs b/embassy-usb-serial/src/lib.rs
index c28681dc4..d6c31c86e 100644
--- a/examples/nrf/src/bin/usb/cdc_acm.rs
+++ b/embassy-usb-serial/src/lib.rs
@@ -1,7 +1,13 @@
1#![no_std]
2#![feature(generic_associated_types)]
3#![feature(type_alias_impl_trait)]
4
5// This mod MUST go first, so that the others see its macros.
6pub(crate) mod fmt;
7
1use core::cell::Cell; 8use core::cell::Cell;
2use core::mem::{self, MaybeUninit}; 9use core::mem::{self, MaybeUninit};
3use core::sync::atomic::{AtomicBool, Ordering}; 10use core::sync::atomic::{AtomicBool, Ordering};
4use defmt::info;
5use embassy::blocking_mutex::CriticalSectionMutex; 11use embassy::blocking_mutex::CriticalSectionMutex;
6use embassy_usb::control::{self, ControlHandler, InResponse, OutResponse, Request}; 12use embassy_usb::control::{self, ControlHandler, InResponse, OutResponse, Request};
7use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError}; 13use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError};
@@ -291,11 +297,6 @@ impl<'d, D: Driver<'d>> CdcAcmClass<'d, D> {
291 pub async fn read_packet(&mut self, data: &mut [u8]) -> Result<usize, ReadError> { 297 pub async fn read_packet(&mut self, data: &mut [u8]) -> Result<usize, ReadError> {
292 self.read_ep.read(data).await 298 self.read_ep.read(data).await
293 } 299 }
294
295 /// Gets the address of the IN endpoint.
296 pub(crate) fn write_ep_address(&self) -> EndpointAddress {
297 self.write_ep.info().addr
298 }
299} 300}
300 301
301/// Number of stop bits for LineCoding 302/// Number of stop bits for LineCoding
diff --git a/embassy-usb/Cargo.toml b/embassy-usb/Cargo.toml
index af5986c15..01bf5ef6f 100644
--- a/embassy-usb/Cargo.toml
+++ b/embassy-usb/Cargo.toml
@@ -8,6 +8,4 @@ embassy = { version = "0.1.0", path = "../embassy" }
8 8
9defmt = { version = "0.3", optional = true } 9defmt = { version = "0.3", optional = true }
10log = { version = "0.4.14", optional = true } 10log = { version = "0.4.14", optional = true }
11cortex-m = "0.7.3"
12num-traits = { version = "0.2.14", default-features = false }
13heapless = "0.7.10" \ No newline at end of file 11heapless = "0.7.10" \ No newline at end of file
diff --git a/embassy-usb/src/descriptor.rs b/embassy-usb/src/descriptor.rs
index 746c6b828..5f8b0d560 100644
--- a/embassy-usb/src/descriptor.rs
+++ b/embassy-usb/src/descriptor.rs
@@ -136,6 +136,7 @@ impl<'a> DescriptorWriter<'a> {
136 ) 136 )
137 } 137 }
138 138
139 #[allow(unused)]
139 pub(crate) fn end_class(&mut self) { 140 pub(crate) fn end_class(&mut self) {
140 self.num_endpoints_mark = None; 141 self.num_endpoints_mark = None;
141 } 142 }
diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs
index cbb909244..5a6b21906 100644
--- a/embassy-usb/src/lib.rs
+++ b/embassy-usb/src/lib.rs
@@ -302,7 +302,6 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
302 302
303 async fn handle_get_descriptor(&mut self, req: Request) { 303 async fn handle_get_descriptor(&mut self, req: Request) {
304 let (dtype, index) = req.descriptor_type_index(); 304 let (dtype, index) = req.descriptor_type_index();
305 let config = self.config.clone();
306 305
307 match dtype { 306 match dtype {
308 descriptor_type::BOS => self.control.accept_in(self.bos_descriptor).await, 307 descriptor_type::BOS => self.control.accept_in(self.bos_descriptor).await,
@@ -321,13 +320,10 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
321 2 => self.config.product, 320 2 => self.config.product,
322 3 => self.config.serial_number, 321 3 => self.config.serial_number,
323 _ => { 322 _ => {
324 let index = StringIndex::new(index); 323 let _index = StringIndex::new(index);
325 let lang_id = req.index; 324 let _lang_id = req.index;
325 // TODO
326 None 326 None
327 //classes
328 // .iter()
329 // .filter_map(|cls| cls.get_string(index, lang_id))
330 // .nth(0)
331 } 327 }
332 }; 328 };
333 329
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml
index 59e5de026..58450a045 100644
--- a/examples/nrf/Cargo.toml
+++ b/examples/nrf/Cargo.toml
@@ -12,6 +12,7 @@ nightly = ["embassy-nrf/nightly", "embassy-nrf/unstable-traits"]
12embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } 12embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] }
13embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } 13embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
14embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] }
15 16
16defmt = "0.3" 17defmt = "0.3"
17defmt-rtt = "0.3" 18defmt-rtt = "0.3"
diff --git a/examples/nrf/src/bin/usb/main.rs b/examples/nrf/src/bin/usb_serial.rs
index c4b9c0176..0a4ff9489 100644
--- a/examples/nrf/src/bin/usb/main.rs
+++ b/examples/nrf/src/bin/usb_serial.rs
@@ -3,11 +3,6 @@
3#![feature(generic_associated_types)] 3#![feature(generic_associated_types)]
4#![feature(type_alias_impl_trait)] 4#![feature(type_alias_impl_trait)]
5 5
6#[path = "../../example_common.rs"]
7mod example_common;
8
9mod cdc_acm;
10
11use core::mem; 6use core::mem;
12use defmt::*; 7use defmt::*;
13use embassy::executor::Spawner; 8use embassy::executor::Spawner;
@@ -18,9 +13,11 @@ use embassy_nrf::usb::Driver;
18use embassy_nrf::Peripherals; 13use embassy_nrf::Peripherals;
19use embassy_usb::driver::{EndpointIn, EndpointOut}; 14use embassy_usb::driver::{EndpointIn, EndpointOut};
20use embassy_usb::{Config, UsbDeviceBuilder}; 15use embassy_usb::{Config, UsbDeviceBuilder};
16use embassy_usb_serial::{CdcAcmClass, State};
21use futures::future::join3; 17use futures::future::join3;
22 18
23use crate::cdc_acm::{CdcAcmClass, State}; 19use defmt_rtt as _; // global logger
20use panic_probe as _;
24 21
25#[embassy::main] 22#[embassy::main]
26async fn main(_spawner: Spawner, p: Peripherals) { 23async fn main(_spawner: Spawner, p: Peripherals) {