diff --git a/data/registers/otg_v2.json b/data/registers/otg_v2.json index baad653d..c594b716 100644 --- a/data/registers/otg_v2.json +++ b/data/registers/otg_v2.json @@ -373,7 +373,8 @@ "name": "DSPD", "description": "Device speed", "bit_offset": 0, - "bit_size": 2 + "bit_size": 2, + "enum": "DSPD" }, { "name": "NZLSOHSK", @@ -503,7 +504,8 @@ "name": "EPTYP", "description": "EPTYP", "bit_offset": 18, - "bit_size": 2 + "bit_size": 2, + "enum": "EPTYP" }, { "name": "SNPM", @@ -2264,5 +2266,46 @@ "bit_size": 1 } ] + }, + "enum/DSPD": { + "bit_size": 2, + "variants": [ + { + "name": "HIGH_SPEED", + "description": "High speed", + "value": 0 + }, + { + "name": "FULL_SPEED_EXTERNAL", + "description": "Full speed using external ULPI PHY", + "value": 1 + }, + { + "name": "FULL_SPEED_INTERNAL", + "description": "Full speed using internal embedded PHY", + "value": 3 + } + ] + }, + "enum/EPTYP": { + "bit_size": 2, + "variants": [ + { + "name": "CONTROL", + "value": 0 + }, + { + "name": "ISOCHRONOUS", + "value": 1 + }, + { + "name": "BULK", + "value": 2 + }, + { + "name": "INTERRUPT", + "value": 3 + } + ] } } \ No newline at end of file diff --git a/stm32-metapac/src/peripherals/otg_v2.rs b/stm32-metapac/src/peripherals/otg_v2.rs index 862ecc5e..57a23093 100644 --- a/stm32-metapac/src/peripherals/otg_v2.rs +++ b/stm32-metapac/src/peripherals/otg_v2.rs @@ -134,9 +134,9 @@ fn default () -> Daintmsk { Daintmsk (0) } } # [doc = "Device configuration regi # [derive (Copy , Clone , Eq , PartialEq)] pub struct Dcfg (pub u32) ; impl Dcfg { # [doc = "Device speed"] # [inline (always)] -pub const fn dspd (& self) -> u8 { let val = (self . 0 >> 0usize) & 0x03 ; val as u8 } # [doc = "Device speed"] +pub const fn dspd (& self) -> super :: vals :: Dspd { let val = (self . 0 >> 0usize) & 0x03 ; super :: vals :: Dspd :: from_bits (val as u8) } # [doc = "Device speed"] # [inline (always)] -pub fn set_dspd (& mut self , val : u8) { self . 0 = (self . 0 & ! (0x03 << 0usize)) | (((val as u32) & 0x03) << 0usize) ; } # [doc = "Non-zero-length status OUT handshake"] +pub fn set_dspd (& mut self , val : super :: vals :: Dspd) { self . 0 = (self . 0 & ! (0x03 << 0usize)) | (((val . to_bits () as u32) & 0x03) << 0usize) ; } # [doc = "Non-zero-length status OUT handshake"] # [inline (always)] pub const fn nzlsohsk (& self) -> bool { let val = (self . 0 >> 2usize) & 0x01 ; val != 0 } # [doc = "Non-zero-length status OUT handshake"] # [inline (always)] @@ -222,9 +222,9 @@ pub const fn naksts (& self) -> bool { let val = (self . 0 >> 17usize) & 0x01 ; # [inline (always)] pub fn set_naksts (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize) ; } # [doc = "EPTYP"] # [inline (always)] -pub const fn eptyp (& self) -> u8 { let val = (self . 0 >> 18usize) & 0x03 ; val as u8 } # [doc = "EPTYP"] +pub const fn eptyp (& self) -> super :: vals :: Eptyp { let val = (self . 0 >> 18usize) & 0x03 ; super :: vals :: Eptyp :: from_bits (val as u8) } # [doc = "EPTYP"] # [inline (always)] -pub fn set_eptyp (& mut self , val : u8) { self . 0 = (self . 0 & ! (0x03 << 18usize)) | (((val as u32) & 0x03) << 18usize) ; } # [doc = "SNPM"] +pub fn set_eptyp (& mut self , val : super :: vals :: Eptyp) { self . 0 = (self . 0 & ! (0x03 << 18usize)) | (((val . to_bits () as u32) & 0x03) << 18usize) ; } # [doc = "SNPM"] # [inline (always)] pub const fn snpm (& self) -> bool { let val = (self . 0 >> 20usize) & 0x01 ; val != 0 } # [doc = "SNPM"] # [inline (always)] @@ -1421,4 +1421,19 @@ pub fn set_physleep (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 < pub const fn susp (& self) -> bool { let val = (self . 0 >> 7usize) & 0x01 ; val != 0 } # [doc = "SUSP."] # [inline (always)] pub fn set_susp (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize) ; } } impl Default for Pcgcctl { # [inline (always)] -fn default () -> Pcgcctl { Pcgcctl (0) } } } \ No newline at end of file +fn default () -> Pcgcctl { Pcgcctl (0) } } } pub mod vals { # [repr (u8)] +# [derive (Copy , Clone , Eq , PartialEq , Ord , PartialOrd)] +pub enum Dspd { # [doc = "High speed"] +HIGH_SPEED = 0x0 , # [doc = "Full speed using external ULPI PHY"] +FULL_SPEED_EXTERNAL = 0x01 , _RESERVED_2 = 0x02 , # [doc = "Full speed using internal embedded PHY"] +FULL_SPEED_INTERNAL = 0x03 , } impl Dspd { # [inline (always)] +pub const fn from_bits (val : u8) -> Dspd { unsafe { core :: mem :: transmute (val & 0x03) } } # [inline (always)] +pub const fn to_bits (self) -> u8 { unsafe { core :: mem :: transmute (self) } } } impl From < u8 > for Dspd { # [inline (always)] +fn from (val : u8) -> Dspd { Dspd :: from_bits (val) } } impl From < Dspd > for u8 { # [inline (always)] +fn from (val : Dspd) -> u8 { Dspd :: to_bits (val) } } # [repr (u8)] +# [derive (Copy , Clone , Eq , PartialEq , Ord , PartialOrd)] +pub enum Eptyp { CONTROL = 0x0 , ISOCHRONOUS = 0x01 , BULK = 0x02 , INTERRUPT = 0x03 , } impl Eptyp { # [inline (always)] +pub const fn from_bits (val : u8) -> Eptyp { unsafe { core :: mem :: transmute (val & 0x03) } } # [inline (always)] +pub const fn to_bits (self) -> u8 { unsafe { core :: mem :: transmute (self) } } } impl From < u8 > for Eptyp { # [inline (always)] +fn from (val : u8) -> Eptyp { Eptyp :: from_bits (val) } } impl From < Eptyp > for u8 { # [inline (always)] +fn from (val : Eptyp) -> u8 { Eptyp :: to_bits (val) } } } \ No newline at end of file diff --git a/stm32-metapac/src/registers/otg_v2.rs b/stm32-metapac/src/registers/otg_v2.rs index 78b72be3..fb3501f4 100644 --- a/stm32-metapac/src/registers/otg_v2.rs +++ b/stm32-metapac/src/registers/otg_v2.rs @@ -966,7 +966,9 @@ ), bit_size: 2, array: None, - enumm: None, + enumm: Some( + "Dspd", + ), }, Field { name: "nzlsohsk", @@ -1266,7 +1268,9 @@ ), bit_size: 2, array: None, - enumm: None, + enumm: Some( + "Eptyp", + ), }, Field { name: "snpm", @@ -5313,6 +5317,62 @@ ], }, ], - enums: &[], + enums: &[ + Enum { + name: "Dspd", + description: None, + bit_size: 2, + variants: &[ + EnumVariant { + name: "HIGH_SPEED", + description: Some( + "High speed", + ), + value: 0, + }, + EnumVariant { + name: "FULL_SPEED_EXTERNAL", + description: Some( + "Full speed using external ULPI PHY", + ), + value: 1, + }, + EnumVariant { + name: "FULL_SPEED_INTERNAL", + description: Some( + "Full speed using internal embedded PHY", + ), + value: 3, + }, + ], + }, + Enum { + name: "Eptyp", + description: None, + bit_size: 2, + variants: &[ + EnumVariant { + name: "CONTROL", + description: None, + value: 0, + }, + EnumVariant { + name: "ISOCHRONOUS", + description: None, + value: 1, + }, + EnumVariant { + name: "BULK", + description: None, + value: 2, + }, + EnumVariant { + name: "INTERRUPT", + description: None, + value: 3, + }, + ], + }, + ], }; \ No newline at end of file