diff --git a/CHANGELOG.md b/CHANGELOG.md index 85cbde20..b89b7e93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - Adapt RISC-V specific codegen for `riscv-peripheral` v0.3.0 rework - Include `riscv-peripheral` peripherals in `Peripherals` struct +- `repr(transparent)` for field wrapper ## [v0.36.1] - 2025-04-04 diff --git a/src/generate/register.rs b/src/generate/register.rs index 7622ba71..e9c1c4a0 100644 --- a/src/generate/register.rs +++ b/src/generate/register.rs @@ -1497,12 +1497,6 @@ fn add_with_no_variants( .as_ref() .map(|feature| quote!(#[cfg_attr(feature = #feature, derive(defmt::Format))])); - let cast = if fty == "bool" { - quote! { val.0 as u8 != 0 } - } else { - quote! { val.0 as _ } - }; - let desc = if let Some(rv) = reset_value { format!("{desc}\n\nValue on reset: {rv}") } else { @@ -1513,11 +1507,12 @@ fn add_with_no_variants( #[doc = #desc] #defmt #[derive(Clone, Copy, Debug, PartialEq, Eq)] + #[repr(transparent)] pub struct #pc(#fty); impl From<#pc> for #fty { #[inline(always)] fn from(val: #pc) -> Self { - #cast + val.0 } } });