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

Fieldset default value is always 0 #14

Closed
yodaldevoid opened this issue Nov 4, 2023 · 1 comment
Closed

Fieldset default value is always 0 #14

yodaldevoid opened this issue Nov 4, 2023 · 1 comment

Comments

@yodaldevoid
Copy link
Contributor

yodaldevoid commented Nov 4, 2023

I noticed after a long session of debugging that the default value of every fieldset is set to 0. My assumption and expectation was that a fieldset's default value would be the reset value defined in the SVD.

Was this a conscious decision or simply something not implemented? I wanted to check before putting in work to implement it.

@yodaldevoid yodaldevoid changed the title Register default value is always 0 Fieldset default value is always 0 Nov 4, 2023
@Dirbaio
Copy link
Member

Dirbaio commented Nov 20, 2023

This is intentional, reset values cause a variety of issues that were contrary to the goals of chiptool. For example, in STM32, different GPIO pins might have different reset values (for example the pins used for SWD). We want the pin registers to be an array, so HALs can index them instead of having to use macros to duplicate the code for each pin (causing unreadable code and slow compile times). However, the reset values of all the registers in an array must be the same. This means we're either forced to lie (have wrong reset values) or have ugly macros (not create the array), or simply not play the game at all (ignore reset values, default to 0). Chiptool chooses the latter.

My assumption and expectation was that a fieldset's default value would be the reset value defined in the SVD.

This is because you're used to svd2rust, I'll point out that this is not the case if you use e.g. C-style bit manipulation :)

@Dirbaio Dirbaio closed this as completed Nov 20, 2023
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

2 participants