@@ -9,7 +9,12 @@ use crate::Target;
9
9
use crate :: generate:: { interrupt, peripheral} ;
10
10
11
11
/// Whole device generation
12
- pub fn render ( d : & Device , target : & Target , nightly : bool , device_x : & mut String ) -> Result < Vec < Tokens > > {
12
+ pub fn render (
13
+ d : & Device ,
14
+ target : Target ,
15
+ nightly : bool ,
16
+ device_x : & mut String ,
17
+ ) -> Result < Vec < Tokens > > {
13
18
let mut out = vec ! [ ] ;
14
19
15
20
let doc = format ! (
@@ -21,13 +26,13 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
21
26
env!( "CARGO_PKG_VERSION" )
22
27
) ;
23
28
24
- if * target == Target :: Msp430 {
29
+ if target == Target :: Msp430 {
25
30
out. push ( quote ! {
26
31
#![ feature( abi_msp430_interrupt) ]
27
32
} ) ;
28
33
}
29
34
30
- if * target != Target :: None && * target != Target :: CortexM && * target != Target :: RISCV {
35
+ if target != Target :: None && target != Target :: CortexM && target != Target :: RISCV {
31
36
out. push ( quote ! {
32
37
#![ cfg_attr( feature = "rt" , feature( global_asm) ) ]
33
38
#![ cfg_attr( feature = "rt" , feature( use_extern_macros) ) ]
@@ -49,7 +54,7 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
49
54
} ) ;
50
55
}
51
56
52
- match * target {
57
+ match target {
53
58
Target :: CortexM => {
54
59
out. push ( quote ! {
55
60
extern crate cortex_m;
@@ -88,7 +93,7 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
88
93
let mut fpu_present = true ;
89
94
90
95
if let Some ( cpu) = d. cpu . as_ref ( ) {
91
- let bits = util:: unsuffixed ( cpu. nvic_priority_bits as u64 ) ;
96
+ let bits = util:: unsuffixed ( u64 :: from ( cpu. nvic_priority_bits ) ) ;
92
97
93
98
out. push ( quote ! {
94
99
/// Number available in the NVIC for configuring priority
@@ -100,21 +105,20 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
100
105
101
106
out. extend ( interrupt:: render ( target, & d. peripherals , device_x) ?) ;
102
107
103
- let core_peripherals: & [ & str ] ;
104
-
105
- if fpu_present {
106
- core_peripherals = & [
107
- "CBP" , "CPUID" , "DCB" , "DWT" , "FPB" , "FPU" , "ITM" , "MPU" , "NVIC" , "SCB" , "SYST" , "TPIU"
108
- ] ;
108
+ let core_peripherals: & [ _ ] = if fpu_present {
109
+ & [
110
+ "CBP" , "CPUID" , "DCB" , "DWT" , "FPB" , "FPU" , "ITM" , "MPU" , "NVIC" , "SCB" , "SYST" ,
111
+ "TPIU" ,
112
+ ]
109
113
} else {
110
- core_peripherals = & [
111
- "CBP" , "CPUID" , "DCB" , "DWT" , "FPB" , "ITM" , "MPU" , "NVIC" , "SCB" , "SYST" , "TPIU"
112
- ] ;
113
- }
114
+ & [
115
+ "CBP" , "CPUID" , "DCB" , "DWT" , "FPB" , "ITM" , "MPU" , "NVIC" , "SCB" , "SYST" , "TPIU" ,
116
+ ]
117
+ } ;
114
118
115
119
let mut fields = vec ! [ ] ;
116
120
let mut exprs = vec ! [ ] ;
117
- if * target == Target :: CortexM {
121
+ if target == Target :: CortexM {
118
122
out. push ( quote ! {
119
123
pub use cortex_m:: peripheral:: Peripherals as CorePeripherals ;
120
124
#[ cfg( feature = "rt" ) ]
@@ -139,7 +143,7 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
139
143
}
140
144
141
145
for p in & d. peripherals {
142
- if * target == Target :: CortexM && core_peripherals. contains ( & & * p. name . to_uppercase ( ) ) {
146
+ if target == Target :: CortexM && core_peripherals. contains ( & & * p. name . to_uppercase ( ) ) {
143
147
// Core peripherals are handled above
144
148
continue ;
145
149
}
@@ -150,7 +154,8 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
150
154
. as_ref ( )
151
155
. map ( |v| & v[ ..] )
152
156
. unwrap_or ( & [ ] )
153
- . is_empty ( ) && p. derived_from . is_none ( )
157
+ . is_empty ( )
158
+ && p. derived_from . is_none ( )
154
159
{
155
160
// No register block will be generated so don't put this peripheral
156
161
// in the `Peripherals` struct
@@ -166,12 +171,13 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
166
171
exprs. push ( quote ! ( #id: #id { _marker: PhantomData } ) ) ;
167
172
}
168
173
169
- let take = match * target {
174
+ let take = match target {
170
175
Target :: CortexM => Some ( Ident :: new ( "cortex_m" ) ) ,
171
176
Target :: Msp430 => Some ( Ident :: new ( "msp430" ) ) ,
172
177
Target :: RISCV => Some ( Ident :: new ( "riscv" ) ) ,
173
178
Target :: None => None ,
174
- } . map ( |krate| {
179
+ }
180
+ . map ( |krate| {
175
181
quote ! {
176
182
/// Returns all the peripherals *once*
177
183
#[ inline]
0 commit comments