usb: make max interface count configurable at compile time.

This commit is contained in:
Dario Nieuwenhuis
2023-02-07 20:49:10 +01:00
parent 4a224efe75
commit 1d841cc8ac
6 changed files with 212 additions and 5 deletions

View File

@ -308,7 +308,10 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> {
};
if self.builder.interfaces.push(iface).is_err() {
panic!("max interface count reached")
panic!(
"embassy-usb: interface list full. Increase the `max_interface_count` compile-time setting. Current value: {}",
MAX_INTERFACE_COUNT
)
}
InterfaceBuilder {

View File

@ -16,10 +16,16 @@ mod descriptor_reader;
pub mod msos;
pub mod types;
mod config {
#![allow(unused)]
include!(concat!(env!("OUT_DIR"), "/config.rs"));
}
use embassy_futures::select::{select, Either};
use heapless::Vec;
pub use crate::builder::{Builder, Config};
use crate::config::*;
use crate::control::*;
use crate::descriptor::*;
use crate::descriptor_reader::foreach_endpoint;
@ -71,9 +77,6 @@ pub const CONFIGURATION_NONE: u8 = 0;
/// The bConfiguration value for the single configuration supported by this device.
pub const CONFIGURATION_VALUE: u8 = 1;
/// Maximum interface count, configured at compile time.
pub const MAX_INTERFACE_COUNT: usize = 4;
const STRING_INDEX_MANUFACTURER: u8 = 1;
const STRING_INDEX_PRODUCT: u8 = 2;
const STRING_INDEX_SERIAL_NUMBER: u8 = 3;