<re_irc> <@dngrs:matrix.org> I'm still unsure how any software solution would help me with spurious events when releasing after a long press
<re_irc> <@9names:matrix.org> if the debouncing countdown only starts after the pressed->released transition it should work just fine
<re_irc> <@9names:matrix.org> or one that just resets the counter any time it sees logic high would also work
<re_irc> <@9names:matrix.org> assuming high is pressed in this scenario
<re_irc> <@dngrs:matrix.org> the problem I'm facing is: press button, *hold for a long time*, release, *receive spurious press event*
<re_irc> <@dngrs:matrix.org> also, I wanna reiterate that I'm not stuck with this; I'm currently working on sth else and afterwards will play around with scope + apply the electrical fixes suggested by James earlier
<re_irc> <@dngrs:matrix.org> (I want to trigger my actions on *press*, not *release*, therefore I really don't think this can be solved in software)
<re_irc> <@dirbaio:matrix.org> start a timer on release, that blocks more events for a bit
<Lumpio-> Debouncing can totally be solved in software
<re_irc> <@dngrs:matrix.org> dirbaio:matrix.org: ah yes. Facepalm moment :)
<re_irc> <@dngrs:matrix.org> thx!
<Lumpio-> Usually I'm just lazy and poll the button every N milliseconds if I don't care about power usage
<Lumpio-> Where N is bigger than the bounce time
<re_irc> <@dirbaio:matrix.org> with async I always do
<re_irc> <@dirbaio:matrix.org> loop {
<re_irc> <@dirbaio:matrix.org> pin.wait_for_low().await;
<re_irc> <@dirbaio:matrix.org> ```rust
<re_irc> <@dirbaio:matrix.org> works great *and* is as low-power as it gets
<re_irc> <@adamgreig:matrix.org> is Timer there shared system-wide somehow?
<re_irc> <@jamesmunns:beeper.com> I think Embassy does something similar to groundhog?
<re_irc> <@jamesmunns:beeper.com> e.g. a global timer item (though I think embassy keeps it with the executor?)
<re_irc> <@dirbaio:matrix.org> yeah, it uses a single hardware timer/rtc that's always counting
<re_irc> <@dirbaio:matrix.org> it gives Instant, Duration, Timer
<re_irc> <@dirbaio:matrix.org> and the executor has a timer queue, so multiple tasks can use Timers to sleep at the same time
<re_irc> <@firefrommoonlight:matrix.org> I've been debouncing with a timer. Fires in button's ISR. Runs for ~1/10 of a second or so. If it's running, abort the button's ISR. If not, continue with button logic
<re_irc> <@firefrommoonlight:matrix.org> On STM32, I also use an interrupt with the timer that resets and stops it. On nRF, this isn't required due to the shortcut that automatically does this
<re_irc> <@firefrommoonlight:matrix.org> However, on nRF I need to keep track of if the timer's running using an atomic bool etc, since there's no way to check with registers AFAIK
<re_irc> <@firefrommoonlight:matrix.org> There are probably more clever deboucne techniques avail
<re_irc> <@dirbaio:matrix.org> firefrommoonlight:matrix.org: you can leave the timer irq disabled, then just read the event flag to know if it's expired or not
<re_irc> <@firefrommoonlight:matrix.org> Oh nice! I should probalby do that instead
<re_irc> <@firefrommoonlight:matrix.org> That would indeed prevent the need for the timer's ISR
fabic has joined #rust-embedded
<re_irc> <@jamesmunns:beeper.com> Okay y'all, it absolutely *blows my mind* `cortex-m` AND `heapless` each have *1.2 MILLION* downloads on crates.io
<re_irc> <@dirbaio:matrix.org> something something CI jobs with badly configured cache
<re_irc> <@jamesmunns:beeper.com> Still an indicator of use.
<re_irc> <@dirbaio:matrix.org> yep1
<re_irc> <@jamesmunns:beeper.com> dirbaio spreading the good word of `atomic-polyfill`: https://twitter.com/ThomasWinwood/status/1464015067524087820
<re_irc> <@dirbaio:matrix.org> ARMv4T, oh boi
<re_irc> <@jamesmunns:beeper.com> Yeah, shame Lokathor isn't idling. rust-gba is where I see most active rust-on-armv4t work
<re_irc> <@dirbaio:matrix.org> I don't think it's standardized, no
<re_irc> <@dirbaio:matrix.org> on gba/nds you use this reg https://problemkaputt.de/gbatek.htm#gbainterruptcontrol
<re_irc> <@jamesmunns:beeper.com> ah, fair. is that generally some kind of Global Interrupt Enable (GIE) flag?
<re_irc> <@dirbaio:matrix.org> yeah
<re_irc> <@dirbaio:matrix.org> but I dunno if that's defined by ARM or Nintendo, but looks like it's Nintendo lol
<re_irc> <@jamesmunns:beeper.com> heh
<re_irc> <@dirbaio:matrix.org> > Note that there is another 'master enable flag' directly in the CPUs Status Register (CPSR) accessible in privileged modes, see CPU reference for details.
<re_irc> <@dirbaio:matrix.org> that one is ARM-standard I guess
<re_irc> <@jamesmunns:beeper.com> yeah
<re_irc> <@jamesmunns:beeper.com> Another day, another twitter conversation about UB :D
jackneilll has quit [Remote host closed the connection]
jackneilll has joined #rust-embedded
jackneillll has joined #rust-embedded
jackneilll has quit [Ping timeout: 245 seconds]
PyroPeter has quit [Ping timeout: 245 seconds]
PyroPeter has joined #rust-embedded
tokomak has joined #rust-embedded
cr1901_ has joined #rust-embedded
cr1901 has quit [Ping timeout: 264 seconds]
fabic has quit [Ping timeout: 260 seconds]
<re_irc> <@m3angreen:matrix.org> Hello,
<re_irc> <@m3angreen:matrix.org> I'm embedded dev and I recently have a lot of time that I want to spend to learn and maybe contributing to rust-analyzer (LSP server for Rust).
<re_irc> <@m3angreen:matrix.org> what feature rust-analyzer misses for embedded development?
<re_irc> <@m3angreen:matrix.org> So I've got a question,
<re_irc> <@m3angreen:matrix.org> What rust-analyzer features your missing most in your embedded development workflow?
<re_irc> <@k900:0upti.me> r-a doesn't really do anything embedded-specific
<re_irc> <@k900:0upti.me> (which is a good thing)
<re_irc> <@pvdb:matrix.org> hi everybody, I'm using stm32f1xx-hal, and I'm trying to configure an USART as single wire half duplex. According to the STM docs I should set the HDSEL bit in its CR3 register. I can do that using "p.USART1.cr3.write(|w| w.hdsel().set_bit());". But if I create a stm32f1xx_hal::Serial object, it resets the USART device (including the HDSEL bit) and takes ownership of the p.USART1 object (and keeps it in a...
<re_irc> ... private field), so I cannot set the bit afterwards. What's the best way to set the HDSEL bit and still be able to use Serial?
<re_irc> <@m3angreen:matrix.org> K900: Totally agree, but maybe some features that might be especially helpful for embedded/bare-metal development?
<re_irc> <@k900:0upti.me> Maybe something to do with run configurations in the VSCode plugin, but I really can't think of much else
<re_irc> <@k900:0upti.me> Embedded Rust isn't different enough from regular Rust l
<re_irc> <@k900:0upti.me> pvdb:matrix.org: Does the HAL not have a way to set that? If it doesn't, I'd say you should just add it and submit a PR.
fabic has joined #rust-embedded
<re_irc> <@pvdb:matrix.org> no, the HAL does not support it. I'll give a PR a go
<re_irc> <@m3angreen:matrix.org> K900: Maybe for example, `go to definition` between FFI symbols (some kind of integration between clangd-ra)? Is it useful feature?
<re_irc> <@k900:0upti.me> That would be cool, but extremely difficult, and also not particularly useful for embedded, because most embedded stuff is pure Rust
<re_irc> <@m3angreen:matrix.org> K900: It's always some kind of legacy C code, at least in my practice
dcz_ has joined #rust-embedded
fabic_ has joined #rust-embedded
inara` has joined #rust-embedded
inara has quit [Ping timeout: 260 seconds]
Rahix_ has quit [Ping timeout: 260 seconds]
rektide has quit [Ping timeout: 260 seconds]
fabic has quit [Ping timeout: 260 seconds]
wose has quit [Ping timeout: 260 seconds]
rektide_ has joined #rust-embedded
Rahix has joined #rust-embedded
wose has joined #rust-embedded
rjframe has joined #rust-embedded
<re_irc> <@firefrommoonlight:matrix.org> pvdb:matrix.org: ```rust
<re_irc> <@firefrommoonlight:matrix.org> unsafe { (*pac::USART1::ptr()).cr3.write(|w| w.hdsel().set_bit());
<re_irc> <@firefrommoonlight:matrix.org> (*I agree the PR is better overall)
fabic_ has quit [Remote host closed the connection]
cr1901_ is now known as cr1901
troth has quit [Ping timeout: 245 seconds]
troth has joined #rust-embedded
troth has quit [Ping timeout: 240 seconds]
<re_irc> <@t4d1:matrix.org> Does by chance anybody ḱnow about companies using Rust in or near Utrecht, Netherlands? (or maybe Amsterdam)
<re_irc> <@jamesmunns:beeper.com> Tweede Golf isn't far from Utrecht
<re_irc> <@t4d1:matrix.org> jamesmunns:beeper.com: Thanks :)
troth has joined #rust-embedded
<re_irc> <@diondokter:matrix.org> t4d1:matrix.org: Yep, we're located in Nijmegen
<re_irc> <@tonygarnockjones:matrix.org> t4d1:matrix.org: I'm based in Maastricht, but I'm just a consultant, not a company per se :-)
<re_irc> <@whitequark:matrix.org> tonygarnockjones: oh hi!
tokomak has quit [Read error: Connection reset by peer]
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
<re_irc> <@mehmet:grusbv.com> t4d1:matrix.org: I know tweedegolf and recently saw one company who does vibration monitoring.
<re_irc> <@mehmet:grusbv.com> And hopefully, when I get a decent project backlog, me in Eindhoven.
<re_irc> <@mehmet:grusbv.com> Oh JitterCompany.
<re_irc> <@mehmet:grusbv.com> Spotted them with their utilitarian company naming scheme. so popular here.
<re_irc> <@mehmet:grusbv.com> On a different note, I realized that
<re_irc> <@mehmet:grusbv.com> #[cortex_m_rt::entry]
<re_irc> <@mehmet:grusbv.com> ```rust
<re_irc> <@mehmet:grusbv.com> Do you also have this?
<re_irc> <@mehmet:grusbv.com> Was going to issue this in rust-analyzer, but realized that that extra error is a macro-error on the decorator, which rust-analyzer just adheres to.
<re_irc> <@l0uisc:matrix.org> Yes, I also have it. The easy fix is to not add the decorator until after writing main.
<re_irc> <@mehmet:grusbv.com> l0uisc:matrix.org: That's what I do, comment it out. I remember to uncomment it with a linker error.
<re_irc> <@l0uisc:matrix.org> Ok. I don't know if there is a better fix; didn't feel the urge to spend more time on it yet.
rjframe has quit [Ping timeout: 265 seconds]
<re_irc> <@dirbaio:matrix.org> setting `"rust-analyzer.experimental.procAttrMacros": false` fixes it
<re_irc> <@firefrommoonlight:matrix.org> Rust seems very popular for web dev. Do y'all think it will move in that direction at the expense of low level. Subtle design decisions, the features added etc
<re_irc> <@dirbaio:matrix.org> hopefully not 🤣
<re_irc> <@firefrommoonlight:matrix.org> I think it's a very nice tool for embedded dev, and I assume most people here would agree by self-selection
<re_irc> <@dirbaio:matrix.org> I do have seen pushes for rust async to become "higher level"
<re_irc> <@dirbaio:matrix.org> for example some features that are only possible if alloc is required
<re_irc> <@dirbaio:matrix.org> but the project knows we embedded people exist :D
<re_irc> <@dirbaio:matrix.org> so it seems embedded-friendliness (or at least low-leve-ness) is taken into account so far
<re_irc> <@dirbaio:matrix.org> but yeah it's somewhat scary
<re_irc> <@firefrommoonlight:matrix.org> The web devs have so many options!
<re_irc> <@firefrommoonlight:matrix.org> We have C, C++, Ada, Rust, and maybe Zig
<re_irc> <@dirbaio:matrix.org> yeah they could stay in nodejs land >_<
<re_irc> <@firefrommoonlight:matrix.org> Rust is probably the nicest of those. Keep it a priority;