Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#
Expand Down
19 changes: 16 additions & 3 deletions src/control_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down