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

Field writer has no impl when enumeratedValue is derived across peripherals #705

Closed
kaizensparc opened this issue Jan 6, 2023 · 4 comments · Fixed by #731
Closed

Field writer has no impl when enumeratedValue is derived across peripherals #705

kaizensparc opened this issue Jan 6, 2023 · 4 comments · Fixed by #731
Labels

Comments

@kaizensparc
Copy link

Hello,
I'm currently implementing a PAC/HAL for the GD32E103 device and set the SVD to derive TIMER*.CTL0.CEN registers to TIMER0.CTL0.CEN register:

            <field>
              <name>CEN</name>
              <description>Counter enable</description>
              <bitOffset>0</bitOffset>
              <bitWidth>1</bitWidth>
              <enumeratedValues derivedFrom="TIMER0.CTL0.CEN.CEN"/>
            </field>

The generated code reuses the CEN_A and CEN_R types from TIMER0 to every timer but not the CEN_W. The issue is that is defines the type (pub type CEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTL0_SPEC, CEN_A, O>;) but it does not provides its implementation (to set the variants) as it does on TIMER0.

This issue appeared between svd2rust 0.24.0 and 0.25.0.

@burrbull
Copy link
Member

burrbull commented Jan 7, 2023

Please, add link on source

@kaizensparc
Copy link
Author

An example of the bug is available on https://github.com/gd32-rust/gd32-rs for the gd32f1 timer peripheral (the gd32e1 is still a WIP). The generated source code is available on https://github.com/gd32-rust/gd32-rs-nightlies/tree/main/gd32f1. I attached the patched svd used by svd2rust for generation. On the svd file you can see lines 17899-17905 the derived I quoted earlier.
On the generated code you can compare the two CEN_W types for TIMER0 and TIMER1 (which is derived from TIMER0). The documentation for TIMER0.CTL0.CEN is on https://docs.rs/gd32f1/latest/gd32f1/gd32f130/timer0/ctl0/type.CEN_W.html and has the implementation. The one for TIMER1.CTL0.CEN is on https://docs.rs/gd32f1/latest/gd32f1/gd32f130/timer1/ctl0/type.CEN_W.html and lacks the implementation.

gd32f130.svd.txt

@kaizensparc
Copy link
Author

Hello! Any updates on the issue?
Thanks,

@burrbull burrbull added the bug label Jun 5, 2023
@burrbull burrbull changed the title Field writer has no impl when enumeratedValue is derived Field writer has no impl when enumeratedValue is derived across peripherals Jun 5, 2023
@burrbull
Copy link
Member

burrbull commented Jun 5, 2023

изображение

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants