svd2rust
svd2rust copied to clipboard
When `isDefault` is present in an `enumeratedValue`, map all non-specified reads to that variant
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.
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.
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