Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upThe weekly driver initiative #39
Comments
This comment has been minimized.
This comment has been minimized.
niklasad1
commented
Jan 18, 2018
|
I can probably help porting some NRF51/NRF52 drivers from TockOS that I have been involved in. I think the BLE driver could be interesting to have in a separate crate. Let me know if you think it is a good idea! |
This comment has been minimized.
This comment has been minimized.
|
I'm going to look at my Raspberry Pi SenseHat crate and my LM4F120 chip
crate, as used by the Stellaris Launchpad, as soon as I can.
If TockOS starts using this HAL internally then new chip support should be
easier to add in the future. I found the LM4F120 port fairly hard going.
|
This comment has been minimized.
This comment has been minimized.
dbrgn
commented
Jan 18, 2018
•
This comment has been minimized.
This comment has been minimized.
|
I've tons of devices at hand and I might write drivers for them but first I need to get the device crates and HALs up to snuff. Apart from the usual Serial/I2C/SPI suspects what I'd like to see is whether the HAL approach is also viable for bit-banged GPIO, potentially even timing critical devices, some of which are also in @japaric's list, like the Neopixels. Something that would be really killer to have is support for multiplexed and charlieplexed LED matrices. |
This comment has been minimized.
This comment has been minimized.
alevy
commented
Jan 18, 2018
I'd personally be highly supportive of that, but would need some convincing that it would fit the capsule architecture (that hasn't seemed to be the case for previous iterations). Perhaps @niklasad1 can report some insights if he ports his BLE stack from Tock. |
This comment has been minimized.
This comment has been minimized.
|
@japaric Is there going to be a registry for embedded stuff and especially drivers? crates.io is becoming more and more useless to find interesting crates... |
This comment has been minimized.
This comment has been minimized.
|
The LM4F120 crate now implements |
This comment has been minimized.
This comment has been minimized.
More drivers is a good idea, IMO. :-)
Just to clarify: Is this driver about interfacing an external pre-flashed nRF5x device, or is it some
At the very least we'll want to add a
The words Neopixels and bit banging reminded me of an Arduino library I saw. It implemented the protocol using assembly and was fully blocking (
I meant to include this in the issue description: I'm using the embedded-hal keyword for my driver crates. That makes them easier to find. Perhaps we can just use crates.io and keywords instead of creating another registry / list. We can bikeshed the keywords to use in this thread: perhaps |
This comment has been minimized.
This comment has been minimized.
Coincidentally I'm working on a micro:bit crate (which is based on the NRF51822, as I'm pretty sure you're aware of It's not quite ready for primetime yet since the documentation is somewhat lacking and reversing Zephyr somewhat time consuming due to the many layers of abstraction and indirection. But your recent work and post kind of beat me to adapting what I have to the new singleton approach and also use the embedded-hal (which I previously haven't), so I'm trying to put some more time in.
Yeah, that's going to be interesting. But the reason I mentioned this is that there somehow (and I'm not sure what this will might look like just yet) should be a way to facility the required high speed updates.
Some of those WS controllers can be driven by abused SPI peripherals provided by some MCUs but that can't be taken for granted. AFAIR that doesn't work on the RasPi and that one also cannot do the required timing via bitbanging the GPIOs.
That might work but has quite a number of disadvantages:
crates.io is okay for larger std crates but for the hundreds or even thousands of embedded crates we're going to have, this is going nowhere fast... Originally I was counting on japaric.io or rust-embedded becoming the authoritative source for everything embedded in Rust but somehow this didn't quite happen. ;) My hopes are still that we can establish a lively community around those topics, with a comprehensive catalog of relevant crates (architectural, register mapping, MCU HAL, peripheral HAL, BSP and specific implementations), articles on the use of any of that and general development topics, guides for embedded Rust development and support (development tools and debugging software/hardware to use) and potentially even general MCU howtos (selecting and connecting peripherals to an MCU, developing your own hardware...)... |
This comment has been minimized.
This comment has been minimized.
jacobrosenthal
commented
Jan 19, 2018
|
Greetings,
Another open source nrf ble stack to check out is mynewt's nimble, which is
the rtos im currently using in my daily work.
https://github.com/apache/mynewt-core/tree/master/net/nimble
Im hoping to try out rust for the first time, and ble on the microbit would
be a great reason for me to finally dig in as 'full' functionality
(bootloading over ble mainly) on nrf51822 devices is tough to come by with
every other rtos out there due to the low memory. Curious how rust could
stand up.
This is much futher out there, but the bootloader zephyr and mynewt team
are collaborating on is called mcuboot. It would be pretty cool to support
that, allowing people to transition devices away from zephyr/mynewt into a
rust rtos.
https://github.com/runtimeco/mcuboot/
For now Im quietly lurking and watching you all. Keep up the great work
…On Thu, Jan 18, 2018 at 6:03 PM, Daniel Egger ***@***.***> wrote:
@japaric <https://github.com/japaric>
Just to clarify: Is this driver about interfacing an external pre-flashed
nRF5x device, or is it some BleRadio trait on top of which a generic BLE
stack con be built? In the later case you implement the BleRadio trait for,
say, a nrf51 device crate and you get a BLE stack for free (ideally).
Coincidentally I'm working on a micro:bit crate (which is based on the
NRF51822, as I'm pretty sure you're aware of
|
This comment has been minimized.
This comment has been minimized.
I am aware, I tried everything I could find for that MCU, including (but not limited to) Mynewt, RIOT and Zephyr. Most ecosystems rely on the softdevice while some others provide their own (but often very limited) BLE stack. The Zephyr stack is written by the vendor Nordic themself and has been certified so it is known to be feature complete and (somewhat) correct.
Rust allows for ridiculously small firmwares on those MCUs (compared to other ecosystems that is) so I'm confident that there won't be any space issues per se. Of course if you add a BLE capable bootloader for DFU that whole situation changes a good deal because that will take a sizeable amount of flash by itself. I wouldn't hold my breath for that to materialize. ;) Bootloaders don't have a very high priority for me at the moment but adding support for mcuboot might be straight forward. Question is what the benefits would be, especially on the micro:bit but I'll have a look, thanks. |
This comment has been minimized.
This comment has been minimized.
whitequark
commented
Jan 19, 2018
Is that really true? The generated |
This comment has been minimized.
This comment has been minimized.
That's true, Here I have an example rendering a counter triggered by USART input onto an I2C driven SSD1306 OLED display:
This (a bit older example) includes |
This comment has been minimized.
This comment has been minimized.
chocol4te
commented
Jan 19, 2018
|
I have both an HC05 and HC06 pair and a tricolour e-ink display. I should be able to start work on these pretty soon. |
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
Jan 19, 2018
|
I already have (incomplete) |
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
Jan 19, 2018
•
|
@whitequark, @therealprof check out |
This comment has been minimized.
This comment has been minimized.
whitequark
commented
Jan 19, 2018
|
@Kixunil any documentation would be helpful. |
This comment has been minimized.
This comment has been minimized.
mneumann
commented
Jan 19, 2018
|
would be great to have USB support, i.e. some library interfacing for instance FTDI chips. seems like tock os got some generic USB code. |
This comment has been minimized.
This comment has been minimized.
|
@mneumann Not sure I follow. Why would you use an USB<->Serial interface? Some MCUs have USB peripherals built-in but providing an HAL for creating an USB endpoint is a somewhat complex and very specific. |
This comment has been minimized.
This comment has been minimized.
mneumann
commented
Jan 20, 2018
|
@therealprof : if the MCU has a built-in USB peripheral then I'd of course use that, given that it's easy to use from Rust ;-). But those devices I have at hand, need an external USB chip. Regardless of whether it's on or off-chip, I'd love to be able to use USB from Rust. This is just the last (big) missing piece to make use of Rust on embedded for me. |
This comment has been minimized.
This comment has been minimized.
lnicola
commented
Jan 20, 2018
This comment has been minimized.
This comment has been minimized.
|
I have created a separate issue for tracking progress on a generic USB stack: #40. Please continue USB discussions over there; let's keep this thread focused on drivers built on top of embedded-hal. (I'm of the opinion that USB is complex and specialized enough that it should go into its own crate separate from embedded-hal.) |
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
Jan 21, 2018
|
@whitequark what exactly are you missing? |
This comment has been minimized.
This comment has been minimized.
I already had the DHT22 working with Rust at some point, although not in the form of a reusable driver library. If anyone is interested, I can dig up the code. Caveats: It's messy code, integrated into an application, built on top of other messy unpublished code. I'm not sure how useful it's going to be, but as a starting point, it may be better than nothing.
I'm in full agreement. Not sure what the best keywords would be, but we should have them. I'm already using the
I think your points are valid, and I would love to see a community resource like the one you describe. However, someone has to build this, and it's going to be a lot of work. crates.io is already here, and we can start using the suggested tags to ease the problems that it has right now. |
This comment has been minimized.
This comment has been minimized.
JJJollyjim
commented
Jan 22, 2018
|
I'm gonna have a go at building something for a HD44780-style (S6A0069 in my case) 16x2 LCD. @japaric I see you mention an LCD in the context of an IO expander: would a potential IO expander API expose |
This comment has been minimized.
This comment has been minimized.
I totally agree. One doesn't preclude the other. I fully expect that crates.io will remain the official source for all crates, including embedded ones. I was hoping we could at least get something like https://github.com/brson/stdx up. |
This comment has been minimized.
This comment has been minimized.
kunerd
commented
Jan 22, 2018
|
@JJJollyjim: clerk might be of interest for you. Here are some tickets from embedded-hal |
This comment has been minimized.
This comment has been minimized.
It's just that the LCD I have has an I2C port expander attached to it and the only interface that the module exposes in I2C. But ideally the port expander driver, say |
This comment has been minimized.
This comment has been minimized.
dbrgn
commented
Jan 22, 2018
|
For HD44780 compatible LCDs, there are mainly two I²C port expanders used: The PCF8574 and the MCP23008. In case it helps, here's my Python driver for those LCDs: https://github.com/dbrgn/RPLCD/blob/master/RPLCD/i2c.py |
This comment has been minimized.
This comment has been minimized.
dbrgn
commented
Apr 1, 2018
Oh, sorry, confused it with the RFM95.
A pure-rust LoRaWAN stack implementation (ideally device-agnostic) would be amazing |
This comment has been minimized.
This comment has been minimized.
dbrgn
commented
Apr 1, 2018
|
SGP30 driver is complete and published: https://blog.dbrgn.ch/2018/4/1/rust-sgp30-driver/ |
This comment has been minimized.
This comment has been minimized.
byronwasti
commented
Apr 1, 2018
|
I have a WIP Memory LCD driver working: https://github.com/byronwasti/ls010b7dh01 My next steps are to abstract away some of the details and to make it screen-size independent. I also just discovered the |
This comment has been minimized.
This comment has been minimized.
|
Hiya folks! I've deprecated the list of drivers in the issue description in favor of the awesome-embedded-rust list. That list contains not only the list of drivers we had here but also list of device crates, board support crates and HAL implementation crates. This rationale of this change is that (a) it's better to have a single place to go and find embedded / no-std crates (ideally crates.io should be this place but it's still lacking in domain specific discoverability); and (b) it makes the maintenance of the list easier: you can now send a PR to add your crate to the list instead of waiting for me to notice your comment in this thread. So, please go ahead and send PRs to that list if I forgot about you (sorry) or if you would like to move your driver crate from the WIP list to the "released" list. I also would love some help maintaining the list and merging PRs. If you are interested leave a comment in rust-embedded/awesome-embedded-rust#3. |
This comment has been minimized.
This comment has been minimized.
mbacch
commented
Apr 2, 2018
•
therealprof
referenced this issue
Apr 8, 2018
Open
Split up one list into easier digestible subpages #20
This comment has been minimized.
This comment has been minimized.
TheZoq2
commented
Jun 3, 2018
|
I wrote a driver for the dht11 and dht22 temperature/humidity sensors for one of my projects: https://github.com/TheZoq2/weather/blob/master/stmhardware/src/dhtxx.rs. There are some issues with it however
|
This comment has been minimized.
This comment has been minimized.
JoshMcguigan
commented
Jul 1, 2018
•
|
After completing the Discovery book I started writing a very basic shift register driver. struct ShiftRegister<Pin1, Pin2, Pin3>
where Pin1: OutputPin,
Pin2: OutputPin,
Pin3: OutputPin,
{
clock: Pin1,
latch: Pin2,
data: Pin3,
}
impl<Pin1, Pin2, Pin3> ShiftRegister<Pin1, Pin2, Pin3>
where Pin1: OutputPin,
Pin2: OutputPin,
Pin3: OutputPin,
{
fn new(clock: Pin1, latch: Pin2, data: Pin3) -> Self {
ShiftRegister { clock, latch, data }
}
fn update(&mut self, output_state: [bool; 8]) {
self.latch.set_low();
for i in 1..=8 {
if output_state[output_state.len()-i] {self.data.set_high();}
else {self.data.set_low();}
self.clock.set_high();
self.clock.set_low();
}
self.latch.set_high();
}
}I am very new to embedded development (and relatively new to Rust in general), so I'd like to ask a few questions:
I want to say thanks to @japaric for putting together the Discovery book, and to the embedded-wg community for sharing so many drivers. This has been a great learning experience so far, and I look forward to being able to contribute back. |
This comment has been minimized.
This comment has been minimized.
JoshMcguigan
commented
Jul 3, 2018
|
I've fleshed out the driver above a bit more and created shift-register-driver. It is still a simple implementation, but it does accomplish the Any feedback is appreciated! |
This comment has been minimized.
This comment has been minimized.
|
@JoshMcguigan This is a great idea. There're probably more small functionalities like this which can be implemented in a somewhat generic way. I was already thinking of creating a crate that bundles these kind of GPIO adapter for general consumption; other adapters I can imagine from the top of my head:
Of course all of the adapters would be stackable, so if you wanted to drive a segmented display using a shift-register which requires a the latch to have an inverted signal -- you can do that. NB: Don't forget to add a release function so someone could can get their moved GPIO pins back. |
This comment has been minimized.
This comment has been minimized.
JoshMcguigan
commented
Jul 3, 2018
|
@therealprof Thanks for the feedback. I've added the I do like your idea of building up those types of abstractions. |
hannobraun
referenced this issue
Jul 4, 2018
Closed
Common and coherent license policy for rust-embedded and drivers? #57
This comment has been minimized.
This comment has been minimized.
JoshMcguigan
commented
Jul 7, 2018
|
I've added a pull request to add the shift register driver to the list. The intro blog post is up as well. Thanks again for the feedback. |
This comment has been minimized.
This comment has been minimized.
|
Has anyone tried doing CAN with the STM32F3DISCOVERY (or any microcontroller)? It looks like this Discovery Shield has a SN65HVD230 CAN transceiver on it (listed in @japaric's original post). |
This comment has been minimized.
This comment has been minimized.
|
Hey @johnthagen, you might want to check out the discussion on the |
This comment has been minimized.
This comment has been minimized.
kjetilkjeka
commented
Jul 9, 2018
|
@johnthagen I've used can in rust with NXP S32K and socketcan on rpi (if it qualifies as a MCU). |
This comment has been minimized.
This comment has been minimized.
eldruin
commented
Aug 6, 2018
This comment has been minimized.
This comment has been minimized.
eldruin
commented
Aug 8, 2018
|
I have created a topic in the rust users forum asking for design and implementation feedback and ideas about my serial EEPROM driver. |
This comment has been minimized.
This comment has been minimized.
eldruin
commented
Sep 10, 2018
|
Hi, my 24x serial EEPROM driver is now finished and my PR here was just merged. The intro blog post is also here. |
This comment has been minimized.
This comment has been minimized.
eldruin
commented
Sep 26, 2018
|
Hi, my DS1307 real-time clock driver is now finished and my PR here was just merged. The intro blog post is here. |
This comment has been minimized.
This comment has been minimized.
e-matteson
commented
Sep 26, 2018
|
I just put in a PR for my released keypad matrix driver. It's a bit different in that it's for a generic sort of circuit, rather than a device, but I think it fits here. @JoshMcguigan and @therealprof, your discussion here about adding abstractions around GPIOs is super interesting, so I applied that to reading from a keypad. I'd be happy to hear any feedback on the design! |
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
Dec 8, 2018
|
Hi, I got a bit of time to play with my Nucleo and I've developed seven_segment crate for controlling 7-segment displays. |
This comment has been minimized.
This comment has been minimized.
eldruin
commented
Dec 8, 2018
|
Hi, my TMP006 Contact-less IR thermopile driver (non-contact temperature sensor) is now finished and my PR here was merged. The intro blog post is here. |
This comment has been minimized.
This comment has been minimized.
|
@Kixunil Nice. It's actually much more versatile and better documented than mine: https://crates.io/crates/sevensegment . Have to check it out. |
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
Dec 10, 2018
|
@therealprof what the hell, I tried to find whether there's such crate out there already and didn't find your. :( |
This comment has been minimized.
This comment has been minimized.
rnestler
commented
Dec 13, 2018
•
Interestingly if you search for "seven segment" you won't find the sevensegment crate. |
This comment has been minimized.
This comment has been minimized.
dbrgn
commented
Dec 13, 2018
Maybe add a "sevensegment" keyword in |
This comment has been minimized.
This comment has been minimized.
eupn
commented
Feb 6, 2019
|
Just pulled off a Bosch BNO055 Nine-axis IMU sensor driver: |
This comment has been minimized.
This comment has been minimized.
eldruin
commented
Mar 29, 2019
|
Hi, my TMP1x2 temperature sensor driver is now finished. The intro blog post is here. |
japaric commentedJan 18, 2018
•
edited
There's now a HAL published on crates.io:🎉
embedded-hal(Introduction blog post).To put it to test and to expand the crates.io ecosystem I'm starting the weekly driver initiative.
The goal is to release a new no_std, generic,
embedded-halbased driver crate every one or twoweeks. Driver crate here means a library crate that lets you interface an external component like a
digital sensor or a wireless transceiver. A driver release consists of (a) publishing a library
crate on crates.io (*) and (b) presenting your driver to the community via any means: a blog post,
a tweet, a reddit post, a
u.r-l.ohttps://users.rust-lang.org post, etc.(*) Make sure you tag your crate with the
embedded-hal-driverkeyword!If you'd like to participate leave a comment here stating the driver you'll be working on. If you
can post a link to the repo where the (WIP) driver code is or will be, even better! If you don't
have a personal blog to present your driver to the community you can do a guest post on my blog.
For a list of released and WIP drivers check the awesome-embedded-rust list. If you'd like your crate to be added to that list simply send a PR to that repo!
TODO (potentially):
These are components that @japaric has at hand:
ENC28J60 - ethernet controller (SPI)L298N - Motor driver