You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
627: Rework: Enum typename considering name in enumeratedValues r=burrbull a=luojia65
~Marked as draft: this pull request depends on #626, and should be merged after that pull request is merged.~ Ready for review as #626 is merged.
This pull request is a rework to #612; commits in this pull request only considers enumeration name other than writer structure and reader structure. Names to those two proxy structures are yet to be discussed.
svd2rust has a good mechanism to parse enumeratedValues into Rust enums. However, current code would pick name of the first field the enum resides, and use pub type to re-export it into other names.
SVD files provide `name` field in enumeratedValues, this commit make use of them to name the Rust enums it generated. After this commit, more information of SVD file is considered in output pac crate. Users may also discover a significant drop in amount of types, which will speed up rustdoc generation and crate compilation.
After this pull request is merged, we can discuss on how the read proxy and write proxy should be named as is mentioned in [comment at #612](#612 (comment)).
Before this pull request:
<details>

</details>
After this pull request:
<details>

</details>
SVD file for this example:
<details>
```xml
<register>
<name>interrupt</name>
<description>Interrupt enables, states and masks</description>
<addressOffset>0x04</addressOffset>
<resetValue>0x3f003f00</resetValue>
<resetMask>0xffffffff</resetMask>
<fields>
<field>
<name>fifo_error_enable</name>
<description>Transmit or receive FIFO error interrupt enable</description>
<lsb>29</lsb>
<msb>29</msb>
<writeConstraint>
<useEnumeratedValues>true</useEnumeratedValues>
</writeConstraint>
<enumeratedValues>
<name>InterruptEnable</name>
<enumeratedValue>
<name>enable</name>
<description>Enable interrupt</description>
<value>1</value>
</enumeratedValue>
<enumeratedValue>
<name>disable</name>
<description>Disable interrupt</description>
<value>0</value>
</enumeratedValue>
</enumeratedValues>
</field>
<field>
<name>arbitrate_lost_enable</name>
<description>Arbitration lost interrupt enable</description>
<lsb>28</lsb>
<msb>28</msb>
<writeConstraint>
<useEnumeratedValues>true</useEnumeratedValues>
</writeConstraint>
<enumeratedValues derivedFrom="InterruptEnable" />
</field>
<!-- ...... -->
```
</details>
Co-authored-by: luojia65 <[email protected]>
0 commit comments