From 0cf2c4e116d10211cfef4e87117d9550a542d49c Mon Sep 17 00:00:00 2001 From: ROMemories Date: Thu, 22 Feb 2024 17:31:43 +0100 Subject: [PATCH] tests(embassy): complete the usb dummy arch module --- src/riot-rs-embassy/src/arch/dummy.rs | 153 +++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 5 deletions(-) diff --git a/src/riot-rs-embassy/src/arch/dummy.rs b/src/riot-rs-embassy/src/arch/dummy.rs index 295b84d89..f6147e5b9 100644 --- a/src/riot-rs-embassy/src/arch/dummy.rs +++ b/src/riot-rs-embassy/src/arch/dummy.rs @@ -3,7 +3,6 @@ /// Dummy type. /// /// See the `OptionalPeripherals` type of your Embassy architecture crate instead. -#[derive(Default)] pub struct OptionalPeripherals; /// Dummy type. @@ -21,23 +20,28 @@ mod executor { pub struct Executor; impl Executor { + #[allow(clippy::new_without_default)] pub const fn new() -> Self { + // Actually return a value instead of marking it unimplemented like other dummy + // functions, because this function is const and is thus run during compilation Self {} } - pub fn start(&self, _: super::SWI) {} + pub fn start(&self, _: super::SWI) { + unimplemented!(); + } pub fn spawner(&self) -> Spawner { - Spawner {} + unimplemented!(); } } - pub struct Spawner {} + pub struct Spawner; impl Spawner { #[allow(clippy::result_unit_err)] pub fn spawn(&self, _token: SpawnToken) -> Result<(), ()> { - Ok(()) + unimplemented!(); } } } @@ -51,3 +55,142 @@ pub fn init(_config: Config) -> OptionalPeripherals { } pub struct SWI; + +#[cfg(feature = "usb")] +pub mod usb { + use embassy_usb::driver::{ + Bus, ControlPipe, Driver, Endpoint, EndpointAddress, EndpointAllocError, EndpointError, + EndpointIn, EndpointInfo, EndpointOut, EndpointType, Event, Unsupported, + }; + + use super::OptionalPeripherals; + + pub struct UsbDriver; + + impl<'a> Driver<'a> for UsbDriver { + type EndpointOut = DummyEndpointOut; + type EndpointIn = DummyEndpointIn; + type ControlPipe = DummyControlPipe; + type Bus = DummyBus; + + fn alloc_endpoint_out( + &mut self, + _ep_type: EndpointType, + _max_packet_size: u16, + _interval_ms: u8, + ) -> Result { + unimplemented!(); + } + fn alloc_endpoint_in( + &mut self, + _ep_type: EndpointType, + _max_packet_size: u16, + _interval_ms: u8, + ) -> Result { + unimplemented!(); + } + fn start(self, _control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) { + unimplemented!(); + } + } + + pub fn driver(_peripherals: &mut OptionalPeripherals) -> UsbDriver { + unimplemented!(); + } + + pub struct DummyEndpointOut; + + impl Endpoint for DummyEndpointOut { + fn info(&self) -> &EndpointInfo { + unimplemented!(); + } + async fn wait_enabled(&mut self) { + unimplemented!(); + } + } + + impl EndpointOut for DummyEndpointOut { + async fn read(&mut self, _buf: &mut [u8]) -> Result { + unimplemented!(); + } + } + + pub struct DummyEndpointIn; + + impl Endpoint for DummyEndpointIn { + fn info(&self) -> &EndpointInfo { + unimplemented!(); + } + async fn wait_enabled(&mut self) { + unimplemented!(); + } + } + + impl EndpointIn for DummyEndpointIn { + async fn write(&mut self, _buf: &[u8]) -> Result<(), EndpointError> { + unimplemented!(); + } + } + + pub struct DummyControlPipe; + + impl ControlPipe for DummyControlPipe { + fn max_packet_size(&self) -> usize { + unimplemented!(); + } + async fn setup(&mut self) -> [u8; 8] { + unimplemented!(); + } + async fn data_out( + &mut self, + _buf: &mut [u8], + _first: bool, + _last: bool, + ) -> Result { + unimplemented!(); + } + async fn data_in( + &mut self, + _data: &[u8], + _first: bool, + _last: bool, + ) -> Result<(), EndpointError> { + unimplemented!(); + } + async fn accept(&mut self) { + unimplemented!(); + } + async fn reject(&mut self) { + unimplemented!(); + } + async fn accept_set_address(&mut self, _addr: u8) { + unimplemented!(); + } + } + + pub struct DummyBus; + + impl Bus for DummyBus { + async fn enable(&mut self) { + unimplemented!(); + } + async fn disable(&mut self) { + unimplemented!(); + } + async fn poll(&mut self) -> Event { + unimplemented!(); + } + fn endpoint_set_enabled(&mut self, _ep_addr: EndpointAddress, _enabled: bool) { + unimplemented!(); + } + fn endpoint_set_stalled(&mut self, _ep_addr: EndpointAddress, _stalled: bool) { + unimplemented!(); + } + fn endpoint_is_stalled(&mut self, _ep_addr: EndpointAddress) -> bool { + unimplemented!(); + } + async fn remote_wakeup(&mut self) -> Result<(), Unsupported> { + unimplemented!(); + } + } +}