Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interrupts #2

Closed
Rahix opened this issue May 12, 2019 · 1 comment
Closed

Interrupts #2

Rahix opened this issue May 12, 2019 · 1 comment

Comments

@Rahix
Copy link
Owner

Rahix commented May 12, 2019

Right now, the interrupt list specified in the atdf file is completely ignored. atdf2svd definitely needs a way to add them to the svd file, but unfortunately, this is not quite trivial: The atdf does not associate interrupts with peripherals like svd does ... I am currently in favor of just adding all interrupts to the CPU peripheral unconditionally, as svd2rust does not care about this association anyway ...

@Rahix
Copy link
Owner Author

Rahix commented May 24, 2019

Implementation

Data-Structure Changes

Add a new list of interrupts to the Chip struct. Probably similar to

pub struct Chip {
    pub name: String,
    // ...
    pub peripherals: HashMap<String, Peripheral>,
    pub interrupts: HashMap<String, Interrupt>,
}

This interrupt type also needs to be defined:

pub struct Interrupt {
    pub name: String,
    pub description: Option<String>,
    pub index: usize,
}

Parsing

The interrupt list should be filled with the interrupts from the <interrupts> element. Probably in atdf/chip.rs. Look at the other parsers and try to mimic what they do to get this working.

svd-Generation

The idea is to add all interrupts to the CPU peripheral in the svd file. To do so, after generating all peripherals, attach a new child-tree to the CPU peripheral. This should happen in svd/chip.rs(Line 28+). Reference the svd documentation for details about that.

Unfortunately, there is no easy way to access the CPU peripheral, so what you'll probably end up with is looping over all peripherals until you find it:

for peripheral in peripherals.children.iter_mut() {
    if let Some("CPU") = peripheral.get_child("name") {
        // Add interrupts
        peripheral.children.push(...);
        break;
    }
}

offdroid added a commit to offdroid/atdf2svd that referenced this issue May 25, 2019
Signed-off-by: offdroid <filip.skubacz.public@gmail.com>
offdroid added a commit to offdroid/atdf2svd that referenced this issue May 25, 2019
Implement interrupts as specified in Rahix#2.
offdroid added a commit to offdroid/atdf2svd that referenced this issue May 26, 2019
This commit makes atdf2svd parse the interrupt list
from the source file and adds all interrupts to the CPU
peripheral in the generated svd.

Fixes Rahix#2

Signed-off-by: offdroid <filip.skubacz.public@gmail.com>
@Rahix Rahix closed this as completed in fbf069b May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant