File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -104,27 +104,29 @@ fn main() -> Result<(), String> {
104
104
_ => unreachable ! ( ) ,
105
105
} ;
106
106
107
+ // Load families
107
108
let families = family:: Families :: load ( & db_dir)
108
109
. map_err ( |e| format ! ( "Could not load families XML: {}" , e) ) ?;
109
110
111
+ // Find target family
110
112
let family = ( & families)
111
113
. into_iter ( )
112
114
. find ( |v| v. name == mcu_family)
113
115
. ok_or_else ( || format ! ( "Could not find family {}" , mcu_family) ) ?;
114
116
115
- let mut mcu_gpio_map = HashMap :: new ( ) ;
116
-
117
+ // Build MCU map
118
+ //
119
+ // The keys of this map are GPIO peripheral version strings (e.g.
120
+ // "STM32L051_gpio_v1_0"), while the value is a Vec of MCU ref names.
121
+ let mut mcu_gpio_map: HashMap < String , Vec < String > > = HashMap :: new ( ) ;
117
122
for sf in family {
118
123
for mcu in sf {
119
124
let mcu_dat = mcu:: Mcu :: load ( & db_dir, & mcu. name )
120
125
. map_err ( |e| format ! ( "Could not load MCU data: {}" , e) ) ?;
121
126
let gpio_version = mcu_dat. get_ip ( "GPIO" ) . unwrap ( ) . get_version ( ) . to_string ( ) ;
122
- if !mcu_gpio_map. contains_key ( & gpio_version) {
123
- mcu_gpio_map. insert ( gpio_version. clone ( ) , Vec :: new ( ) ) ;
124
- }
125
127
mcu_gpio_map
126
- . get_mut ( & gpio_version)
127
- . unwrap ( )
128
+ . entry ( gpio_version)
129
+ . or_insert ( vec ! [ ] )
128
130
. push ( mcu. name . clone ( ) ) ;
129
131
}
130
132
}
You can’t perform that action at this time.
0 commit comments