Run rustfmt.
This commit is contained in:
@ -1,14 +1,11 @@
|
||||
use heapless::Vec;
|
||||
|
||||
use crate::{Interface, STRING_INDEX_CUSTOM_START};
|
||||
|
||||
use super::control::ControlHandler;
|
||||
use super::descriptor::{BosWriter, DescriptorWriter};
|
||||
use super::driver::{Driver, Endpoint};
|
||||
use super::types::*;
|
||||
use super::DeviceStateHandler;
|
||||
use super::UsbDevice;
|
||||
use super::MAX_INTERFACE_COUNT;
|
||||
use super::{DeviceStateHandler, UsbDevice, MAX_INTERFACE_COUNT};
|
||||
use crate::{Interface, STRING_INDEX_CUSTOM_START};
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
@ -151,9 +148,7 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
) -> Self {
|
||||
// Magic values specified in USB-IF ECN on IADs.
|
||||
if config.composite_with_iads
|
||||
&& (config.device_class != 0xEF
|
||||
|| config.device_sub_class != 0x02
|
||||
|| config.device_protocol != 0x01)
|
||||
&& (config.device_class != 0xEF || config.device_sub_class != 0x02 || config.device_protocol != 0x01)
|
||||
{
|
||||
panic!("if composite_with_iads is set, you must set device_class = 0xEF, device_sub_class = 0x02, device_protocol = 0x01");
|
||||
}
|
||||
@ -218,12 +213,7 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
/// with the given class/subclass/protocol, associating all the child interfaces.
|
||||
///
|
||||
/// If it's not set, no IAD descriptor is added.
|
||||
pub fn function(
|
||||
&mut self,
|
||||
class: u8,
|
||||
subclass: u8,
|
||||
protocol: u8,
|
||||
) -> FunctionBuilder<'_, 'd, D> {
|
||||
pub fn function(&mut self, class: u8, subclass: u8, protocol: u8) -> FunctionBuilder<'_, 'd, D> {
|
||||
let iface_count_index = if self.config.composite_with_iads {
|
||||
self.config_descriptor.iad(
|
||||
InterfaceNumber::new(self.interfaces.len() as _),
|
||||
@ -315,24 +305,14 @@ impl<'a, 'd, D: Driver<'d>> InterfaceBuilder<'a, 'd, D> {
|
||||
/// Alternate setting numbers are guaranteed to be allocated consecutively, starting from 0.
|
||||
///
|
||||
/// The first alternate setting, with number 0, is the default one.
|
||||
pub fn alt_setting(
|
||||
&mut self,
|
||||
class: u8,
|
||||
subclass: u8,
|
||||
protocol: u8,
|
||||
) -> InterfaceAltBuilder<'_, 'd, D> {
|
||||
pub fn alt_setting(&mut self, class: u8, subclass: u8, protocol: u8) -> InterfaceAltBuilder<'_, 'd, D> {
|
||||
let number = self.next_alt_setting_number;
|
||||
self.next_alt_setting_number += 1;
|
||||
self.builder.interfaces[self.interface_number.0 as usize].num_alt_settings += 1;
|
||||
|
||||
self.builder.config_descriptor.interface_alt(
|
||||
self.interface_number,
|
||||
number,
|
||||
class,
|
||||
subclass,
|
||||
protocol,
|
||||
None,
|
||||
);
|
||||
self.builder
|
||||
.config_descriptor
|
||||
.interface_alt(self.interface_number, number, class, subclass, protocol, None);
|
||||
|
||||
InterfaceAltBuilder {
|
||||
builder: self.builder,
|
||||
@ -365,17 +345,10 @@ impl<'a, 'd, D: Driver<'d>> InterfaceAltBuilder<'a, 'd, D> {
|
||||
/// Descriptors are written in the order builder functions are called. Note that some
|
||||
/// classes care about the order.
|
||||
pub fn descriptor(&mut self, descriptor_type: u8, descriptor: &[u8]) {
|
||||
self.builder
|
||||
.config_descriptor
|
||||
.write(descriptor_type, descriptor)
|
||||
self.builder.config_descriptor.write(descriptor_type, descriptor)
|
||||
}
|
||||
|
||||
fn endpoint_in(
|
||||
&mut self,
|
||||
ep_type: EndpointType,
|
||||
max_packet_size: u16,
|
||||
interval: u8,
|
||||
) -> D::EndpointIn {
|
||||
fn endpoint_in(&mut self, ep_type: EndpointType, max_packet_size: u16, interval: u8) -> D::EndpointIn {
|
||||
let ep = self
|
||||
.builder
|
||||
.driver
|
||||
@ -387,12 +360,7 @@ impl<'a, 'd, D: Driver<'d>> InterfaceAltBuilder<'a, 'd, D> {
|
||||
ep
|
||||
}
|
||||
|
||||
fn endpoint_out(
|
||||
&mut self,
|
||||
ep_type: EndpointType,
|
||||
max_packet_size: u16,
|
||||
interval: u8,
|
||||
) -> D::EndpointOut {
|
||||
fn endpoint_out(&mut self, ep_type: EndpointType, max_packet_size: u16, interval: u8) -> D::EndpointOut {
|
||||
let ep = self
|
||||
.builder
|
||||
.driver
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::builder::Config;
|
||||
use super::{types::*, CONFIGURATION_VALUE};
|
||||
use super::types::*;
|
||||
use super::CONFIGURATION_VALUE;
|
||||
|
||||
/// Standard descriptor types
|
||||
#[allow(missing_docs)]
|
||||
@ -113,11 +114,7 @@ impl<'a> DescriptorWriter<'a> {
|
||||
CONFIGURATION_VALUE, // bConfigurationValue
|
||||
0, // iConfiguration
|
||||
0x80 | if config.self_powered { 0x40 } else { 0x00 }
|
||||
| if config.supports_remote_wakeup {
|
||||
0x20
|
||||
} else {
|
||||
0x00
|
||||
}, // bmAttributes
|
||||
| if config.supports_remote_wakeup { 0x20 } else { 0x00 }, // bmAttributes
|
||||
(config.max_power / 2) as u8, // bMaxPower
|
||||
],
|
||||
)
|
||||
|
@ -161,18 +161,12 @@ pub trait ControlPipe {
|
||||
///
|
||||
/// Must be called after `setup()` for requests with `direction` of `Out`
|
||||
/// and `length` greater than zero.
|
||||
fn data_out<'a>(
|
||||
&'a mut self,
|
||||
buf: &'a mut [u8],
|
||||
first: bool,
|
||||
last: bool,
|
||||
) -> Self::DataOutFuture<'a>;
|
||||
fn data_out<'a>(&'a mut self, buf: &'a mut [u8], first: bool, last: bool) -> Self::DataOutFuture<'a>;
|
||||
|
||||
/// Sends a DATA IN packet with `data` in response to a control read request.
|
||||
///
|
||||
/// If `last_packet` is true, the STATUS packet will be ACKed following the transfer of `data`.
|
||||
fn data_in<'a>(&'a mut self, data: &'a [u8], first: bool, last: bool)
|
||||
-> Self::DataInFuture<'a>;
|
||||
fn data_in<'a>(&'a mut self, data: &'a [u8], first: bool, last: bool) -> Self::DataInFuture<'a>;
|
||||
|
||||
/// Accepts a control request.
|
||||
///
|
||||
|
@ -15,16 +15,13 @@ pub mod types;
|
||||
use embassy::util::{select, Either};
|
||||
use heapless::Vec;
|
||||
|
||||
use crate::descriptor_reader::foreach_endpoint;
|
||||
use crate::driver::ControlPipe;
|
||||
|
||||
pub use self::builder::{Builder, Config};
|
||||
use self::control::*;
|
||||
use self::descriptor::*;
|
||||
use self::driver::{Bus, Driver, Event};
|
||||
use self::types::*;
|
||||
|
||||
pub use self::builder::Builder;
|
||||
pub use self::builder::Config;
|
||||
use crate::descriptor_reader::foreach_endpoint;
|
||||
use crate::driver::ControlPipe;
|
||||
|
||||
/// The global state of the USB device.
|
||||
///
|
||||
@ -418,10 +415,8 @@ impl<'d, D: Driver<'d>> Inner<'d, D> {
|
||||
// Enable all endpoints of selected alt settings.
|
||||
foreach_endpoint(self.config_descriptor, |ep| {
|
||||
let iface = &self.interfaces[ep.interface as usize];
|
||||
self.bus.endpoint_set_enabled(
|
||||
ep.ep_address,
|
||||
iface.current_alt_setting == ep.interface_alt,
|
||||
);
|
||||
self.bus
|
||||
.endpoint_set_enabled(ep.ep_address, iface.current_alt_setting == ep.interface_alt);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
@ -474,10 +469,8 @@ impl<'d, D: Driver<'d>> Inner<'d, D> {
|
||||
// Enable/disable EPs of this interface as needed.
|
||||
foreach_endpoint(self.config_descriptor, |ep| {
|
||||
if ep.interface == req.index as u8 {
|
||||
self.bus.endpoint_set_enabled(
|
||||
ep.ep_address,
|
||||
iface.current_alt_setting == ep.interface_alt,
|
||||
);
|
||||
self.bus
|
||||
.endpoint_set_enabled(ep.ep_address, iface.current_alt_setting == ep.interface_alt);
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
|
Reference in New Issue
Block a user