aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb/src/lib.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-01-31 22:27:19 +0100
committerDario Nieuwenhuis <[email protected]>2023-01-31 22:27:19 +0100
commitca10fe7135d10084e38038f3cd433da39e505bea (patch)
tree075aca4a76caccd1bba95869c64bbb838969c8b1 /embassy-usb/src/lib.rs
parent4c1946454874597c358e7c7d5bf555b687376a5b (diff)
usb: docs
Diffstat (limited to 'embassy-usb/src/lib.rs')
-rw-r--r--embassy-usb/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs
index 096e8b07a..2656af29d 100644
--- a/embassy-usb/src/lib.rs
+++ b/embassy-usb/src/lib.rs
@@ -1,5 +1,7 @@
1#![no_std] 1#![no_std]
2#![feature(type_alias_impl_trait)] 2#![feature(type_alias_impl_trait)]
3#![doc = include_str!("../README.md")]
4#![warn(missing_docs)]
3 5
4// This mod MUST go first, so that the others see its macros. 6// This mod MUST go first, so that the others see its macros.
5pub(crate) mod fmt; 7pub(crate) mod fmt;
@@ -46,10 +48,13 @@ pub enum UsbDeviceState {
46 Configured, 48 Configured,
47} 49}
48 50
51/// Error returned by [`UsbDevice::remote_wakeup`].
49#[derive(PartialEq, Eq, Copy, Clone, Debug)] 52#[derive(PartialEq, Eq, Copy, Clone, Debug)]
50#[cfg_attr(feature = "defmt", derive(defmt::Format))] 53#[cfg_attr(feature = "defmt", derive(defmt::Format))]
51pub enum RemoteWakeupError { 54pub enum RemoteWakeupError {
55 /// The USB device is not suspended, or remote wakeup was not enabled.
52 InvalidState, 56 InvalidState,
57 /// The underlying driver doesn't support remote wakeup.
53 Unsupported, 58 Unsupported,
54} 59}
55 60
@@ -65,6 +70,7 @@ pub const CONFIGURATION_NONE: u8 = 0;
65/// The bConfiguration value for the single configuration supported by this device. 70/// The bConfiguration value for the single configuration supported by this device.
66pub const CONFIGURATION_VALUE: u8 = 1; 71pub const CONFIGURATION_VALUE: u8 = 1;
67 72
73/// Maximum interface count, configured at compile time.
68pub const MAX_INTERFACE_COUNT: usize = 4; 74pub const MAX_INTERFACE_COUNT: usize = 4;
69 75
70const STRING_INDEX_MANUFACTURER: u8 = 1; 76const STRING_INDEX_MANUFACTURER: u8 = 1;
@@ -100,6 +106,7 @@ struct Interface<'d> {
100 num_strings: u8, 106 num_strings: u8,
101} 107}
102 108
109/// Main struct for the USB device stack.
103pub struct UsbDevice<'d, D: Driver<'d>> { 110pub struct UsbDevice<'d, D: Driver<'d>> {
104 control_buf: &'d mut [u8], 111 control_buf: &'d mut [u8],
105 control: D::ControlPipe, 112 control: D::ControlPipe,
@@ -489,7 +496,6 @@ impl<'d, D: Driver<'d>> Inner<'d, D> {
489 .unwrap(); 496 .unwrap();
490 497
491 // TODO check it is valid (not out of range) 498 // TODO check it is valid (not out of range)
492 // TODO actually enable/disable endpoints.
493 499
494 if let Some(handler) = &mut iface.handler { 500 if let Some(handler) = &mut iface.handler {
495 handler.set_alternate_setting(new_altsetting); 501 handler.set_alternate_setting(new_altsetting);