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

Enums with isDefault not handled correctly #47

Open
armandas opened this issue Jan 6, 2025 · 0 comments
Open

Enums with isDefault not handled correctly #47

armandas opened this issue Jan 6, 2025 · 0 comments

Comments

@armandas
Copy link

armandas commented Jan 6, 2025

In the Renesas RA SVDs, there are some enums like the below, with isDefault and no value.

<field>
<name>MOSEL</name>
<description>Main Clock Oscillator Switching</description>
<lsb>6</lsb>
<msb>7</msb>
<access>read-write</access>
<enumeratedValues>
    <enumeratedValue>
        <name>01</name>
        <description>Resonator</description>
        <value>#01</value>
    </enumeratedValue>
    <enumeratedValue>
        <name>11</name>
        <description>External clock input mode</description>
        <value>#11</value>
    </enumeratedValue>
    <enumeratedValue>
        <name>Others</name>
        <description>Port mode</description>
        <isDefault>true</isDefault>
    </enumeratedValue>
</enumeratedValues>
</field>

This causes chiptool to crash at

value: v.value.unwrap() as _, // TODO what are variants without values used for??

while svd2rust generates the following enum:

#[doc = "Main Clock Oscillator Switching\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Mosel {
    #[doc = "1: Resonator"]
    _01 = 1,
    #[doc = "3: External clock input mode"]
    _11 = 3,
    #[doc = "0: Port mode"]
    Others = 0,
}

Related issues in svd2rust:

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

1 participant