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

Compile error from generated device module file #16

Open
demotomohiro opened this issue Sep 12, 2024 · 0 comments
Open

Compile error from generated device module file #16

demotomohiro opened this issue Sep 12, 2024 · 0 comments

Comments

@demotomohiro
Copy link

I tried svd2nim for SVD file for RP2040 in https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2040/hardware_regs/RP2040.svd
It generated RP2040.nim with following code:

type ROSC_CTRL_FREQ_RANGE* {.size: 4.} = enum
  LOW = 0xfa4,
  MEDIUM = 0xfa5,
  HIGH = 0xfa7,
  TOOHIGH = 0xfa6,

It causes compile error: Error: invalid order in enum 'TOOHIGH'.

It seems above code was generated from following code:

    <peripheral>
        <name>ROSC</name>
        <baseAddress>0x40060000</baseAddress>
        <addressBlock>
            <offset>0</offset>
            <size>36</size>
            <usage>registers</usage>
        </addressBlock>
        <registers>
            <register>
                <name>CTRL</name>
                <addressOffset>0x00000000</addressOffset>
                <description>Ring Oscillator control</description>
                <resetValue>0x00000aa0</resetValue>
                <fields>
                    <field>
                        <name>ENABLE</name>
                        <description>On power-up this field is initialised to ENABLE 
                            The system clock must be switched to another source before setting this field to DISABLE otherwise the chip will lock up 
                            The 12-bit code is intended to give some protection against accidental writes. An invalid setting will enable the oscillator.</description>
                        <bitRange>[23:12]</bitRange>
                        <access>read-write</access>
                        <enumeratedValues>
                            <enumeratedValue>
                                <name>DISABLE</name>
                                <value>3358</value>
                            </enumeratedValue>
                            <enumeratedValue>
                                <name>ENABLE</name>
                                <value>4011</value>
                            </enumeratedValue>
                        </enumeratedValues>
                    </field>
                    <field>
                        <name>FREQ_RANGE</name>
                        <description>Controls the number of delay stages in the ROSC ring 
                            LOW uses stages 0 to 7 
                            MEDIUM uses stages 2 to 7 
                            HIGH uses stages 4 to 7 
                            TOOHIGH uses stages 6 to 7 and should not be used because its frequency exceeds design specifications 
                            The clock output will not glitch when changing the range up one step at a time 
                            The clock output will glitch when changing the range down 
                            Note: the values here are gray coded which is why HIGH comes before TOOHIGH</description>
                        <bitRange>[11:0]</bitRange>
                        <access>read-write</access>
                        <enumeratedValues>
                            <enumeratedValue>
                                <name>LOW</name>
                                <value>4004</value>
                            </enumeratedValue>
                            <enumeratedValue>
                                <name>MEDIUM</name>
                                <value>4005</value>
                            </enumeratedValue>
                            <enumeratedValue>
                                <name>HIGH</name>
                                <value>4007</value>
                            </enumeratedValue>
                            <enumeratedValue>
                                <name>TOOHIGH</name>
                                <value>4006</value>
                            </enumeratedValue>
                        </enumeratedValues>
                    </field>
                </fields>
            </register>

TOOHIGH has value lower value than HIGH.
svd2nim need to sort enumerated Value when generating code.

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