From dab17627093faa709f309c81f067ed2b578f2a8e Mon Sep 17 00:00:00 2001
From: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Date: Thu, 29 Sep 2022 15:52:23 +0200
Subject: [PATCH] usb: remove all "Direction as u8" casts.

---
 embassy-usb-driver/src/lib.rs | 8 ++++++--
 1 file 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.
-- 
GitLab