Comments (11)
FWIW I spent some time getting the USB stuff to work with RTFM (which could help with eliminating the globals) but found it hard to get both the inner references (i.e. device needs a ref to the serial object) and then return those same objects from init (because the objects constructed in init
did not have static
lifetimes). I am sure there is some magic here that would allow RTFM to work that I am just missing though I am not sure whether RTFM counts as solving the globals issue.
from atsamd.
This is one of those thing's that's left over from when @wez was running the project and frankly I'm scared to touch it lol.
from atsamd.
I'm interested in working on this, but as a newbie to rust its best if I'm told what to do. How can I help?
from atsamd.
I've been a bit too busy to pick this up in a while. Things have matured a bit more in the upstream usb-device crate so what I think needs to be done in this one now is:
- Update to the latest usb-device code; there have been a few API changes that will require some changes
- Revise https://github.com/atsamd-rs/atsamd/blob/master/boards/metro_m0/examples/usb_serial.rs to use the now standalone CDC-ACM serial implementation crate https://github.com/mvirkkunen/usbd-serial
With that done, we'll have a relatively low level support for USB on this class of devices and can consider actually enabling that code when publishing to crates.io, but there is still more to be done to make practical USB device implementations:
- USB HID support (near and dear to my heart for keyboards)
- USB storage device support to expose eg: on-board SPI based flash storage, or perhaps UF2 bootloader
I see these as requiring some work in the upstream usb device crate with appropriate atsamd-specific support happening in this crate.
There's also a distinction between low-level support (eg: it basically works) and ergonomic high-level support (eg: there's a nice way to respond to USB HID events and embed support in a consuming application crate).
Beyond the bus implementation in this crate, most of the work to be done is generic USB stuff that should happen in the usb-device project.
from atsamd.
I'll take a look at updating the samd21 crate, but I don't have hardware so it will need someone else to test.
I'll also try and get it working for samd51, which I do have hardware for.
from atsamd.
Looking at the samd21 code, it looks very similar to what is required for samd51. I expect there's a good amount we can put in the common crate.
from atsamd.
This is slowly coming along here. Some notes/changes for comment:
- Instead of only exposing an implementation of the
usb_device::bus::UsbBus
device, I'm going to expose a lower-level (no state, no memory management) APIUsbController
, which theUsbBus
implementation will be built off. - I'm refactoring the
ep!
macro to collect all the registers for a given endpoint into a single structure,EndpointRegs
, which will provide a nicer internal API over mutating the state of the endpoint registers. - Aside from HAL layers, move away from using the term Bank to describe one endpoint in an endpoint pair, as I couldnt find any reference to it outside of datasheets.
- I'm using a single lifetime across all objects from
UsbController
downwards, and instantiating them all at the same time. This allows us to avoidRef*
andMutex
boxing.
from atsamd.
Heya @wez, how did you get the dbgprint!
macro to dance your tune?
I made the mistake of writing the samd51 driver all at once, so it attaches but doesnt enumerate. I'm thinking it would be nice to have a printf out a SERCOM UART, but if thats something youve already done I'll gladly copypasta :)
from atsamd.
@twitchyliquid64 Did you make any progress on the samd21 port? I've got some devices I'd be willing to test with.
from atsamd.
@BenBergman no - haven't ported samd21 USB support over to the 0.3 version of usb-device. The original code (which ran from an earlier version) should still be usable.
In terms of working on the USB peripheral, I've been side-tracked by other projects as of late, but hope to get back to this + fixing the other bug soon.
from atsamd.
I tried compiling the Metro-M0 usb-serial example but it is failing to compile for me, so I'm guessing some other change broke something. I poked at it a bit but low level USB is a bit beyond me and the limited time I have to focus on it.
Let me know when you get back to it and I can test on a few Adafruit M0 boards I have lying around.
from atsamd.
Related Issues (20)
- Is the ATSAMDA1 micro supported? HOT 3
- wio-terminal Wi-Fi examples broken by #542 HOT 13
- Read state of EIC pin HOT 1
- Example for standalone usage? HOT 7
- I2C slave mode support HOT 4
- Wrong GCLK used for Metro M4 and Grand Central Express USB
- Non-working implementation of eic::pin::ExternalInterrupt::id() HOT 2
- RTC peripheral can be used without configuring the RTC clock
- PACs need to be regenerated to remove lint diagnostic
- How can I use usb function on 0.15.0 or higher HOT 3
- `Spi` implementation relies on fragile timing HOT 4
- Add support for SAMC2x ? HOT 11
- Correct alternate for USB pins on some M4 BSPs? HOT 4
- `hal::sercom::uart::Config` could potentially check for the correct sercom clock HOT 2
- Allow a way to get >1 `impl Delay` type HOT 8
- pybadge support HOT 2
- How to keep the device in bootloader mode? HOT 3
- atsamd21e18a I2C HOT 6
- Unable to use cargo flash in the feather_m0 repo HOT 2
- Wio Terminal, eRPC communication, USART Overflow
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atsamd.