Skip to content

Commit 935512c

Browse files
committed
Correction: EEPROM size is in bytes
1 parent 0ed9111 commit 935512c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn gpio_version_to_feature(version: &str) -> Result<String, String> {
3232
}
3333
}
3434

35-
/// Get the EEPROM size (in KiB) feature for a certain size.
35+
/// Get the EEPROM size feature for a certain size.
3636
fn eeprom_size_to_feature(size: u32) -> String {
3737
format!("eeprom-{}", size)
3838
}
@@ -102,7 +102,7 @@ fn main() -> Result<(), String> {
102102

103103
// EEPROM size map
104104
//
105-
// The keys of this map are EEPROM sizes in KiB, the values are Vecs of MCU ref names.
105+
// The keys of this map are EEPROM sizes, the values are Vecs of MCU ref names.
106106
let mut mcu_eeprom_size_map: HashMap<u32, Vec<String>> = HashMap::new();
107107

108108
// Iterate through subfamilies, then through MCUs. Fill the maps above with
@@ -127,7 +127,7 @@ fn main() -> Result<(), String> {
127127
}
128128

129129
// Fill EEPROM size map
130-
if let Some(size) = mcu_dat.get_eeprom_size_kib() {
130+
if let Some(size) = mcu_dat.get_eeprom_size() {
131131
mcu_eeprom_size_map
132132
.entry(size)
133133
.or_insert(vec![])
@@ -200,7 +200,7 @@ fn generate_features(
200200
// EEPROM sizes
201201
let mut eeprom_sizes = mcu_eeprom_size_map.keys().collect::<Vec<_>>();
202202
eeprom_sizes.sort();
203-
println!("# Features based on EEPROM size (in KiB)");
203+
println!("# Features based on EEPROM size (in bytes)");
204204
for size in eeprom_sizes {
205205
println!("{} = []", eeprom_size_to_feature(*size));
206206
}
@@ -247,7 +247,7 @@ fn generate_features(
247247
dependencies.push(gpio_version_feature.clone());
248248

249249
// EEPROM size
250-
if let Some(size) = mcu_map.get(mcu).unwrap().get_eeprom_size_kib() {
250+
if let Some(size) = mcu_map.get(mcu).unwrap().get_eeprom_size() {
251251
dependencies.push(eeprom_size_to_feature(size));
252252
}
253253

@@ -301,10 +301,10 @@ fn generate_pin_mappings(
301301

302302
/// Generate code containing the EEPROM size.
303303
fn generate_eeprom_sizes(mcu_eeprom_size_map: &HashMap<u32, Vec<String>>) -> Result<(), String> {
304-
println!("// EEPROM sizes in KiB, generated with cube-parse");
304+
println!("// EEPROM sizes in bytes, generated with cube-parse");
305305
for size in mcu_eeprom_size_map.keys() {
306306
println!("#[cfg({})]", eeprom_size_to_feature(*size));
307-
println!("const EEPROM_SIZE_KIB: u32 = {};", size);
307+
println!("const EEPROM_SIZE_BYTES: u32 = {};", size);
308308
}
309309
Ok(())
310310
}

src/mcu.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct Mcu {
1010
#[serde(rename = "IP", default)]
1111
ip: Vec<IP>,
1212
#[serde(rename = "E2prom")]
13-
eeprom_size_kib: String,
13+
eeprom_size_bytes: String,
1414
}
1515

1616
impl Mcu {
@@ -22,9 +22,9 @@ impl Mcu {
2222
self.ip.iter().find(|v| v.name == name)
2323
}
2424

25-
/// Return the EEPROM size in KiB
26-
pub fn get_eeprom_size_kib(&self) -> Option<u32> {
27-
self.eeprom_size_kib.parse().ok()
25+
/// Return the EEPROM size in bytes
26+
pub fn get_eeprom_size(&self) -> Option<u32> {
27+
self.eeprom_size_bytes.parse().ok()
2828
}
2929
}
3030

0 commit comments

Comments
 (0)