diff options
Diffstat (limited to 'embassy-usb/src')
| -rw-r--r-- | embassy-usb/src/control.rs | 4 | ||||
| -rw-r--r-- | embassy-usb/src/driver.rs | 30 |
2 files changed, 11 insertions, 23 deletions
diff --git a/embassy-usb/src/control.rs b/embassy-usb/src/control.rs index 7c46812bd..a613f1145 100644 --- a/embassy-usb/src/control.rs +++ b/embassy-usb/src/control.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::mem; | 1 | use core::mem; |
| 2 | 2 | ||
| 3 | use crate::descriptor::DescriptorWriter; | 3 | use crate::descriptor::DescriptorWriter; |
| 4 | use crate::driver::{self, ReadError}; | 4 | use crate::driver::{self, EndpointError}; |
| 5 | use crate::DEFAULT_ALTERNATE_SETTING; | 5 | use crate::DEFAULT_ALTERNATE_SETTING; |
| 6 | 6 | ||
| 7 | use super::types::*; | 7 | use super::types::*; |
| @@ -253,7 +253,7 @@ impl<C: driver::ControlPipe> ControlPipe<C> { | |||
| 253 | &mut self, | 253 | &mut self, |
| 254 | buf: &'a mut [u8], | 254 | buf: &'a mut [u8], |
| 255 | stage: DataOutStage, | 255 | stage: DataOutStage, |
| 256 | ) -> Result<(&'a [u8], StatusStage), ReadError> { | 256 | ) -> Result<(&'a [u8], StatusStage), EndpointError> { |
| 257 | if stage.length == 0 { | 257 | if stage.length == 0 { |
| 258 | Ok((&[], StatusStage {})) | 258 | Ok((&[], StatusStage {})) |
| 259 | } else { | 259 | } else { |
diff --git a/embassy-usb/src/driver.rs b/embassy-usb/src/driver.rs index 01eb3d577..875ceafcb 100644 --- a/embassy-usb/src/driver.rs +++ b/embassy-usb/src/driver.rs | |||
| @@ -130,7 +130,7 @@ pub trait Endpoint { | |||
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | pub trait EndpointOut: Endpoint { | 132 | pub trait EndpointOut: Endpoint { |
| 133 | type ReadFuture<'a>: Future<Output = Result<usize, ReadError>> + 'a | 133 | type ReadFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a |
| 134 | where | 134 | where |
| 135 | Self: 'a; | 135 | Self: 'a; |
| 136 | 136 | ||
| @@ -145,10 +145,10 @@ pub trait ControlPipe { | |||
| 145 | type SetupFuture<'a>: Future<Output = Request> + 'a | 145 | type SetupFuture<'a>: Future<Output = Request> + 'a |
| 146 | where | 146 | where |
| 147 | Self: 'a; | 147 | Self: 'a; |
| 148 | type DataOutFuture<'a>: Future<Output = Result<usize, ReadError>> + 'a | 148 | type DataOutFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a |
| 149 | where | 149 | where |
| 150 | Self: 'a; | 150 | Self: 'a; |
| 151 | type DataInFuture<'a>: Future<Output = Result<(), WriteError>> + 'a | 151 | type DataInFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a |
| 152 | where | 152 | where |
| 153 | Self: 'a; | 153 | Self: 'a; |
| 154 | 154 | ||
| @@ -181,7 +181,7 @@ pub trait ControlPipe { | |||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | pub trait EndpointIn: Endpoint { | 183 | pub trait EndpointIn: Endpoint { |
| 184 | type WriteFuture<'a>: Future<Output = Result<(), WriteError>> + 'a | 184 | type WriteFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a |
| 185 | where | 185 | where |
| 186 | Self: 'a; | 186 | Self: 'a; |
| 187 | 187 | ||
| @@ -216,24 +216,12 @@ pub struct Unsupported; | |||
| 216 | 216 | ||
| 217 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | 217 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] |
| 218 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 218 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 219 | /// Errors returned by [`EndpointIn::write`] | 219 | /// Errors returned by [`EndpointIn::write`] and [`EndpointOut::read`] |
| 220 | pub enum WriteError { | 220 | pub enum EndpointError { |
| 221 | /// The packet is too long to fit in the | 221 | /// Either the packet to be written is too long to fit in the transmission |
| 222 | /// transmission buffer. This is generally an error in the class implementation, because the | 222 | /// buffer or the received packet is too long to fit in `buf`. |
| 223 | /// class shouldn't provide more data than the `max_packet_size` it specified when allocating | ||
| 224 | /// the endpoint. | ||
| 225 | BufferOverflow, | 223 | BufferOverflow, |
| 226 | Disabled, | ||
| 227 | } | ||
| 228 | 224 | ||
| 229 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | 225 | /// The endpoint is disabled. |
| 230 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 231 | /// Errors returned by [`EndpointOut::read`] | ||
| 232 | pub enum ReadError { | ||
| 233 | /// The received packet is too long to | ||
| 234 | /// fit in `buf`. This is generally an error in the class implementation, because the class | ||
| 235 | /// should use a buffer that is large enough for the `max_packet_size` it specified when | ||
| 236 | /// allocating the endpoint. | ||
| 237 | BufferOverflow, | ||
| 238 | Disabled, | 226 | Disabled, |
| 239 | } | 227 | } |
