@@ -6,6 +6,20 @@ use crate::class_prelude::*;
66use crate :: device:: { UsbDevice , UsbDeviceBuilder , UsbVidPid } ;
77use crate :: descriptor;
88
9+ #[ cfg( feature = "test-class-highspeed" ) ]
10+ mod sizes {
11+ pub const BUFFER : usize = 1024 ;
12+ pub const BULK_ENDPOINT : u16 = 512 ;
13+ pub const INTERRUPT_ENDPOINT : u16 = 1024 ;
14+ }
15+
16+ #[ cfg( not( feature = "test-class-highspeed" ) ) ]
17+ mod sizes {
18+ pub const BUFFER : usize = 256 ;
19+ pub const BULK_ENDPOINT : u16 = 64 ;
20+ pub const INTERRUPT_ENDPOINT : u16 = 31 ;
21+ }
22+
923/// Test USB class for testing USB driver implementations. Supports various endpoint types and
1024/// requests for testing USB peripheral drivers on actual hardware.
1125pub struct TestClass < ' a , B : UsbBus > {
@@ -15,9 +29,9 @@ pub struct TestClass<'a, B: UsbBus> {
1529 ep_bulk_out : EndpointOut < ' a , B > ,
1630 ep_interrupt_in : EndpointIn < ' a , B > ,
1731 ep_interrupt_out : EndpointOut < ' a , B > ,
18- control_buf : [ u8 ; 256 ] ,
19- bulk_buf : [ u8 ; 256 ] ,
20- interrupt_buf : [ u8 ; 256 ] ,
32+ control_buf : [ u8 ; sizes :: BUFFER ] ,
33+ bulk_buf : [ u8 ; sizes :: BUFFER ] ,
34+ interrupt_buf : [ u8 ; sizes :: BUFFER ] ,
2135 len : usize ,
2236 i : usize ,
2337 bench : bool ,
@@ -43,19 +57,20 @@ pub const REQ_UNKNOWN: u8 = 42;
4357
4458pub const LONG_DATA : & ' static [ u8 ] = & [ 0x17 ; 257 ] ;
4559
60+
4661impl < B : UsbBus > TestClass < ' _ , B > {
4762 /// Creates a new TestClass.
4863 pub fn new ( alloc : & UsbBusAllocator < B > ) -> TestClass < ' _ , B > {
4964 TestClass {
5065 custom_string : alloc. string ( ) ,
5166 iface : alloc. interface ( ) ,
52- ep_bulk_in : alloc. bulk ( 64 ) ,
53- ep_bulk_out : alloc. bulk ( 64 ) ,
54- ep_interrupt_in : alloc. interrupt ( 31 , 1 ) ,
55- ep_interrupt_out : alloc. interrupt ( 31 , 1 ) ,
56- control_buf : [ 0 ; 256 ] ,
57- bulk_buf : [ 0 ; 256 ] ,
58- interrupt_buf : [ 0 ; 256 ] ,
67+ ep_bulk_in : alloc. bulk ( sizes :: BULK_ENDPOINT ) ,
68+ ep_bulk_out : alloc. bulk ( sizes :: BULK_ENDPOINT ) ,
69+ ep_interrupt_in : alloc. interrupt ( sizes :: INTERRUPT_ENDPOINT , 1 ) ,
70+ ep_interrupt_out : alloc. interrupt ( sizes :: INTERRUPT_ENDPOINT , 1 ) ,
71+ control_buf : [ 0 ; sizes :: BUFFER ] ,
72+ bulk_buf : [ 0 ; sizes :: BUFFER ] ,
73+ interrupt_buf : [ 0 ; sizes :: BUFFER ] ,
5974 len : 0 ,
6075 i : 0 ,
6176 bench : false ,
0 commit comments