agausmann / atmega-usbd

Rust usb-device support for ATmega chips
BSD Zero Clause License
27 stars 10 forks source link

Unable to run example #10

Closed qwelyt closed 1 year ago

qwelyt commented 1 year ago
atmega-usbd (git)-[master] % cargo run --release --example arduino_keyboard
   Compiling atmega-usbd v0.1.0 (/home/developer/IdeaProjects/github/atmega-usbd)
error: cannot find attribute `interrupt` in this scope
  --> examples/arduino_keyboard.rs:82:3
   |
82 | #[interrupt(atmega32u4)]
   |   ^^^^^^^^^
   |
note: `interrupt` is imported here, but it is a module, not an attribute
  --> examples/arduino_keyboard.rs:18:30
   |
18 | use avr_device::{asm::sleep, interrupt};
   |                              ^^^^^^^^^

error: cannot find attribute `interrupt` in this scope
  --> examples/arduino_keyboard.rs:87:3
   |
87 | #[interrupt(atmega32u4)]
   |   ^^^^^^^^^
   |
note: `interrupt` is imported here, but it is a module, not an attribute
  --> examples/arduino_keyboard.rs:18:30
   |
18 | use avr_device::{asm::sleep, interrupt};
   |                              ^^^^^^^^^

error[E0308]: mismatched types
   --> examples/arduino_keyboard.rs:55:38
    |
55  |         &*USB_BUS.insert(UsbBus::new(usb))
    |                          ----------- ^^^ expected `USB_DEVICE`, found `arduino_hal::pac::USB_DEVICE`
    |                          |
    |                          arguments to this function are incorrect
    |
    = note: `arduino_hal::pac::USB_DEVICE` and `USB_DEVICE` have similar names, but are actually distinct types
note: `arduino_hal::pac::USB_DEVICE` is defined in crate `avr_device`
   --> /home/developer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/avr-device-0.5.0/src/devices/atmega32u4/mod.rs:627:1
    |
627 | pub struct USB_DEVICE {
    | ^^^^^^^^^^^^^^^^^^^^^
note: `USB_DEVICE` is defined in crate `avr_device`
   --> /home/developer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/avr-device-0.4.0/src/devices/atmega32u4/mod.rs:627:1
    |
627 | pub struct USB_DEVICE {
    | ^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `avr_device` are being used?
note: associated function defined here
   --> /home/developer/IdeaProjects/github/atmega-usbd/src/lib.rs:68:12
    |
68  |     pub fn new(usb: USB_DEVICE) -> UsbBusAllocator<Self> {
    |            ^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `atmega-usbd` (example "arduino_keyboard") due to 3 previous errors

Tried to run the example keyboard but unable to compile it. Might there have been updates to the deps in this repo that breaks the example?

I tried to base a project of my own on this repo and the example but couldn't get it to work. Tried to compile the example and get the same errors here. So I guess something has changed.

stappersg commented 1 year ago

On Sat, Mar 18, 2023 at 07:38:28AM -0700, FB wrote: ... it didn't compile on my system ...

So I guess something has changed.

And I wonder if that is a

 it did previously on my system
agausmann commented 1 year ago

Oh yeah, that's possible that there have been breaking changes. I didn't upload a Cargo.lock, and since avr-hal is a git dependency it will fetch the latest version.

I'll try to take a look at updating it this week.

qwelyt commented 1 year ago

Seems to have been an easy fix. Just up avr-device from 0.4 to 0.5 (same as avr-hal uses) and it works.

stappersg commented 1 year ago

On Sun, Mar 19, 2023 at 06:02:05AM -0700, FB wrote:

Seems to have been an easy fix. Just up avr-device from 0.4 to 0.5 (same as avr-hal uses) and it works.

Please convert that into a pull request

agausmann commented 1 year ago

Updated to avr-device 0.5