diff --git a/src/generate/peripheral.rs b/src/generate/peripheral.rs index 5c37aa5c..47071384 100644 --- a/src/generate/peripheral.rs +++ b/src/generate/peripheral.rs @@ -54,7 +54,8 @@ pub fn render( impl #name_pc { /// Returns a pointer to the register block - pub fn ptr() -> *const #base::RegisterBlock { + #[inline(always)] + pub const fn ptr() -> *const #base::RegisterBlock { #address as *const _ } } diff --git a/src/generate/register.rs b/src/generate/register.rs index 23adccad..66e24b31 100644 --- a/src/generate/register.rs +++ b/src/generate/register.rs @@ -42,7 +42,7 @@ pub fn render( if access == Access::ReadWrite { reg_impl_items.push(quote! { /// Modifies the contents of the register - #[inline] + #[inline(always)] pub fn modify(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W @@ -56,7 +56,7 @@ pub fn render( if access == Access::ReadOnly || access == Access::ReadWrite { reg_impl_items.push(quote! { /// Reads the contents of the register - #[inline] + #[inline(always)] pub fn read(&self) -> R { R { bits: self.register.get() } } @@ -71,7 +71,7 @@ pub fn render( r_impl_items.push(quote! { /// Value of the register as raw bits - #[inline] + #[inline(always)] pub fn bits(&self) -> #rty { self.bits } @@ -81,7 +81,7 @@ pub fn render( if access == Access::WriteOnly || access == Access::ReadWrite { reg_impl_items.push(quote! { /// Writes to the register - #[inline] + #[inline(always)] pub fn write(&self, f: F) where F: FnOnce(&mut W) -> &mut W @@ -105,12 +105,12 @@ pub fn render( reg_impl_items.push(quote! { /// Reset value of the register - #[inline] + #[inline(always)] pub const fn reset_value() -> #rty { #rv } /// Writes the reset value to the register - #[inline] + #[inline(always)] pub fn reset(&self) { self.register.set(Self::reset_value()) } @@ -118,7 +118,7 @@ pub fn render( w_impl_items.push(quote! { /// Writes raw bits to the register - #[inline] + #[inline(always)] pub #unsafety fn bits(&mut self, bits: #rty) -> &mut Self { self.bits = bits; self @@ -365,7 +365,7 @@ pub fn fields( let sc = &f.sc; r_impl_items.push(quote! { #[doc = #description] - #[inline] + #[inline(always)] pub fn #sc(&self) -> #pc_r { #pc_r::_from( #value ) } @@ -421,13 +421,13 @@ pub fn fields( if f.width == 1 { enum_items.push(quote! { /// Returns `true` if the bit is clear (0) - #[inline] + #[inline(always)] pub fn bit_is_clear(&self) -> bool { !self.#bits() } /// Returns `true` if the bit is set (1) - #[inline] + #[inline(always)] pub fn bit_is_set(&self) -> bool { self.#bits() } @@ -436,7 +436,7 @@ pub fn fields( enum_items.push(quote! { /// Value of the field as raw bits - #[inline] + #[inline(always)] pub fn #bits(&self) -> #fty { match *self { #(#arms),* @@ -469,7 +469,7 @@ pub fn fields( enum_items.push(quote! { #[allow(missing_docs)] #[doc(hidden)] - #[inline] + #[inline(always)] pub fn _from(value: #fty) -> #pc_r { match value { #(#arms),*, @@ -490,7 +490,7 @@ pub fn fields( let doc = format!("Checks if the value of the field is `{}`", pc); enum_items.push(quote! { #[doc = #doc] - #[inline] + #[inline(always)] pub fn #is_variant(&self) -> bool { *self == #pc_r::#pc } @@ -509,7 +509,7 @@ pub fn fields( let sc = &f.sc; r_impl_items.push(quote! { #[doc = #description] - #[inline] + #[inline(always)] pub fn #sc(&self) -> #pc_r { let bits = #value; #pc_r { bits } @@ -519,7 +519,7 @@ pub fn fields( let mut pc_r_impl_items = vec![ quote! { /// Value of the field as raw bits - #[inline] + #[inline(always)] pub fn #bits(&self) -> #fty { self.bits } @@ -529,13 +529,13 @@ pub fn fields( if f.width == 1 { pc_r_impl_items.push(quote! { /// Returns `true` if the bit is clear (0) - #[inline] + #[inline(always)] pub fn bit_is_clear(&self) -> bool { !self.#bits() } /// Returns `true` if the bit is set (1) - #[inline] + #[inline(always)] pub fn bit_is_set(&self) -> bool { self.#bits() } @@ -690,7 +690,7 @@ pub fn fields( impl #pc_w { #[allow(missing_docs)] #[doc(hidden)] - #[inline] + #[inline(always)] pub fn _bits(&self) -> #fty { match *self { #(#arms),* @@ -702,7 +702,7 @@ pub fn fields( proxy_items.push(quote! { /// Writes `variant` to the field - #[inline] + #[inline(always)] pub fn variant(self, variant: #pc_w) -> &'a mut W { #unsafety { self.#bits(variant._bits()) @@ -718,7 +718,7 @@ pub fn fields( if let Some(enum_) = base_pc_w.as_ref() { proxy_items.push(quote! { #[doc = #doc] - #[inline] + #[inline(always)] pub fn #sc(self) -> &'a mut W { self.variant(#enum_::#pc) } @@ -726,7 +726,7 @@ pub fn fields( } else { proxy_items.push(quote! { #[doc = #doc] - #[inline] + #[inline(always)] pub fn #sc(self) -> &'a mut W { self.variant(#pc_w::#pc) } @@ -751,7 +751,7 @@ pub fn fields( proxy_items.push(quote! { /// Writes raw bits to the field - #[inline] + #[inline(always)] pub #unsafety fn #bits(self, value: #fty) -> &'a mut W { self.w.bits &= !(#mask << #offset); self.w.bits |= ((value as #rty) & #mask) << #offset; @@ -775,7 +775,7 @@ pub fn fields( let sc = &f.sc; w_impl_items.push(quote! { #[doc = #description] - #[inline] + #[inline(always)] pub fn #sc(&mut self) -> #_pc_w { #_pc_w { w: self } }