From 58af6b59db2590c00ccf896294345ba553d01aac Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 21 Mar 2021 23:00:15 +0100 Subject: [PATCH] Add control-buffer-512 and -1024 feature flags --- Cargo.toml | 2 ++ src/control_pipe.rs | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d582a0f..79f4233 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,8 @@ rand = "0.6.1" [features] # Use a 256 byte buffer for control transfers instead of 128. control-buffer-256 = [] +control-buffer-512 = [] +control-buffer-1024 = [] # Use larger endpoint buffers for highspeed operation (default fullspeed) # diff --git a/src/control_pipe.rs b/src/control_pipe.rs index a38a0df..9f8d82b 100644 --- a/src/control_pipe.rs +++ b/src/control_pipe.rs @@ -21,10 +21,23 @@ enum ControlState { // Maximum length of control transfer data stage in bytes. 128 bytes by default. You can define the // feature "control-buffer-256" to make it 256 bytes if you have larger control transfers. -#[cfg(not(feature = "control-buffer-256"))] -const CONTROL_BUF_LEN: usize = 128; -#[cfg(feature = "control-buffer-256")] + +#[cfg(feature = "control-buffer-1024")] +const CONTROL_BUF_LEN: usize = 1024; +#[cfg(all(not(feature = "control-buffer-1024"), feature = "control-buffer-512"))] +const CONTROL_BUF_LEN: usize = 512; +#[cfg(all( + not(feature = "control-buffer-1024"), + not(feature = "control-buffer-512"), + feature = "control-buffer-256" +))] const CONTROL_BUF_LEN: usize = 256; +#[cfg(all( + not(feature = "control-buffer-1024"), + not(feature = "control-buffer-512"), + not(feature = "control-buffer-256") +))] +const CONTROL_BUF_LEN: usize = 128; /// Buffers and parses USB control transfers. pub struct ControlPipe<'a, B: UsbBus> {