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

Handling of multiple declaration/meanings of the same interrupt vector #20

Merged
merged 1 commit into from
Nov 25, 2020
Merged

Handling of multiple declaration/meanings of the same interrupt vector #20

merged 1 commit into from
Nov 25, 2020

Conversation

trembel
Copy link
Contributor

@trembel trembel commented Nov 25, 2020

This solves #17.
Interrupts of the newer AVR MCUs having multiple name, e.g. the TCA interrupts of the attiny412:

        ...
        <interrupt index="8" module-instance="TCA0" name="LUNF"/>
        <interrupt index="8" module-instance="TCA0" name="OVF"/>
        <interrupt index="9" module-instance="TCA0" name="HUNF"/>
        <interrupt index="10" module-instance="TCA0" name="CMP0"/>
        <interrupt index="10" module-instance="TCA0" name="LCMP0"/>
        ...

will be stored as TCA0_LUNF_OVF, respectively TCA0_CMP0_LCMP0.

Signed-off-by: trembel <silvano.cortesi@hotmail.com>
@trembel trembel marked this pull request as ready for review November 25, 2020 10:45
Comment on lines +43 to +48
if let Some(split_idx) = int.name.find('_') {
existing_int.name.push_str(int.name.split_at(split_idx).1);
} else {
existing_int.name.push('_');
existing_int.name.push_str(&int.name);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say that I am a big fan of this ad-hoc string manipulation because it's very fragile ... But I cannot think of a different solution that does not require bigger changes, so I guess it is fine. We won't see this 'duplicate interrupt' situation too often anyway, I hope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for me. The other option would have been adding a "module-instance" field to the interrupt struct, but than serialization would not work (or needs to exclude the module-instance). This would give a much simpler string manipulation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw now that you do the serialization manually, so actually then an additional field in the interrupt struct would not change anything?

Then we could add a field module-instance as Option<std::string::String>, and in chip.rs we could append name with module-instance if it exists, and append also the other module-instance in case of duplicate index number.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change would then combine #19 with #20.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it like it is for now and only fix it if it breaks for someone ;) No point wasting too much effort on this rare issue ...

@Rahix Rahix merged commit 243ac64 into Rahix:master Nov 25, 2020
@Rahix
Copy link
Owner

Rahix commented Nov 25, 2020

Thanks a lot!

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

Successfully merging this pull request may close these issues.

2 participants