File tree Expand file tree Collapse file tree 13 files changed +28
-0
lines changed Expand file tree Collapse file tree 13 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414- Add delay structure and methods using embedded-hal traits and ` mcycle ` register
1515- Add ` asm::delay() ` function for assembly-based busy-loops
1616- Add ` asm::nop() ` , a wrapper for implementing a ` nop ` instruction
17+ - Add missing ` #[inline] ` attribute to register reads, type conversations and ` interrupt::free `
1718
1819### Changed
1920
Original file line number Diff line number Diff line change @@ -9,12 +9,14 @@ pub struct McycleDelay {
99
1010impl McycleDelay {
1111 /// Constructs the delay provider
12+ #[ inline( always) ]
1213 pub fn new ( ticks_second : u32 ) -> Self {
1314 Self { ticks_second }
1415 }
1516}
1617
1718impl DelayUs < u64 > for McycleDelay {
19+ #[ inline( always) ]
1820 fn delay_us ( & mut self , us : u64 ) {
1921 let t0 = mcycle:: read64 ( ) ;
2022 let clock = ( us * ( self . ticks_second as u64 ) ) / 1_000_000 ;
@@ -53,6 +55,7 @@ impl DelayUs<u8> for McycleDelay {
5355}
5456
5557impl DelayMs < u32 > for McycleDelay {
58+ #[ inline( always) ]
5659 fn delay_ms ( & mut self , ms : u32 ) {
5760 self . delay_us ( ( ms as u64 ) * 1000 )
5861 }
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ pub unsafe fn enable() {
3333/// Execute closure `f` in an interrupt-free context.
3434///
3535/// This as also known as a "critical section".
36+ #[ inline]
3637pub fn free < F , R > ( f : F ) -> R
3738where
3839 F : FnOnce ( & CriticalSection ) -> R ,
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ pub enum RoundingMode {
7676
7777impl FCSR {
7878 /// Returns the contents of the register as raw bits
79+ #[ inline]
7980 pub fn bits ( & self ) -> u32 {
8081 self . bits
8182 }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub struct Marchid {
1010
1111impl Marchid {
1212 /// Returns the contents of the register as raw bits
13+ #[ inline]
1314 pub fn bits ( & self ) -> usize {
1415 self . bits . get ( )
1516 }
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ pub enum Exception {
4949}
5050
5151impl Interrupt {
52+ #[ inline]
5253 pub fn from ( nr : usize ) -> Self {
5354 match nr {
5455 0 => Interrupt :: UserSoft ,
@@ -66,6 +67,7 @@ impl Interrupt {
6667}
6768
6869impl Exception {
70+ #[ inline]
6971 pub fn from ( nr : usize ) -> Self {
7072 match nr {
7173 0 => Exception :: InstructionMisaligned ,
@@ -94,6 +96,7 @@ impl Mcause {
9496 }
9597
9698 /// Returns the code field
99+ #[ inline]
97100 pub fn code ( & self ) -> usize {
98101 match ( ) {
99102 #[ cfg( target_pointer_width = "32" ) ]
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub struct Mimpid {
1010
1111impl Mimpid {
1212 /// Returns the contents of the register as raw bits
13+ #[ inline]
1314 pub fn bits ( & self ) -> usize {
1415 self . bits . get ( )
1516 }
Original file line number Diff line number Diff line change @@ -18,11 +18,13 @@ pub enum MXL {
1818
1919impl Misa {
2020 /// Returns the contents of the register as raw bits
21+ #[ inline]
2122 pub fn bits ( & self ) -> usize {
2223 self . bits . get ( )
2324 }
2425
2526 /// Returns the machine xlen.
27+ #[ inline]
2628 pub fn mxl ( & self ) -> MXL {
2729 let value = match ( ) {
2830 #[ cfg( target_pointer_width = "32" ) ]
@@ -39,6 +41,7 @@ impl Misa {
3941 }
4042
4143 /// Returns true when the atomic extension is implemented.
44+ #[ inline]
4245 pub fn has_extension ( & self , extension : char ) -> bool {
4346 let bit = extension as u8 - 65 ;
4447 if bit > 25 {
Original file line number Diff line number Diff line change @@ -15,16 +15,19 @@ pub enum TrapMode {
1515
1616impl Mtvec {
1717 /// Returns the contents of the register as raw bits
18+ #[ inline]
1819 pub fn bits ( & self ) -> usize {
1920 self . bits
2021 }
2122
2223 /// Returns the trap-vector base-address
24+ #[ inline]
2325 pub fn address ( & self ) -> usize {
2426 self . bits - ( self . bits & 0b11 )
2527 }
2628
2729 /// Returns the trap-vector mode
30+ #[ inline]
2831 pub fn trap_mode ( & self ) -> Option < TrapMode > {
2932 let mode = self . bits & 0b11 ;
3033 match mode {
Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ pub struct Mvendorid {
1010
1111impl Mvendorid {
1212 /// Returns the contents of the register as raw bits
13+ #[ inline]
1314 pub fn bits ( & self ) -> usize {
1415 self . bits . get ( )
1516 }
1617
1718 /// Returns the JEDEC manufacturer ID
19+ #[ inline]
1820 pub fn jedec_manufacturer ( & self ) -> usize {
1921 self . bits ( ) >> 7
2022 }
You can’t perform that action at this time.
0 commit comments