diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/usb/cdc_acm.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/examples/nrf/src/bin/usb/cdc_acm.rs b/examples/nrf/src/bin/usb/cdc_acm.rs index 25c3108a9..141c6ecd1 100644 --- a/examples/nrf/src/bin/usb/cdc_acm.rs +++ b/examples/nrf/src/bin/usb/cdc_acm.rs | |||
| @@ -3,9 +3,7 @@ use core::mem::{self, MaybeUninit}; | |||
| 3 | use core::sync::atomic::{AtomicBool, Ordering}; | 3 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy::blocking_mutex::CriticalSectionMutex; | 5 | use embassy::blocking_mutex::CriticalSectionMutex; |
| 6 | use embassy_usb::control::{ | 6 | use embassy_usb::control::{self, ControlHandler, ControlIn, InResponse, OutResponse, Request}; |
| 7 | self, ControlHandler, ControlIn, ControlInRequestStatus, Request, RequestStatus, | ||
| 8 | }; | ||
| 9 | use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError}; | 7 | use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError}; |
| 10 | use embassy_usb::{driver::Driver, types::*, UsbDeviceBuilder}; | 8 | use embassy_usb::{driver::Driver, types::*, UsbDeviceBuilder}; |
| 11 | 9 | ||
| @@ -88,12 +86,12 @@ impl ControlHandler for Control { | |||
| 88 | shared.rts.store(false, Ordering::Relaxed); | 86 | shared.rts.store(false, Ordering::Relaxed); |
| 89 | } | 87 | } |
| 90 | 88 | ||
| 91 | fn control_out(&mut self, req: control::Request, data: &[u8]) -> RequestStatus { | 89 | fn control_out(&mut self, req: control::Request, data: &[u8]) -> OutResponse { |
| 92 | match req.request { | 90 | match req.request { |
| 93 | REQ_SEND_ENCAPSULATED_COMMAND => { | 91 | REQ_SEND_ENCAPSULATED_COMMAND => { |
| 94 | // We don't actually support encapsulated commands but pretend we do for standards | 92 | // We don't actually support encapsulated commands but pretend we do for standards |
| 95 | // compatibility. | 93 | // compatibility. |
| 96 | RequestStatus::Accepted | 94 | OutResponse::Accepted |
| 97 | } | 95 | } |
| 98 | REQ_SET_LINE_CODING if data.len() >= 7 => { | 96 | REQ_SET_LINE_CODING if data.len() >= 7 => { |
| 99 | let coding = LineCoding { | 97 | let coding = LineCoding { |
| @@ -105,7 +103,7 @@ impl ControlHandler for Control { | |||
| 105 | self.shared().line_coding.lock(|x| x.set(coding)); | 103 | self.shared().line_coding.lock(|x| x.set(coding)); |
| 106 | info!("Set line coding to: {:?}", coding); | 104 | info!("Set line coding to: {:?}", coding); |
| 107 | 105 | ||
| 108 | RequestStatus::Accepted | 106 | OutResponse::Accepted |
| 109 | } | 107 | } |
| 110 | REQ_SET_CONTROL_LINE_STATE => { | 108 | REQ_SET_CONTROL_LINE_STATE => { |
| 111 | let dtr = (req.value & 0x0001) != 0; | 109 | let dtr = (req.value & 0x0001) != 0; |
| @@ -116,17 +114,13 @@ impl ControlHandler for Control { | |||
| 116 | shared.rts.store(rts, Ordering::Relaxed); | 114 | shared.rts.store(rts, Ordering::Relaxed); |
| 117 | info!("Set dtr {}, rts {}", dtr, rts); | 115 | info!("Set dtr {}, rts {}", dtr, rts); |
| 118 | 116 | ||
| 119 | RequestStatus::Accepted | 117 | OutResponse::Accepted |
| 120 | } | 118 | } |
| 121 | _ => RequestStatus::Rejected, | 119 | _ => OutResponse::Rejected, |
| 122 | } | 120 | } |
| 123 | } | 121 | } |
| 124 | 122 | ||
| 125 | fn control_in<'a>( | 123 | fn control_in<'a>(&mut self, req: Request, control: ControlIn<'a>) -> InResponse<'a> { |
| 126 | &mut self, | ||
| 127 | req: Request, | ||
| 128 | control: ControlIn<'a>, | ||
| 129 | ) -> ControlInRequestStatus<'a> { | ||
| 130 | match req.request { | 124 | match req.request { |
| 131 | // REQ_GET_ENCAPSULATED_COMMAND is not really supported - it will be rejected below. | 125 | // REQ_GET_ENCAPSULATED_COMMAND is not really supported - it will be rejected below. |
| 132 | REQ_GET_LINE_CODING if req.length == 7 => { | 126 | REQ_GET_LINE_CODING if req.length == 7 => { |
