@@ -91,20 +91,33 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
91
91
use core:: marker:: PhantomData ;
92
92
} ) ;
93
93
94
+ // Retaining the previous assumption
95
+ let mut fpu_present = true ;
96
+
94
97
if let Some ( cpu) = d. cpu . as_ref ( ) {
95
98
let bits = util:: unsuffixed ( cpu. nvic_priority_bits as u64 ) ;
96
99
97
100
out. push ( quote ! {
98
101
/// Number available in the NVIC for configuring priority
99
102
pub const NVIC_PRIO_BITS : u8 = #bits;
100
103
} ) ;
104
+
105
+ fpu_present = cpu. fpu_present ;
101
106
}
102
107
103
108
out. extend ( interrupt:: render ( target, & d. peripherals , device_x) ?) ;
104
109
105
- const CORE_PERIPHERALS : & [ & str ] = & [
106
- "CBP" , "CPUID" , "DCB" , "DWT" , "FPB" , "FPU" , "ITM" , "MPU" , "NVIC" , "SCB" , "SYST" , "TPIU"
107
- ] ;
110
+ let core_peripherals: & [ & str ] ;
111
+
112
+ if fpu_present {
113
+ core_peripherals = & [
114
+ "CBP" , "CPUID" , "DCB" , "DWT" , "FPB" , "FPU" , "ITM" , "MPU" , "NVIC" , "SCB" , "SYST" , "TPIU"
115
+ ] ;
116
+ } else {
117
+ core_peripherals = & [
118
+ "CBP" , "CPUID" , "DCB" , "DWT" , "FPB" , "ITM" , "MPU" , "NVIC" , "SCB" , "SYST" , "TPIU"
119
+ ] ;
120
+ }
108
121
109
122
let mut fields = vec ! [ ] ;
110
123
let mut exprs = vec ! [ ] ;
@@ -113,15 +126,23 @@ pub fn render(d: &Device, target: &Target, nightly: bool, device_x: &mut String)
113
126
pub use cortex_m:: peripheral:: Peripherals as CorePeripherals ;
114
127
} ) ;
115
128
116
- out. push ( quote ! {
117
- pub use cortex_m:: peripheral:: {
118
- CBP , CPUID , DCB , DWT , FPB , FPU , ITM , MPU , NVIC , SCB , SYST , TPIU ,
119
- } ;
120
- } ) ;
129
+ if fpu_present {
130
+ out. push ( quote ! {
131
+ pub use cortex_m:: peripheral:: {
132
+ CBP , CPUID , DCB , DWT , FPB , FPU , ITM , MPU , NVIC , SCB , SYST , TPIU ,
133
+ } ;
134
+ } ) ;
135
+ } else {
136
+ out. push ( quote ! {
137
+ pub use cortex_m:: peripheral:: {
138
+ CBP , CPUID , DCB , DWT , FPB , ITM , MPU , NVIC , SCB , SYST , TPIU ,
139
+ } ;
140
+ } ) ;
141
+ }
121
142
}
122
143
123
144
for p in & d. peripherals {
124
- if * target == Target :: CortexM && CORE_PERIPHERALS . contains ( & & * p. name . to_uppercase ( ) ) {
145
+ if * target == Target :: CortexM && core_peripherals . contains ( & & * p. name . to_uppercase ( ) ) {
125
146
// Core peripherals are handled above
126
147
continue ;
127
148
}
0 commit comments