Skip to content

Commit 1b7eea6

Browse files
committed
Add base-address-shift configuration flag
1 parent fece2ff commit 1b7eea6

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
- Add `base-address-shift` config flag
11+
1012
## [v0.31.3] - 2023-12-25
1113

1214
- Add `svd::Device` validation after parsing by `serde`

src/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct Config {
2828
pub interrupt_link_section: Option<String>,
2929
pub reexport_core_peripherals: bool,
3030
pub reexport_interrupt: bool,
31+
pub base_address_shift: u64,
3132
}
3233

3334
#[allow(clippy::upper_case_acronyms)]

src/generate/peripheral.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
4040
let span = Span::call_site();
4141
let name_str = name.to_sanitized_constant_case();
4242
let name_constant_case = Ident::new(&name_str, span);
43-
let address = util::hex(p.base_address);
43+
let address = util::hex(p.base_address + config.base_address_shift);
4444
let description = util::respace(p.description.as_ref().unwrap_or(&p.name));
4545

4646
let name_snake_case = name.to_snake_case_ident(span);
@@ -83,7 +83,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
8383
let description = pi.description.as_deref().unwrap_or(&p.name);
8484
let name_str = name.to_sanitized_constant_case();
8585
let name_constant_case = Ident::new(name, span);
86-
let address = util::hex(pi.base_address);
86+
let address = util::hex(pi.base_address + config.base_address_shift);
8787
let p_snake = name.to_sanitized_snake_case();
8888
snake_names.push(p_snake.to_string());
8989
let mut feature_attribute_n = feature_attribute.clone();

src/main.rs

+8
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ fn run() -> Result<()> {
198198
.action(ArgAction::SetTrue)
199199
.help("Reexport interrupt macro from cortex-m-rt like crates"),
200200
)
201+
.arg(
202+
Arg::new("base_address_shift")
203+
.short('b')
204+
.long("base-address-shift")
205+
.alias("base_address_shift")
206+
.action(ArgAction::Set)
207+
.help("Shift base address for all peripherals"),
208+
)
201209
.arg(
202210
Arg::new("log_level")
203211
.long("log")

0 commit comments

Comments
 (0)