diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-09-29 13:53:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-29 13:53:22 +0000 |
commit | 1d6f5493e7764767eb592e0b90d6b07d46b100ca (patch) | |
tree | a6b0139df4ccc8acf8f57c83226207bb3cc60308 | |
parent | ebf5a92ab2c23cc6430e83109cd5762904cf2c41 (diff) | |
parent | dab17627093faa709f309c81f067ed2b578f2a8e (diff) | |
download | embassy-1d6f5493e7764767eb592e0b90d6b07d46b100ca.zip |
Merge #991
991: usb: remove all "Direction as u8" casts. r=Dirbaio a=Dirbaio
Alternative fix for #989 , see comment there for rationale.
bors r+
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
-rw-r--r-- | embassy-usb-driver/src/lib.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/embassy-usb-driver/src/lib.rs b/embassy-usb-driver/src/lib.rs index fc29786f..931e9c31 100644 --- a/embassy-usb-driver/src/lib.rs +++ b/embassy-usb-driver/src/lib.rs @@ -54,12 +54,16 @@ impl From<EndpointAddress> for u8 { } impl EndpointAddress { - const INBITS: u8 = Direction::In as u8; + const INBITS: u8 = 0x80; /// Constructs a new EndpointAddress with the given index and direction. #[inline] pub fn from_parts(index: usize, dir: Direction) -> Self { - EndpointAddress(index as u8 | dir as u8) + let dir_u8 = match dir { + Direction::Out => 0x00, + Direction::In => Self::INBITS, + }; + EndpointAddress(index as u8 | dir_u8) } /// Gets the direction part of the address. |