@@ -2,12 +2,12 @@ use crate::svd::{array::names, Device, Peripheral};
2
2
use proc_macro2:: { Span , TokenStream } ;
3
3
use quote:: { quote, ToTokens } ;
4
4
5
- use log:: debug;
5
+ use log:: { debug, warn } ;
6
6
use std:: fs:: File ;
7
7
use std:: io:: Write ;
8
8
use std:: path:: Path ;
9
9
10
- use crate :: config:: { Config , Settings , Target } ;
10
+ use crate :: config:: { Config , Target } ;
11
11
use crate :: util:: { self , ident} ;
12
12
use anyhow:: { Context , Result } ;
13
13
@@ -31,9 +31,9 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
31
31
let settings = match config. settings . as_ref ( ) {
32
32
Some ( settings) => {
33
33
let file = std:: fs:: read_to_string ( settings) . context ( "could not read settings file" ) ?;
34
- serde_yaml:: from_str ( & file) . context ( "could not parse settings file" ) ?
34
+ Some ( serde_yaml:: from_str ( & file) . context ( "could not parse settings file" ) ?)
35
35
}
36
- None => Settings :: default ( ) ,
36
+ None => None ,
37
37
} ;
38
38
39
39
if config. target == Target :: Msp430 {
@@ -197,8 +197,23 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
197
197
198
198
match config. target {
199
199
Target :: RISCV => {
200
- debug ! ( "Rendering RISC-V specific code" ) ;
201
- out. extend ( riscv:: render ( & d. peripherals , device_x, & settings) ?) ;
200
+ if settings. is_none ( ) {
201
+ warn ! ( "No settings file provided for RISC-V target. Using legacy interrupts rendering" ) ;
202
+ warn ! ( "Please, consider migrating your PAC to riscv 0.12.0 or later" ) ;
203
+ out. extend ( interrupt:: render (
204
+ config. target ,
205
+ & d. peripherals ,
206
+ device_x,
207
+ config,
208
+ ) ?) ;
209
+ } else {
210
+ debug ! ( "Rendering RISC-V specific code" ) ;
211
+ out. extend ( riscv:: render (
212
+ & d. peripherals ,
213
+ device_x,
214
+ settings. as_ref ( ) . unwrap ( ) ,
215
+ ) ?) ;
216
+ }
202
217
}
203
218
_ => {
204
219
debug ! ( "Rendering interrupts" ) ;
@@ -219,7 +234,10 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
219
234
// Core peripherals are handled above
220
235
continue ;
221
236
}
222
- if config. target == Target :: RISCV && riscv:: is_riscv_peripheral ( p, & settings) {
237
+ if config. target == Target :: RISCV
238
+ && settings. is_some ( )
239
+ && riscv:: is_riscv_peripheral ( p, settings. as_ref ( ) . unwrap ( ) )
240
+ {
223
241
// RISC-V specific peripherals are handled above
224
242
continue ;
225
243
}
0 commit comments