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/).
14
14
- Add delay structure and methods using embedded-hal traits and ` mcycle ` register
15
15
- Add ` asm::delay() ` function for assembly-based busy-loops
16
16
- Add ` asm::nop() ` , a wrapper for implementing a ` nop ` instruction
17
+ - Add missing ` #[inline] ` attribute to register reads, type conversations and ` interrupt::free `
17
18
18
19
### Changed
19
20
Original file line number Diff line number Diff line change @@ -9,12 +9,14 @@ pub struct McycleDelay {
9
9
10
10
impl McycleDelay {
11
11
/// Constructs the delay provider
12
+ #[ inline( always) ]
12
13
pub fn new ( ticks_second : u32 ) -> Self {
13
14
Self { ticks_second }
14
15
}
15
16
}
16
17
17
18
impl DelayUs < u64 > for McycleDelay {
19
+ #[ inline]
18
20
fn delay_us ( & mut self , us : u64 ) {
19
21
let t0 = mcycle:: read64 ( ) ;
20
22
let clock = ( us * ( self . ticks_second as u64 ) ) / 1_000_000 ;
@@ -53,6 +55,7 @@ impl DelayUs<u8> for McycleDelay {
53
55
}
54
56
55
57
impl DelayMs < u32 > for McycleDelay {
58
+ #[ inline]
56
59
fn delay_ms ( & mut self , ms : u32 ) {
57
60
self . delay_us ( ( ms as u64 ) * 1000 )
58
61
}
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ pub unsafe fn enable() {
33
33
/// Execute closure `f` in an interrupt-free context.
34
34
///
35
35
/// This as also known as a "critical section".
36
+ #[ inline]
36
37
pub fn free < F , R > ( f : F ) -> R
37
38
where
38
39
F : FnOnce ( & CriticalSection ) -> R ,
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ pub enum RoundingMode {
76
76
77
77
impl FCSR {
78
78
/// Returns the contents of the register as raw bits
79
+ #[ inline]
79
80
pub fn bits ( & self ) -> u32 {
80
81
self . bits
81
82
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub struct Marchid {
10
10
11
11
impl Marchid {
12
12
/// Returns the contents of the register as raw bits
13
+ #[ inline]
13
14
pub fn bits ( & self ) -> usize {
14
15
self . bits . get ( )
15
16
}
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ pub enum Exception {
49
49
}
50
50
51
51
impl Interrupt {
52
+ #[ inline]
52
53
pub fn from ( nr : usize ) -> Self {
53
54
match nr {
54
55
0 => Interrupt :: UserSoft ,
@@ -66,6 +67,7 @@ impl Interrupt {
66
67
}
67
68
68
69
impl Exception {
70
+ #[ inline]
69
71
pub fn from ( nr : usize ) -> Self {
70
72
match nr {
71
73
0 => Exception :: InstructionMisaligned ,
@@ -94,6 +96,7 @@ impl Mcause {
94
96
}
95
97
96
98
/// Returns the code field
99
+ #[ inline]
97
100
pub fn code ( & self ) -> usize {
98
101
match ( ) {
99
102
#[ cfg( target_pointer_width = "32" ) ]
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub struct Mimpid {
10
10
11
11
impl Mimpid {
12
12
/// Returns the contents of the register as raw bits
13
+ #[ inline]
13
14
pub fn bits ( & self ) -> usize {
14
15
self . bits . get ( )
15
16
}
Original file line number Diff line number Diff line change @@ -18,11 +18,13 @@ pub enum MXL {
18
18
19
19
impl Misa {
20
20
/// Returns the contents of the register as raw bits
21
+ #[ inline]
21
22
pub fn bits ( & self ) -> usize {
22
23
self . bits . get ( )
23
24
}
24
25
25
26
/// Returns the machine xlen.
27
+ #[ inline]
26
28
pub fn mxl ( & self ) -> MXL {
27
29
let value = match ( ) {
28
30
#[ cfg( target_pointer_width = "32" ) ]
@@ -39,6 +41,7 @@ impl Misa {
39
41
}
40
42
41
43
/// Returns true when the atomic extension is implemented.
44
+ #[ inline]
42
45
pub fn has_extension ( & self , extension : char ) -> bool {
43
46
let bit = extension as u8 - 65 ;
44
47
if bit > 25 {
Original file line number Diff line number Diff line change @@ -15,16 +15,19 @@ pub enum TrapMode {
15
15
16
16
impl Mtvec {
17
17
/// Returns the contents of the register as raw bits
18
+ #[ inline]
18
19
pub fn bits ( & self ) -> usize {
19
20
self . bits
20
21
}
21
22
22
23
/// Returns the trap-vector base-address
24
+ #[ inline]
23
25
pub fn address ( & self ) -> usize {
24
26
self . bits - ( self . bits & 0b11 )
25
27
}
26
28
27
29
/// Returns the trap-vector mode
30
+ #[ inline]
28
31
pub fn trap_mode ( & self ) -> Option < TrapMode > {
29
32
let mode = self . bits & 0b11 ;
30
33
match mode {
Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ pub struct Mvendorid {
10
10
11
11
impl Mvendorid {
12
12
/// Returns the contents of the register as raw bits
13
+ #[ inline]
13
14
pub fn bits ( & self ) -> usize {
14
15
self . bits . get ( )
15
16
}
16
17
17
18
/// Returns the JEDEC manufacturer ID
19
+ #[ inline]
18
20
pub fn jedec_manufacturer ( & self ) -> usize {
19
21
self . bits ( ) >> 7
20
22
}
You can’t perform that action at this time.
0 commit comments