Skip to content

Commit

Permalink
Add base-address-shift configuration flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gephaistos committed Dec 25, 2023
1 parent fece2ff commit 1b7eea6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Add `base-address-shift` config flag

## [v0.31.3] - 2023-12-25

- Add `svd::Device` validation after parsing by `serde`
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct Config {
pub interrupt_link_section: Option<String>,
pub reexport_core_peripherals: bool,
pub reexport_interrupt: bool,
pub base_address_shift: u64,
}

#[allow(clippy::upper_case_acronyms)]
Expand Down
4 changes: 2 additions & 2 deletions src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let span = Span::call_site();
let name_str = name.to_sanitized_constant_case();
let name_constant_case = Ident::new(&name_str, span);
let address = util::hex(p.base_address);
let address = util::hex(p.base_address + config.base_address_shift);
let description = util::respace(p.description.as_ref().unwrap_or(&p.name));

let name_snake_case = name.to_snake_case_ident(span);
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let description = pi.description.as_deref().unwrap_or(&p.name);
let name_str = name.to_sanitized_constant_case();
let name_constant_case = Ident::new(name, span);
let address = util::hex(pi.base_address);
let address = util::hex(pi.base_address + config.base_address_shift);
let p_snake = name.to_sanitized_snake_case();
snake_names.push(p_snake.to_string());
let mut feature_attribute_n = feature_attribute.clone();
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ fn run() -> Result<()> {
.action(ArgAction::SetTrue)
.help("Reexport interrupt macro from cortex-m-rt like crates"),
)
.arg(
Arg::new("base_address_shift")
.short('b')
.long("base-address-shift")
.alias("base_address_shift")
.action(ArgAction::Set)
.help("Shift base address for all peripherals"),
)
.arg(
Arg::new("log_level")
.long("log")
Expand Down

0 comments on commit 1b7eea6

Please sign in to comment.