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

Add patch to remove prefixes from register names #33

Merged
merged 1 commit into from
Oct 12, 2022

Conversation

jeandudey
Copy link
Contributor

This is just a proof of concept, remove prefixes from register names on each peripheral.

For example on ADC when there is a list of registers named ADC_<name> it will remove the ADC_ part leaving <name>.

I've thought of using the peripheral name as a guess but on the ATDF file I'm converting the FLEXCOM peripherals have registers named FLEX_<> so it wasn't possible, so I opted to find the longest matching common prefix on the registers name that ended with an underscore.

This could be under a command line flag if it causes problems on other ATDF files, for example it can also mistakenly remove prefixes that should probably not be removed (e.g.: a set of registers that are CH_CR, CH_SR, etc.), haven't found something like that though.

@Rahix
Copy link
Owner

Rahix commented Sep 28, 2022

In general, I personally think it is best to keep the original names as much as possible so they can be easily referenced in the datasheet. But I don't know what MCUs you're dealing with so the situation might be different for you.

This could be under a command line flag

I think this is the best approach. This way I can keep it disabled for our builds but people like you can opt-in to this behavior where needed.

@jeandudey
Copy link
Contributor Author

See 17cf656. Added a --patch <patch-name> command line flag, by default the existing patches are used if none specified, otherwise only the specified will be used, --patch can be specified multiple times.

src/main.rs Outdated Show resolved Hide resolved
@jeandudey jeandudey force-pushed the 2022_09_28-patch branch 2 times, most recently from 8f4b281 to 7155ea7 Compare October 11, 2022 11:42
Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

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

Thanks! Now I got around to looking at the actual patch implementation in more detail as well. I have two more comments but overall I am fine with the change.

One more thing: What ATDF files are you testing against? If I can download them as well, I can incorporate them into my own testing in the future. This will help to make sure your files also don't get regressed by other changes.

It would be especially interesting when (if) I get around to adding a proper regression test-suite here...

src/atdf/patch.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
@jeandudey
Copy link
Contributor Author

What ATDF files are you testing against? If I can download them as well,

SAMA5D2's ATDF files:

* Adds a --auto-patches command line flag
Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

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

Thanks!

@Rahix Rahix changed the title Remove prefixes from register names Add patch to remove prefixes from register names Oct 12, 2022
@Rahix Rahix merged commit 31d85ce into Rahix:main Oct 12, 2022
@jeandudey jeandudey deleted the 2022_09_28-patch branch October 13, 2022 11:28
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