diff options
Diffstat (limited to 'examples/nrf/src/bin')
| -rw-r--r-- | examples/nrf/src/bin/usb/cdc_acm.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/nrf/src/bin/usb/cdc_acm.rs b/examples/nrf/src/bin/usb/cdc_acm.rs index 141c6ecd1..4be35fd3f 100644 --- a/examples/nrf/src/bin/usb/cdc_acm.rs +++ b/examples/nrf/src/bin/usb/cdc_acm.rs | |||
| @@ -3,7 +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::{self, ControlHandler, ControlIn, InResponse, OutResponse, Request}; | 6 | use embassy_usb::control::{self, ControlHandler, InResponse, OutResponse, Request}; |
| 7 | use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError}; | 7 | use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError}; |
| 8 | use embassy_usb::{driver::Driver, types::*, UsbDeviceBuilder}; | 8 | use embassy_usb::{driver::Driver, types::*, UsbDeviceBuilder}; |
| 9 | 9 | ||
| @@ -120,20 +120,19 @@ impl ControlHandler for Control { | |||
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | fn control_in<'a>(&mut self, req: Request, control: ControlIn<'a>) -> InResponse<'a> { | 123 | fn control_in(&mut self, req: Request, resp: &mut [u8]) -> InResponse { |
| 124 | match req.request { | 124 | match req.request { |
| 125 | // 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. |
| 126 | REQ_GET_LINE_CODING if req.length == 7 => { | 126 | REQ_GET_LINE_CODING if req.length == 7 => { |
| 127 | info!("Sending line coding"); | 127 | info!("Sending line coding"); |
| 128 | let coding = self.shared().line_coding.lock(|x| x.get()); | 128 | let coding = self.shared().line_coding.lock(|x| x.get()); |
| 129 | let mut data = [0; 7]; | 129 | resp[0..4].copy_from_slice(&coding.data_rate.to_le_bytes()); |
| 130 | data[0..4].copy_from_slice(&coding.data_rate.to_le_bytes()); | 130 | resp[4] = coding.stop_bits as u8; |
| 131 | data[4] = coding.stop_bits as u8; | 131 | resp[5] = coding.parity_type as u8; |
| 132 | data[5] = coding.parity_type as u8; | 132 | resp[6] = coding.data_bits; |
| 133 | data[6] = coding.data_bits; | 133 | InResponse::Accepted(7) |
| 134 | control.accept(&data) | ||
| 135 | } | 134 | } |
| 136 | _ => control.reject(), | 135 | _ => InResponse::Rejected, |
| 137 | } | 136 | } |
| 138 | } | 137 | } |
| 139 | } | 138 | } |
