usb: builtin handling of interface alternate settings

The stack reads its own descriptors to figure out which endpoints
are used in which alt settings, and enables/disables them as needed.

The ControlHandler has a callback so it can get notified of alternate
setting changes, which is purely informative (it doesn't have to do anything).
This commit is contained in:
Dario Nieuwenhuis
2022-04-16 04:47:27 +02:00
parent ea0a701ebd
commit 092c2b7dfe
9 changed files with 357 additions and 146 deletions

View File

@ -1,5 +1,5 @@
use super::builder::Config;
use super::{types::*, CONFIGURATION_VALUE, DEFAULT_ALTERNATE_SETTING};
use super::{types::*, CONFIGURATION_VALUE};
/// Standard descriptor types
#[allow(missing_docs)]
@ -192,7 +192,7 @@ impl<'a> DescriptorWriter<'a> {
interface_protocol: u8,
interface_string: Option<StringIndex>,
) {
if alternate_setting == DEFAULT_ALTERNATE_SETTING {
if alternate_setting == 0 {
match self.num_interfaces_mark {
Some(mark) => self.buf[mark] += 1,
None => {