diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-09-26 12:35:33 +0200 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-09-26 12:35:33 +0200 |
commit | f4f58249722bc656a13865e06535d208440c3e4a (patch) | |
tree | e5fd41f7c32bb479791d2ec16327e938efce0501 /embassy-usb-driver | |
parent | 7f7c14b7bce5b84eb27c8122535a96a6f0e5dd77 (diff) | |
download | embassy-f4f58249722bc656a13865e06535d208440c3e4a.zip |
usb: do not allow converting Directon to/from u8
Diffstat (limited to 'embassy-usb-driver')
-rw-r--r-- | embassy-usb-driver/src/lib.rs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/embassy-usb-driver/src/lib.rs b/embassy-usb-driver/src/lib.rs index 051190a4..fc29786f 100644 --- a/embassy-usb-driver/src/lib.rs +++ b/embassy-usb-driver/src/lib.rs @@ -8,20 +8,13 @@ use core::future::Future; /// /// The values of the enum also match the direction bit used in endpoint addresses and control /// request types. -#[repr(u8)] #[derive(Copy, Clone, Eq, PartialEq, Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Direction { /// Host to device (OUT) - Out = 0x00, + Out, /// Device to host (IN) - In = 0x80, -} - -impl From<u8> for Direction { - fn from(value: u8) -> Self { - unsafe { core::mem::transmute(value & 0x80) } - } + In, } /// USB endpoint transfer type. The values of this enum can be directly cast into `u8` to get the |