diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-02-07 22:49:14 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-02-08 00:17:08 +0100 |
| commit | 3af991ab63d14cfad6f50d28bfb944d1895d1c70 (patch) | |
| tree | 575fecf6f47fbfd7116070aff2ffd5f4e84c7cf1 /embassy-usb/src/descriptor_reader.rs | |
| parent | 1d841cc8ac74feacc4d231958ce2c46419ae3bda (diff) | |
usb: unify ControlHandler+DeviceStateHandler, route all control requests to all handlers.
- Allows classes to handle vendor requests.
- Allows classes to use a single handler for multiple interfaces.
- Allows classes to access the other events (previously only `reset` was available).
Diffstat (limited to 'embassy-usb/src/descriptor_reader.rs')
| -rw-r--r-- | embassy-usb/src/descriptor_reader.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/embassy-usb/src/descriptor_reader.rs b/embassy-usb/src/descriptor_reader.rs index d64bcb73b..05adcce60 100644 --- a/embassy-usb/src/descriptor_reader.rs +++ b/embassy-usb/src/descriptor_reader.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | use crate::descriptor::descriptor_type; | 1 | use crate::descriptor::descriptor_type; |
| 2 | use crate::driver::EndpointAddress; | 2 | use crate::driver::EndpointAddress; |
| 3 | use crate::types::InterfaceNumber; | ||
| 3 | 4 | ||
| 4 | #[derive(Copy, Clone, PartialEq, Eq, Debug)] | 5 | #[derive(Copy, Clone, PartialEq, Eq, Debug)] |
| 5 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 6 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| @@ -75,7 +76,7 @@ impl<'a, 'b> Iterator for DescriptorIter<'a, 'b> { | |||
| 75 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 76 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 76 | pub struct EndpointInfo { | 77 | pub struct EndpointInfo { |
| 77 | pub configuration: u8, | 78 | pub configuration: u8, |
| 78 | pub interface: u8, | 79 | pub interface: InterfaceNumber, |
| 79 | pub interface_alt: u8, | 80 | pub interface_alt: u8, |
| 80 | pub ep_address: EndpointAddress, | 81 | pub ep_address: EndpointAddress, |
| 81 | } | 82 | } |
| @@ -83,7 +84,7 @@ pub struct EndpointInfo { | |||
| 83 | pub fn foreach_endpoint(data: &[u8], mut f: impl FnMut(EndpointInfo)) -> Result<(), ReadError> { | 84 | pub fn foreach_endpoint(data: &[u8], mut f: impl FnMut(EndpointInfo)) -> Result<(), ReadError> { |
| 84 | let mut ep = EndpointInfo { | 85 | let mut ep = EndpointInfo { |
| 85 | configuration: 0, | 86 | configuration: 0, |
| 86 | interface: 0, | 87 | interface: InterfaceNumber(0), |
| 87 | interface_alt: 0, | 88 | interface_alt: 0, |
| 88 | ep_address: EndpointAddress::from(0), | 89 | ep_address: EndpointAddress::from(0), |
| 89 | }; | 90 | }; |
| @@ -96,7 +97,7 @@ pub fn foreach_endpoint(data: &[u8], mut f: impl FnMut(EndpointInfo)) -> Result< | |||
| 96 | ep.configuration = r.read_u8()?; | 97 | ep.configuration = r.read_u8()?; |
| 97 | } | 98 | } |
| 98 | descriptor_type::INTERFACE => { | 99 | descriptor_type::INTERFACE => { |
| 99 | ep.interface = r.read_u8()?; | 100 | ep.interface = InterfaceNumber(r.read_u8()?); |
| 100 | ep.interface_alt = r.read_u8()?; | 101 | ep.interface_alt = r.read_u8()?; |
| 101 | } | 102 | } |
| 102 | descriptor_type::ENDPOINT => { | 103 | descriptor_type::ENDPOINT => { |
