Rust usb-device support for ATmega chips

Overview

atmega-usbd

usb_device support for ATmega microcontrollers.

NOTE: This is an experimental library, and certainly not production-ready. Expect bugs, and please help out by reporting them if you find any! If you need absolute reliability, consider a more mature framework like LUFA.

MCU support

Currently supports:

  • ATmega16u4/32u4

Untested but probably close to being supported:

  • ATmega8u2/16u2/32u2 - USB peripheral is very similar to m16u4.

Example

See rust-avr-usb for an example usage.

Comments
  • New to embedded rust. Some idle questions.

    New to embedded rust. Some idle questions.

    Hi, so I managed to implement a simple midi controller yesterday, using usbd-midi and atmega-usbd. I'm not new to Rust and have done some arduino embedded before, but this was the first time I joined the two. Frankly, I'm still a newbie at embedded in general. So I have a few questions if you don't mind.

    • My device is working when connected to windoze, but I'd like to send a prototype to a mac/ipad user. Have you tested this lib connected to mac/ipad? Ignore the midi part, I just mean the USB side. My theory is that it should just work(tm). I'm sending them a prototype board, so I'll be able to report back on this in a week or so.
    • The example code you've provided is much more verbose than something like https://github.com/btrepp/usbd-midi (STM32). As a suggestion to you, is it possible to move much of this interrupt stuff into your library such that the user side implementation is easier? I did try to move the polling out of the interrupt and into my program loop, but that caused windoze to fail to recognise the device, which I found odd given the btrepp STM32 example works fine in the main thread.
    • What is the purpose of the PLL section? I tested my code with and without and it works either way.

    I realise this library is still fledgeling. Thank you for implementing it. You saved me a big headache!

    opened by alexmadeathing 4
  • README.md  link to example

    README.md link to example

    The example link in the README.me points to an archived git repository. That archived git repo points back to this repository.

    Please update the README.md so there is a less confusing link.

    opened by stappersg 1
  • UENUM/EPNUM register stops working sometime after enable()

    UENUM/EPNUM register stops working sometime after enable()

    In the process of tracking down why I can't send/receive packets via other endpoints, I've discovered that writes to EPNUM don't stick sometimes. If you read the value of EPNUM immediately after writing to it and compare to the value you wrote, it might not be the same.

    I've been tracing the code and it seems to work fine for a while and then stops working at some point. Some data points:

    • It works just fine while configuring endpoints near the start of the program, in enable() (which is called when the UsbDevice is constructed, finalizing endpoint allocations).

    • It stops working sometime before the USB reset signal (i.e. before the first EORSTI interrupt), e.g. you may notice it fail in poll when the endpoint interrupt flags are being checked for pending data.

    • Polling the endpoint interrupt flags does work at least once before failing

    • When it fails, if you read the value of EPNUM before and after the write, the before/after values are always equal, and they might always be zero (I may have encountered a situation where they were non zero but I don't quite remember)

    opened by agausmann 1
  • A way to nicely recreate usb device

    A way to nicely recreate usb device

    Basically i have usbd-serial device in the main loop, and i want to use serial device to log errors in the panic handler.

    There are two solutions for this:

    1. Make a global serial singleton.
    2. Reset the device somehow.

    First one should just work, but i want to implement second one, and have encountered problems with this.

    I have tried setting a static mut var in the .noinit section, similar to how lufa jumps to bootloader, to keep that variable between reboots, then have used watchdog to reset the program, and then on the start of the program checked if that variable is set do the actual panic handling, but even that doesn't work, for some unknown reason, i have to wait until PC powercycles the devices itself.

    I have tried .reset() method on the bus, but that doesn't work.

    I have found .force_reset() method that is currently unimplemented and i think that is what i need probably, so what i ask is for its implementation.

    opened by kanashimia 0
  • arduino_keyboard:

    arduino_keyboard: "Hello World" is typed as "Helo World"

    The reports for the two "L" keypresses are identical, which supposedly makes the host PC think that the "L" key has been held down.

    Possible solutions:

    • Send an empty report in between identical characters
    • (Possibly simpler) Send an empty report between all characters
    opened by agausmann 3
  • UsbBus should take ownership of the D+ and D- pins.

    UsbBus should take ownership of the D+ and D- pins.

    Their default configuration allows them to function as the USB data pins, but it should still consume them to make sure they are configured correctly.

    opened by agausmann 1
Owner
Adam Gausmann
Systems/embedded programming and cyber security enthusiast, trying to make software safer and more beautiful. Big fan of @rust-lang 🦀
Adam Gausmann
Code for connecting an RP2040 to a Bosch BNO055 IMU and having the realtime orientation data be sent to the host machine via serial USB

Code for connecting an RP2040 (via Raspberry Pi Pico) to a Bosch BNO055 IMU (via an Adafruit breakout board) and having the realtime orientation data be sent to the host machine via serial USB.

Gerald Nash 3 Nov 4, 2022
Open-source NI maschine device handling

Open-source NI maschine device handling

william light 69 Dec 1, 2022
AVR device definitions

avrd AVR device definitons in Rust. Documentation This crate exposes information about different AVR microcontrollers so it can be used pragmatically.

The AVR-Rust project 32 Dec 28, 2022
Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust

Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust, and with an eye towards serializing runtime errors using serde.

Findora Foundation 1 Feb 12, 2022
Utilities to gather data out of roms. Written in Rust. It (should) support all types.

snesutilities Utilities to gather data out of roms. Written in Rust. It (should) support all types. How Have a look at main.rs: use snesutilities::Sne

Layle | Luca 5 Oct 12, 2022
A rewrite of Phonelink for Windows Forms written in Rust, with cross-platform support.

phonelink-rs A rewrite of Phonelink for Windows Forms written in Rust, with cross-platform support. Usage Clone the repository and build, or download

ahsan-a 4 Aug 6, 2022
Board Support Crate for Arduino Leonardo in Rust

Deprecation Note: This crate will soon be deprecated in favor of avr-hal. avr-hal is a new approach to writing the HAL crate, that was designed with s

Rahix 5 May 6, 2021
Universal changelog generator using conventional commit+ with monorepo support. Written in Rust.

chlog Universal changelog generator using conventional commit+ with monorepo support. chlog can generate the changelog from the conventional commits w

Jeff Yang 3 Nov 27, 2022
🦀 Rust support library for semaphore

?? semaphore-rs Rust support library for using semaphore. It's mostly a Rust rewrite of zk-kit, but just focuses on semaphore (for now) and still cove

Worldcoin 31 Dec 21, 2022
Rust no_std, embedded_hal board support package for the Electro-Smith Daisy platform.

Daisy Rust no_std, embedded_hal board support package for the Electro-Smith Daisy platform. This project was forked from antoinevg/daisy_bsp. Supporte

zlosynth 5 Dec 4, 2022
OpenAPI support for Poem

Poem OpenAPI Fast and Type-Safe OpenAPI implementation for Poem. Poem-openapi allows you to easily implement APIs that comply with the OpenAPIv3 speci

Poem Web 40 Sep 16, 2021
Use enum to filter something, support | and & operator.

Filter Use enum to filter something, support | and & operator. Just need to implement Filter Trait with filter-macros crate. How to work Example #[add

上铺小哥 9 Feb 8, 2022
`xrandr` for Gnome/wayland, on distros that don't support `wlr-randr`

gnome-randr-rust A reimplementation of xrandr for Gnome on Wayland, especially for systems that don't support wlr-output-management-unstable-v1 (e.g.

Max Ainatchi 40 Dec 21, 2022
How to bootstrap support for a no_std target

The Embedonomicon How to bootstrap support for a no_std target This book is hosted at https://docs.rust-embedded.org/embedonomicon/ This project is de

Rust Embedded 191 Dec 20, 2022
⚙️ A cute .gitignore generator with support for custom templates

Gign A Gitignore Generator Table of Contents Examples Install Custom templates Help Examples # This is how you going to use it probably most of the ti

Vadim 6 Dec 7, 2022
Lapce vue plugin, support vue (SFC) syntax highlight, autocomplate,types check

Lapce Plugin for Vue (based volar) Preview Usage Required: Lapce version must be greater than 2.0, and you can use Lapce nightly version. click here t

xiaoxin 32 Dec 26, 2022
Mommy's here to support you when running cargo~

cargo-mommy Mommy's here to support you when running cargo~ ❤️ Installation Install cargo-mommy like you would any other cargo extension~ > cargo inst

Aria Beingessner 198 Jan 5, 2023
serde support for http crate types Request, Response, Uri, StatusCode, HeaderMap

serde extensions for the http crate types Allows serializing and deserializing the following types from http: Response Request HeaderMap StatusCode Ur

Andrew Toth 3 Nov 1, 2023
k-mer counter in Rust using the rust-bio and rayon crates

krust is a k-mer counter written in Rust and run from the command line that will output canonical k-mers and their frequency across the records in a f

null 14 Jan 7, 2023