aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-03-28 03:30:08 +0200
committerDario Nieuwenhuis <[email protected]>2022-04-06 05:38:11 +0200
commitbfce731982af1f053b1b727e49e920fc496a9546 (patch)
treec634162e1b851d1c28a2148323a66d053cc8afcd /examples
parent2b547f311efc7feaa3afbb9f1bf4100c5502839e (diff)
usb: nicer names for control structs.
Diffstat (limited to 'examples')
-rw-r--r--examples/nrf/src/bin/usb/cdc_acm.rs20
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};
3use core::sync::atomic::{AtomicBool, Ordering}; 3use core::sync::atomic::{AtomicBool, Ordering};
4use defmt::info; 4use defmt::info;
5use embassy::blocking_mutex::CriticalSectionMutex; 5use embassy::blocking_mutex::CriticalSectionMutex;
6use embassy_usb::control::{ 6use embassy_usb::control::{self, ControlHandler, ControlIn, InResponse, OutResponse, Request};
7 self, ControlHandler, ControlIn, ControlInRequestStatus, Request, RequestStatus,
8};
9use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError}; 7use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError};
10use embassy_usb::{driver::Driver, types::*, UsbDeviceBuilder}; 8use 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 => {