TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Embedded in Rust: Brave new I/O

365 pointsby kartDover 7 years ago

8 comments

vvandersover 7 years ago
This is amazing. Register and peripheral config is so easy to fuck up and waste a whole day chasing down because of limited debugging capabilities on these platforms. I&#x27;ve hit just about every one of those scenarios these compile-time guards now catch on one project or another.<p>Kudos, can&#x27;t wait to see where to goes from here.
评论 #16189646 未加载
评论 #16191173 未加载
mikepurvisover 7 years ago
This is super exciting, and it smacks a little bit of the C++11 variadic template based HW init scheme explored in the stm32plus library, eg:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;andysworkshop&#x2F;stm32plus&#x2F;blob&#x2F;master&#x2F;examples&#x2F;timer_dual_pwm_gpio_out&#x2F;timer_dual_pwm_gpio_out.cpp#L48-L57" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;andysworkshop&#x2F;stm32plus&#x2F;blob&#x2F;master&#x2F;examp...</a><p>Though obviously the Rust approach provides a lot more guarantees, especially at runtime.<p>The one thing that interests me is how flexible this approach would be at dealing with cases where you have to hack around a hardware bug. For example, I had a board on it with an I2C expander whose default I2C address was not one the STM32 was able to address, but could be changed at runtime with an I2C command. So this was dealt with in firmware by initializing those pins initially as GPIO and bit-banging in the message to change the address, then changing them over to the regular I2C peripheral and taking it from there.<p>How possible would something like that be with this much more tightly constrained Rust IO model?
评论 #16192805 未加载
robotjoshover 7 years ago
These problems that embedded rust is trying to solve are not a big deal. In C you try to minimize what happens in any interrupt, usually just set a flag, save a result, and return. You generally use atomic instructions on gpio. To set or clear a bit mask is atomic so there is not much reason to read-modify-write gpio in an interrupt or anywhere. I think these solutions would create more work than they save.
评论 #16191349 未加载
评论 #16192198 未加载
评论 #16191899 未加载
评论 #16191559 未加载
评论 #16191276 未加载
Animatsover 7 years ago
Nice. So how many manufacturers create those XML files which describe all the registers? Is that common in the Arduino community, for example?
评论 #16190231 未加载
评论 #16190563 未加载
评论 #16189958 未加载
评论 #16189790 未加载
Animatsover 7 years ago
This is, amusingly, a lot like Modula I, circa 1979. That had language support for device registers, cooperative multiprogramming, and interrupts. A very nice way to program a PDP-11 at the bare metal level.
aidosover 7 years ago
OT but I’ve just got into microcontrollers for the first time in the last week via an Arduino Uno. I’m absolutely in love with it and I now need to go a bit deeper (I’m working on a synth). I get a lot of the concepts like the registers to control the timers &#x2F; interrupts but I’ve found a good guide to be lacking. I haven’t seen a list anywhere of all the available registers and what the bits do. I get that it’s different for different chips but I thought the info for more common ones (like the ATMega328) would be easier to come by.<p>Any hints on where to look?
评论 #16191259 未加载
评论 #16191141 未加载
评论 #16191183 未加载
评论 #16191170 未加载
评论 #16191145 未加载
bfrogover 7 years ago
I ordered up a stm32f3 discovery to tinker with this
kurtiscover 7 years ago
This doesn&#x27;t seem particularly courageous, plucky, fearless, valiant, valorous, intrepid, heroic, lionhearted, manful, macho, bold, daring, daredevil, adventurous, or audacious.