usb: nicer names for control structs.

This commit is contained in:
Dario Nieuwenhuis
2022-03-28 03:30:08 +02:00
parent 2b547f311e
commit bfce731982
3 changed files with 27 additions and 37 deletions

View File

@ -3,9 +3,7 @@ use core::mem::{self, MaybeUninit};
use core::sync::atomic::{AtomicBool, Ordering};
use defmt::info;
use embassy::blocking_mutex::CriticalSectionMutex;
use embassy_usb::control::{
self, ControlHandler, ControlIn, ControlInRequestStatus, Request, RequestStatus,
};
use embassy_usb::control::{self, ControlHandler, ControlIn, InResponse, OutResponse, Request};
use embassy_usb::driver::{Endpoint, EndpointIn, EndpointOut, ReadError, WriteError};
use embassy_usb::{driver::Driver, types::*, UsbDeviceBuilder};
@ -88,12 +86,12 @@ impl ControlHandler for Control {
shared.rts.store(false, Ordering::Relaxed);
}
fn control_out(&mut self, req: control::Request, data: &[u8]) -> RequestStatus {
fn control_out(&mut self, req: control::Request, data: &[u8]) -> OutResponse {
match req.request {
REQ_SEND_ENCAPSULATED_COMMAND => {
// We don't actually support encapsulated commands but pretend we do for standards
// compatibility.
RequestStatus::Accepted
OutResponse::Accepted
}
REQ_SET_LINE_CODING if data.len() >= 7 => {
let coding = LineCoding {
@ -105,7 +103,7 @@ impl ControlHandler for Control {
self.shared().line_coding.lock(|x| x.set(coding));
info!("Set line coding to: {:?}", coding);
RequestStatus::Accepted
OutResponse::Accepted
}
REQ_SET_CONTROL_LINE_STATE => {
let dtr = (req.value & 0x0001) != 0;
@ -116,17 +114,13 @@ impl ControlHandler for Control {
shared.rts.store(rts, Ordering::Relaxed);
info!("Set dtr {}, rts {}", dtr, rts);
RequestStatus::Accepted
OutResponse::Accepted
}
_ => RequestStatus::Rejected,
_ => OutResponse::Rejected,
}
}
fn control_in<'a>(
&mut self,
req: Request,
control: ControlIn<'a>,
) -> ControlInRequestStatus<'a> {
fn control_in<'a>(&mut self, req: Request, control: ControlIn<'a>) -> InResponse<'a> {
match req.request {
// REQ_GET_ENCAPSULATED_COMMAND is not really supported - it will be rejected below.
REQ_GET_LINE_CODING if req.length == 7 => {