Rahix / avr-device

Register access crate for AVR microcontrollers
Apache License 2.0
170 stars 66 forks source link

Escaping/Renaming `ASYNC` register #66

Closed trembel closed 3 years ago

trembel commented 3 years ago

Trying to compile for attiny412 following error occurs, due to the naming of the ASYNC register in the TCB0 and TCD0 peripheral:

error: expected identifier, found keyword `async`
   --> src/devices/attiny412/tcb0/ctrlb.rs:248:12
    |
248 |     pub fn async(&self) -> ASYNC_R {
    |            ^^^^^ expected identifier, found keyword
    |
help: you can escape reserved keywords to use them as identifiers
    |
248 |     pub fn r#async(&self) -> ASYNC_R {
    |            ^^^^^^^

error: expected identifier, found keyword `async`
   --> src/devices/attiny412/tcb0/ctrlb.rs:270:12
    |
270 |     pub fn async(&mut self) -> ASYNC_W {
    |            ^^^^^ expected identifier, found keyword
    |
help: you can escape reserved keywords to use them as identifiers
    |
270 |     pub fn r#async(&mut self) -> ASYNC_W {
    |            ^^^^^^^

error: expected identifier, found keyword `async`
   --> src/devices/attiny412/tcd0/evctrla.rs:256:12
    |
256 |     pub fn async(self) -> &'a mut W {
    |            ^^^^^ expected identifier, found keyword
    |
help: you can escape reserved keywords to use them as identifiers
    |
256 |     pub fn r#async(self) -> &'a mut W {
    |            ^^^^^^^

error: expected identifier, found keyword `async`
   --> src/devices/attiny412/tcd0/evctrlb.rs:256:12
    |
256 |     pub fn async(self) -> &'a mut W {
    |            ^^^^^ expected identifier, found keyword
    |
help: you can escape reserved keywords to use them as identifiers
    |
256 |     pub fn r#async(self) -> &'a mut W {
    |            ^^^^^^^

Not sure if this should be fixed in atdf2svd by renaming ASYNC registers, or here.

Rahix commented 3 years ago

Try using a version of svd2rust built from git, I believe this is fixed over there.

trembel commented 3 years ago

Yes, this is fixed - but introduces a new error (for ALL avr devices):

error[E0433]: failed to resolve: use of undeclared crate or module `cortex_m`
  --> src/devices/attiny412/interrupt.rs:52:13
   |
52 | unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
   |             ^^^^^^^^ use of undeclared crate or module `cortex_m`

error: Compilation failed, aborting rustdoc
Rahix commented 3 years ago

Hmm, that's new ... Can you try d6c668dedfea for now? I guess this is an upstream regression we need to report. I'll take a look ...

trembel commented 3 years ago

Its because of this breaking change: https://github.com/rust-embedded/svd2rust/blob/c68b71c09c87ff17270e9e8e6cb63f45276b5068/CHANGELOG.md#changed

Rahix commented 3 years ago

Yeah, apparently https://github.com/rust-embedded/svd2rust/pull/473 was not well tested for other platforms :D

Rahix commented 3 years ago

Makes sense, the code they modified is in the else branch of the architecture selection if which is also used for AVR ...

Rahix commented 3 years ago

Made a report. For the time being, using the older git hash I linked above should work for you.

trembel commented 3 years ago

Worked, thanks. I think we should left this open, until svd2rust publishes a new version.

tones111 commented 3 years ago

The fix appears to have been made upstream in https://github.com/rust-embedded/svd2rust/pull/483/files. Since the broken change was never released, should this issue be closed?

Rahix commented 3 years ago

Agreed.