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

When isDefault is present in an enumeratedValue, map all non-specified reads to that variant #172

Closed
codyps opened this issue Jan 26, 2018 · 2 comments · Fixed by #767
Closed
Milestone

Comments

@codyps
Copy link

codyps commented Jan 26, 2018

isDefault is supposed to be an alternate to value within an enumeratedValue. Realistically, it's probably useful to allow both value and isDefault to be specified.

Current svd2rust appears to ignore it. It would likely be more correct to adjust the _from impls on the read proxies to translate all non-specified values into the enumeration marked with isDefault. Right now, it appears those will be mapped to a _Reserved enumeration.

@codyps
Copy link
Author

codyps commented Jan 26, 2018

While this would be useful, it's not quite clear to me what the best way to allow both preserving the exact value written to the register & not require that the user picks 1 of several bit patterns with identical meaning.

@Emilgardis Emilgardis added this to the cmsis-svd milestone Mar 2, 2018
@xd009642
Copy link

I've just ran against this myself and was expecting the generated code to either give me an enum field without a value or be something akin to:

pub enum FQC_A {
    Empty = 0,
    HasData(u8),
    Full = 16,
}

For context this is for a register describing the current capacity of a device FIFO which ranges from 0b00000->0b10000

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 a pull request may close this issue.

3 participants