embassy-rs / embassy-rs/chiptool

Enums with `isDefault` not handled correctly

Open
#47 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
65
Forks
54
PR merge metrics
No merged PRs in 30d

Description

In the Renesas RA SVDs, there are some [enums](https://arm-software.github.io/CMSIS_5/SVD/html/elem_registers.html#elem_enumeratedValues) like the below, with `isDefault` and no `value`.

```xml

MOSEL
Main Clock Oscillator Switching
6
7
read-write


01
Resonator
#01


11
External clock input mode
#11


Others
Port mode
true

```

This causes `chiptool` to crash at https://github.com/embassy-rs/chiptool/blob/26983da961307008dee1ef6b85c93a9489c8ae94/src/svd2ir.rs#L308

while `svd2rust` generates the following enum:

```rust
#[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`:

- https://github.com/rust-embedded/svd2rust/issues/172
- https://github.com/rust-embedded/svd2rust/issues/852

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.