mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 00:02:28 +00:00
usb: rename UsbDeviceBuilder -> Builder.
This commit is contained in:
parent
1c9adec3c5
commit
1bf7b4d6c3
@ -16,7 +16,7 @@ use embassy_usb::driver::EndpointOut;
|
||||
use embassy_usb::{
|
||||
control::{ControlHandler, InResponse, OutResponse, Request, RequestType},
|
||||
driver::{Driver, Endpoint, EndpointError, EndpointIn},
|
||||
UsbDeviceBuilder,
|
||||
Builder,
|
||||
};
|
||||
|
||||
#[cfg(feature = "usbd-hid")]
|
||||
@ -98,7 +98,7 @@ pub struct HidReaderWriter<'d, D: Driver<'d>, const READ_N: usize, const WRITE_N
|
||||
}
|
||||
|
||||
fn build<'d, D: Driver<'d>>(
|
||||
builder: &mut UsbDeviceBuilder<'d, D>,
|
||||
builder: &mut Builder<'d, D>,
|
||||
state: &'d mut State<'d>,
|
||||
config: Config<'d>,
|
||||
with_out_endpoint: bool,
|
||||
@ -160,11 +160,7 @@ impl<'d, D: Driver<'d>, const READ_N: usize, const WRITE_N: usize>
|
||||
/// This will allocate one IN and one OUT endpoints. If you only need writing (sending)
|
||||
/// HID reports, consider using [`HidWriter::new`] instead, which allocates an IN endpoint only.
|
||||
///
|
||||
pub fn new(
|
||||
builder: &mut UsbDeviceBuilder<'d, D>,
|
||||
state: &'d mut State<'d>,
|
||||
config: Config<'d>,
|
||||
) -> Self {
|
||||
pub fn new(builder: &mut Builder<'d, D>, state: &'d mut State<'d>, config: Config<'d>) -> Self {
|
||||
let (ep_out, ep_in, offset) = build(builder, state, config, true);
|
||||
|
||||
Self {
|
||||
@ -246,11 +242,7 @@ impl<'d, D: Driver<'d>, const N: usize> HidWriter<'d, D, N> {
|
||||
/// HID reports. A lower value means better throughput & latency, at the expense
|
||||
/// of CPU on the device & bandwidth on the bus. A value of 10 is reasonable for
|
||||
/// high performance uses, and a value of 255 is good for best-effort usecases.
|
||||
pub fn new(
|
||||
builder: &mut UsbDeviceBuilder<'d, D>,
|
||||
state: &'d mut State<'d>,
|
||||
config: Config<'d>,
|
||||
) -> Self {
|
||||
pub fn new(builder: &mut Builder<'d, D>, state: &'d mut State<'d>, config: Config<'d>) -> Self {
|
||||
let (ep_out, ep_in, _offset) = build(builder, state, config, false);
|
||||
|
||||
assert!(ep_out.is_none());
|
||||
|
@ -11,7 +11,7 @@ use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use embassy::blocking_mutex::CriticalSectionMutex;
|
||||
use embassy_usb::control::{self, ControlHandler, InResponse, OutResponse, Request};
|
||||
use embassy_usb::driver::{Endpoint, EndpointError, EndpointIn, EndpointOut};
|
||||
use embassy_usb::{driver::Driver, types::*, UsbDeviceBuilder};
|
||||
use embassy_usb::{driver::Driver, types::*, Builder};
|
||||
|
||||
/// This should be used as `device_class` when building the `UsbDevice`.
|
||||
pub const USB_CLASS_CDC: u8 = 0x02;
|
||||
@ -163,7 +163,7 @@ impl<'d, D: Driver<'d>> CdcAcmClass<'d, D> {
|
||||
/// Creates a new CdcAcmClass with the provided UsbBus and max_packet_size in bytes. For
|
||||
/// full-speed devices, max_packet_size has to be one of 8, 16, 32 or 64.
|
||||
pub fn new(
|
||||
builder: &mut UsbDeviceBuilder<'d, D>,
|
||||
builder: &mut Builder<'d, D>,
|
||||
state: &'d mut State<'d>,
|
||||
max_packet_size: u16,
|
||||
) -> Self {
|
||||
|
@ -118,7 +118,7 @@ impl<'a> Config<'a> {
|
||||
}
|
||||
|
||||
/// Used to build new [`UsbDevice`]s.
|
||||
pub struct UsbDeviceBuilder<'d, D: Driver<'d>> {
|
||||
pub struct Builder<'d, D: Driver<'d>> {
|
||||
config: Config<'d>,
|
||||
handler: Option<&'d dyn DeviceStateHandler>,
|
||||
interfaces: Vec<(u8, &'d mut dyn ControlHandler), MAX_INTERFACE_COUNT>,
|
||||
@ -134,7 +134,7 @@ pub struct UsbDeviceBuilder<'d, D: Driver<'d>> {
|
||||
pub bos_descriptor: BosWriter<'d>,
|
||||
}
|
||||
|
||||
impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
|
||||
impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
/// Creates a builder for constructing a new [`UsbDevice`].
|
||||
///
|
||||
/// `control_buf` is a buffer used for USB control request data. It should be sized
|
||||
@ -175,7 +175,7 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
|
||||
config_descriptor.configuration(&config);
|
||||
bos_descriptor.bos();
|
||||
|
||||
UsbDeviceBuilder {
|
||||
Builder {
|
||||
driver,
|
||||
handler,
|
||||
config,
|
||||
|
@ -19,8 +19,8 @@ use self::descriptor::*;
|
||||
use self::driver::{Bus, Driver, Event};
|
||||
use self::types::*;
|
||||
|
||||
pub use self::builder::Builder;
|
||||
pub use self::builder::Config;
|
||||
pub use self::builder::UsbDeviceBuilder;
|
||||
|
||||
/// The global state of the USB device.
|
||||
///
|
||||
|
@ -17,7 +17,7 @@ use embassy_nrf::pac;
|
||||
use embassy_nrf::usb::Driver;
|
||||
use embassy_nrf::Peripherals;
|
||||
use embassy_usb::control::OutResponse;
|
||||
use embassy_usb::{Config, DeviceStateHandler, UsbDeviceBuilder};
|
||||
use embassy_usb::{Builder, Config, DeviceStateHandler};
|
||||
use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State};
|
||||
use futures::future::join;
|
||||
use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor};
|
||||
@ -77,7 +77,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
|
||||
let mut state = State::new();
|
||||
|
||||
let mut builder = UsbDeviceBuilder::new(
|
||||
let mut builder = Builder::new(
|
||||
driver,
|
||||
config,
|
||||
&mut device_descriptor,
|
||||
|
@ -12,7 +12,7 @@ use embassy_nrf::pac;
|
||||
use embassy_nrf::usb::Driver;
|
||||
use embassy_nrf::Peripherals;
|
||||
use embassy_usb::control::OutResponse;
|
||||
use embassy_usb::{Config, UsbDeviceBuilder};
|
||||
use embassy_usb::{Builder, Config};
|
||||
use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State};
|
||||
use futures::future::join;
|
||||
use usbd_hid::descriptor::{MouseReport, SerializedDescriptor};
|
||||
@ -54,7 +54,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
|
||||
let mut state = State::new();
|
||||
|
||||
let mut builder = UsbDeviceBuilder::new(
|
||||
let mut builder = Builder::new(
|
||||
driver,
|
||||
config,
|
||||
&mut device_descriptor,
|
||||
|
@ -11,7 +11,7 @@ use embassy_nrf::pac;
|
||||
use embassy_nrf::usb::{Driver, Instance};
|
||||
use embassy_nrf::Peripherals;
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::{Config, UsbDeviceBuilder};
|
||||
use embassy_usb::{Builder, Config};
|
||||
use embassy_usb_serial::{CdcAcmClass, State};
|
||||
use futures::future::join;
|
||||
|
||||
@ -47,7 +47,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
|
||||
let mut state = State::new();
|
||||
|
||||
let mut builder = UsbDeviceBuilder::new(
|
||||
let mut builder = Builder::new(
|
||||
driver,
|
||||
config,
|
||||
&mut device_descriptor,
|
||||
|
@ -12,7 +12,7 @@ use embassy_nrf::usb::Driver;
|
||||
use embassy_nrf::Peripherals;
|
||||
use embassy_nrf::{interrupt, peripherals};
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::{Config, UsbDevice, UsbDeviceBuilder};
|
||||
use embassy_usb::{Builder, Config, UsbDevice};
|
||||
use embassy_usb_serial::{CdcAcmClass, State};
|
||||
|
||||
use defmt_rtt as _; // global logger
|
||||
@ -72,7 +72,7 @@ async fn main(spawner: Spawner, p: Peripherals) {
|
||||
});
|
||||
|
||||
// Create embassy-usb DeviceBuilder using the driver and config.
|
||||
let mut builder = UsbDeviceBuilder::new(
|
||||
let mut builder = Builder::new(
|
||||
driver,
|
||||
config,
|
||||
&mut res.device_descriptor,
|
||||
|
Loading…
Reference in New Issue
Block a user