<re_irc>
<@dirbaio:matrix.org> and closures and stuff
<re_irc>
<@dirbaio:matrix.org> lots of room for it to go wrong yup
fabic has joined #rust-embedded
Amanieu has quit [Quit: No Ping reply in 180 seconds.]
Amanieu has joined #rust-embedded
njha has quit [Quit: a funny/inspired quit message]
aquijoule_ has joined #rust-embedded
richbridger has quit [Ping timeout: 246 seconds]
fabic has quit [Remote host closed the connection]
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 246 seconds]
fabic has joined #rust-embedded
hifi has quit [Remote host closed the connection]
hifi has joined #rust-embedded
hifi has quit [Ping timeout: 246 seconds]
hifi has joined #rust-embedded
hifi has quit [Ping timeout: 246 seconds]
hifi has joined #rust-embedded
hifi has quit [Read error: Connection reset by peer]
hifi has joined #rust-embedded
hifi has quit [Read error: Connection reset by peer]
hifi has joined #rust-embedded
hifi has quit [Ping timeout: 252 seconds]
hifi has joined #rust-embedded
hifi has quit [Remote host closed the connection]
hifi has joined #rust-embedded
hifi has quit [Remote host closed the connection]
hifi has joined #rust-embedded
<re_irc>
<@sympatron:matrix.org> jamesmunns: BBBuffers currently own the actual buffer. Would it be possible to accept a `&mut [u8]` and use that instead?
<re_irc>
<@sympatron:matrix.org> As far as I understand it, `flip-link` swaps heap and stack to prevent stack overflows and therefore UB. Why isn't this the default then? Seems very reasonable. Otherwise you can easily have UB with safe code in an embedded system. Especially with footguns like GenericArray
<re_irc>
<@sympatron:matrix.org> *by prevent I mean hard fault on stack overflow instead of silently continuing
hifi has quit [Remote host closed the connection]
hifi has joined #rust-embedded
neceve has joined #rust-embedded
<re_irc>
<@sympatron:matrix.org> adamgreig: I know `spi-flash` wasn't meant for embedded. But I didn't want to reinvent the wheel and `spi-flash` is so complete and well documented compared to alternatives, that I thought this would be the best solution to adapt it for embedded use cases. Maybe I'll just fork and see where it goes...
<re_irc>
<@sympatron:matrix.org> Having automatic runtime detection of the flash can be really useful, too. Because of the current market situation, I cannot guarantee that every batch of some device will have the same flash and I don't want to compile and maintain a different firmware for each batch, so runtime detection would actually be...
<re_irc>
... really nice to have.
<re_irc>
<@9names:matrix.org> flip-link doesn't do anything with the heap - most embedded rust projects don't even have one. it just measures static allocations, then uses that size information to adjust the link script to move the stack to the bottom of RAM.
<re_irc>
<@9names:matrix.org> as for why it's not the default, most users of the linker have an MMU which makes detecting stack overflow easier and more generic - you can have multiple stacks and detect an overflow on any of them.
<re_irc>
<@adamgreig:matrix.org> sympatron: Thank you for the nice comments about it :) I am definitely interested in it getting no_std support so let's see where it goes, even if the best thing is a fork or maybe a second api for no_std or whatever.
<re_irc>
<@sympatron:matrix.org> 9names: You are right, I misremembered the part about the heap. And if you have a MMU and set it up correctly that's obviously better, but I would disagree that "most" MCU have a MMU and for those who don't stack overflows are very dangerous. I was just wondering if there was a downside to this. The `flip-link`...
<re_irc>
... docs don't mention any.
<Lumpio->
How does flip-link deal with recursive functions?
<Lumpio->
oh wait
<Lumpio->
Ah it only calculates bss and data, alright
<Lumpio->
I thought it actually figured out the max stack size or something.
crabbedhaloablut has quit [Ping timeout: 244 seconds]
crabbedhaloablut has joined #rust-embedded
hifi has quit [Remote host closed the connection]
hifi has joined #rust-embedded
<re_irc>
<@dngrs:matrix.org> ahoy!
<re_irc>
<@dngrs:matrix.org> am I right in my assumption that neither `stm32f1xx-hal` nor `stm32f4xx-hal` offer functionality to use timers in input capture mode?
<re_irc>
<@ryan-summers:matrix.org> That entire file is basically us extending the functionality of the HAL timer by wrapping up unsafe register instantiation + manipulation
<re_irc>
<@dngrs:matrix.org> thx! So I'm thinking, if I were to write a PR, how to structure it ... the f4xx one has a `Timeout` event, maybe extend it with `InputCapture`?
<re_irc>
<@firefrommoonlight:matrix.org> theunknown is working on this now in the stm32-rs channel
<re_irc>
<@dngrs:matrix.org> forgot that one exists. Thx!
<re_irc>
<@lachlansneff:matrix.org> I'm thinking of getting rid of the timer/`CountDown` traits in the `embedded-hal::futures` module and switching to some sort of async delay trait
<re_irc>
<@lachlansneff:matrix.org> Since it's async, it could be used to implement io timeouts and things like that even though it's blocking sort of
<re_irc>
<@lachlansneff:matrix.org> And I'm wondering if we should stick with the `DelayMs`, `DelayUs` style or have a single trait that takes a duration.
<re_irc>
<@lachlansneff:matrix.org> The `CountDown` trait has a `Time` associated type, but maybe it'd make sense to actually have a Duration type?
<re_irc>
<@dirbaio:matrix.org> Duration type or Duration trait?
<re_irc>
<@lachlansneff:matrix.org> Well, I was thinking a `Duration` _type_, but a trait would be okay too I guess.
<re_irc>
<@lachlansneff:matrix.org> I'm recalling the conversation we had a few days ago about all the traits in `core+`
<re_irc>
<@dirbaio:matrix.org> Problem with single type is how is it represented
<re_irc>
<@dirbaio:matrix.org> u32 might overflow too fast for some
<re_irc>
<@dirbaio:matrix.org> u64 might be too big for others
<re_irc>
<@dirbaio:matrix.org> 🤣
<re_irc>
<@dirbaio:matrix.org> but a trait is overengineering
<re_irc>
<@dirbaio:matrix.org> there's also embedded-time, but imo it's too complex too :D
<re_irc>
<@lachlansneff:matrix.org> Even if it were a trait, the hal implementors would be deciding the size of it, not the user, so I'm not sure it really matters
<re_irc>
<@lachlansneff:matrix.org> Or, I guess the `delay` method could be generic on the duration impl
<re_irc>
<@lachlansneff:matrix.org> And the duration trait would have method that return large integers, and if an impl just wanted to store small ones, it could upcast
<re_irc>
<@lachlansneff:matrix.org> Thoughts?
<re_irc>
<@jamesmunns:matrix.org> sympatron: There are talks about this! The answer is: It makes the code harder, and I want to fix this, but it's not a priority for me.
<re_irc>
<@ryan-summers:matrix.org> I honestly think embedded-time is a nice solution, although it definitely is complex enough that I've been hesitant to add it to my crates
<re_irc>
<@ryan-summers:matrix.org> I think it would be easier if there were more default implementations for embedded-time
<re_irc>
<@eldruin:matrix.org> I would say durations get complicated _fast_. See embedded-time
<re_irc>
<@jamesmunns:matrix.org> ryan-summers: As always, if you want a "like instant, but a little worse, but way simpler as long as you hold it right", https://docs.rs/groundhog is exactly for that.
<re_irc>
<@ryan-summers:matrix.org> That's still an overhead form someone to impl groundhog::RollingTimer though
<re_irc>
<@ryan-summers:matrix.org> I'm talking about making a crate that needs some timekeeping impl
<re_irc>
<@jamesmunns:matrix.org> with a u64, you're not going to use enough of the u64 to get close enough to rollover.
<re_irc>
<@jamesmunns:matrix.org> but if you have 70m in a 71m range, and multiply it by 1M, you're gunna have a bad time.
<re_irc>
<@jamesmunns:matrix.org> so like, I'd probably also accept a "close enough" u64 feature that didn't actually do extension promotion, as long as you promise never count more than u64::MAX / 1_000_000 ticks lol
<re_irc>
<@jamesmunns:matrix.org> (groundhog is very much my "ship useful, imperfect code for situations where it doesn't matter" policy on display)
<re_irc>
<@jamesmunns:matrix.org> I'd never do it this way for safety critical, but for pretty little LED lights? sure, why not.
<re_irc>
<@jamesmunns:matrix.org> (and in hot timing loops, I don't actually want u64s)
<re_irc>
<@jamesmunns:matrix.org> (but that's STILL probably premature optimization)
<re_irc>
<@jamesmunns:matrix.org> anyway, sorry for derailing the conversation.
<re_irc>
<@dirbaio:matrix.org> right, for u32 you need it.. for u64 you don't
<re_irc>
<@dirbaio:matrix.org> you could make u64 "promote" to u64 :D
<re_irc>
<@jamesmunns:matrix.org> sympatron: Because you can't do it with a single linker script (llvm-ld can't do the offset calcs necessary), and it also gets odd with multiple RAM banks or split stacks like you might have with an RTOS.
<re_irc>
<@jamesmunns:matrix.org> dirbaio: Yeah, that's what I meant by a `u64-is-fine-i-promise` feature flag that swapped the u128 promotion for just another u64.
<re_irc>
<@dirbaio:matrix.org> aah :D
<re_irc>
<@jamesmunns:matrix.org> I just like the default to be correct, and you opt-in to the "good enough" choice.
<re_irc>
<@jamesmunns:matrix.org> because seriously, u64 microseconds, even picoseconds, is still "heat death of the universe" stuff.
<re_irc>
<@jamesmunns:matrix.org> No! I am wrong!
<re_irc>
<@jamesmunns:matrix.org> 2 ^ 64 picoseconds is 31 weeks.
<re_irc>
<@dirbaio:matrix.org> picoseconds? lol
<re_irc>
<@jamesmunns:matrix.org> but 2 ^ 64 microseconds is 585 years.
<re_irc>
<@dirbaio:matrix.org> to measure nanoseconds you need 1ghz
<re_irc>
<@jamesmunns:matrix.org> Sorry, 585000 years
<re_irc>
<@jamesmunns:matrix.org> so, not heat death
<re_irc>
<@jamesmunns:matrix.org> but like... your SW isn't gunna be running.
<re_irc>
<@dirbaio:matrix.org> maybe not universe death, but probably humankind extinction
<re_irc>
<@lachlansneff:matrix.org> Well, so what's the plan for the `Delay` trait?
<re_irc>
<@dirbaio:matrix.org> no idea
<re_irc>
<@dirbaio:matrix.org> delay_ms/delay_us is not that bad
<re_irc>
<@lachlansneff:matrix.org> That's true
<re_irc>
<@lachlansneff:matrix.org> I'll go with that for now I guess
<re_irc>
<@dirbaio:matrix.org> plus it'd be a shame if blocking adn async were inconsistent
<re_irc>
<@dirbaio:matrix.org> if we can think of something better, we should change both
<re_irc>
<@jamesmunns:matrix.org> I sort of just want to make an "all embedded-dma hal" crate.
<re_irc>
<@jamesmunns:matrix.org> at least to see what it would look like.
<re_irc>
<@jamesmunns:matrix.org> maybe even have blanket impls (or conversions?) for the blocking embedded-hal methods.
<re_irc>
<@jamesmunns:matrix.org> not sure how you would get "dma && async"
<re_irc>
<@jamesmunns:matrix.org> though I feel like that's just "Poll on" the dma? but then you also don't have wakers.
<re_irc>
<@jamesmunns:matrix.org> (don't let me start a flame war, this is just idle thoughts, people smarter than me have probably already thought about this)
<re_irc>
<@lachlansneff:matrix.org> Can't you get an interrupt when the DMA is finished?
<re_irc>
<@dirbaio:matrix.org> HAL has to own the interrupts (SPI/UART/I2C/whatever interrupt, and DMA interrupt if there's a separate one)
<re_irc>
<@jamesmunns:matrix.org> yeah... this is one of those areas where I don't think interrupts match 1:1 to the waker model, but they are deceptively close.
<re_irc>
<@dirbaio:matrix.org> HAL handles the interrupts, if transfer is done HAL wakes the wkaer
<re_irc>
<@jamesmunns:matrix.org> I think embassy takes one of the reasonable paths here.
<re_irc>
<@dirbaio:matrix.org> what *doesn't* work is a "await interrupt" abstraction
<re_irc>
<@lachlansneff:matrix.org> dirbaio: Why wouldn't that work?
<re_irc>
<@dirbaio:matrix.org> 1. usually you have to do "things" in the interrupt, like clearing event flags. You can't simply consider "interrupt happened means transfer's done, ok bye"
<re_irc>
<@dirbaio:matrix.org> 2. often you have multiple "things" in the same interrupt
<re_irc>
<@dirbaio:matrix.org> example 1: task A is reading from uart and task B is writing. both "rx ready" and "tx ready" events go to the same interrupt.
<re_irc>
<@dirbaio:matrix.org> example 2: multiple DMA channels all fire the same interrupt when done
<re_irc>
<@lachlansneff:matrix.org> Ah, I thought you were saying that that wasn't possible. But yet, agreed, it wouldn't be useful
<re_irc>
<@dirbaio:matrix.org> i don't think other reasonable paths exist to be honest
<re_irc>
<@dirbaio:matrix.org> awaiting interrupts doens't work
<re_irc>
<@dirbaio:matrix.org> polling futures from interrupts doesn't work either
<re_irc>
<@dirbaio:matrix.org> ignoring wakers altogether and busylooping sucks, it's not low power
<re_irc>
<@lachlansneff:matrix.org> Hals owning the interrupts definitely would be more batteries included than things are right now I think.
<re_irc>
<@jamesmunns:matrix.org> So far for most of my non-blocking stuff, I've had a HAL impl provide an "interrupt" method, that expects to be called in any interrupt (so in an `#[interrupt]` or `#[task]`, depending on what you're doing)
<re_irc>
<@dirbaio:matrix.org> that makes sense when no infra for owning interrupts exists...
<re_irc>
<@dirbaio:matrix.org> and leaves lots of room to the user to fuck it up
<re_irc>
<@dirbaio:matrix.org> user can not wire it up, wire it up to the wrong one..
<re_irc>
<@dirbaio:matrix.org> with owned interrupts it's guaranteed at compile time that it's wired up properly
<re_irc>
<@lachlansneff:matrix.org> What would that look like?
<re_irc>
<@xgroleau:matrix.org> Is embassy mature enough for production? I've played with RTIC and it seems pretty complete, though embassy seems very recent. I'm not really familiar with embassy and don't really know how it compares with RTIC.
<re_irc>
<@dirbaio:matrix.org> embassy-nrf yep, I'm shipping products with it myself :)
<re_irc>
<@dirbaio:matrix.org> embasys-stm32 is still mostly WiP
<re_irc>
<@xgroleau:matrix.org> Nice, and how is the bluetooth support for nrf chip on rust? I've seen rubble but it's not ready
<re_irc>
<@dirbaio:matrix.org> again, i'm shipping products with it
<re_irc>
<@lachlansneff:matrix.org> Very neat
<re_irc>
<@dirbaio:matrix.org> it's missing some softdevice features (most notably pairing/bonding) but the features that are there are solid
<re_irc>
<@dirbaio:matrix.org> and since it uses the softdevice it's all pre-=certified
<re_irc>
<@xgroleau:matrix.org> Very cool, it's been some time since I've used nordic devices, does the softdevice still trigger a hardfault when using breakpoints?
<re_irc>
<@dirbaio:matrix.org> yes :(
<re_irc>
<@xgroleau:matrix.org> Ohhh :/ it was pretty painful to debug some things even with a logger :(
<re_irc>
<@jamesmunns:matrix.org> though, still some things that are not perfect, for sure :D
<re_irc>
<@dirbaio:matrix.org> breakpoint debugging is doomed with bluetooth stuff though
<re_irc>
<@dirbaio:matrix.org> unless you run bluetooth on a separate core
<re_irc>
<@dirbaio:matrix.org> because if the core is stopped it won't reply to radio packets and the peer device will think we're gone and disconnect
<re_irc>
<@jamesmunns:matrix.org> (same with USB, tbh)
<re_irc>
<@xgroleau:matrix.org> Yea just started rust, defmt is a godsend. I got some stange characters some times, but I think it's my terminal emulator.
<re_irc>
<@dirbaio:matrix.org> the softdevice could handle it more gracefully though...
<re_irc>
<@dirbaio:matrix.org> letting the connection fail, instead of crashing
<re_irc>
<@jamesmunns:matrix.org> that's why we show logging instead of gdb in our advanced training where we write a minimal USB stack.
<re_irc>
<@xgroleau:matrix.org> Yea that what I understood at the time. I think the nrf53 got a dual core though
<re_irc>
<@xgroleau:matrix.org> And how do you feel with RTIC vs Embassy? They seem to try to tackle a similar problem, but with different approach.
<re_irc>
<@dirbaio:matrix.org> they're completely different
<re_irc>
<@dirbaio:matrix.org> rtic is "make interrupt-driven programming super safe"
<re_irc>
<@dirbaio:matrix.org> embassy is "I don't even want to touch interrupts"
<re_irc>
<@dirbaio:matrix.org> rtic is great if you have hard realtime stuff, embassy is great for non-realtime stuff like networking
fabic has quit [Ping timeout: 246 seconds]
<re_irc>
<@dirbaio:matrix.org> in some applications it might even make sense to use both
<re_irc>
<@ryan-summers:matrix.org> Yeah, I'm actually interested in looking into using async for the RTIC `idle` task
<re_irc>
<@xgroleau:matrix.org> I see, pretty interesting stuff, I'll go check embassy too I guess
<re_irc>
<@ryan-summers:matrix.org> Since we have hard real-time requirements in our app (which RTIC resolves), but then lots of timing-insensitive networking when the real-time stuff isn't going
<re_irc>
<@ryan-summers:matrix.org> I don't really see any reason why async and RTIC should be mutually exclusive, but I don't have much async experience
<re_irc>
<@lachlansneff:matrix.org> I think RTIC had some experiments with async, but I'm not sure where that is right now.
<re_irc>
<@jamesmunns:matrix.org> I've used async (like, the bad version, with my `cassette` crate) using the idle loop as an executor.
<re_irc>
<@jamesmunns:matrix.org> it actually works really well.
<re_irc>
<@jamesmunns:matrix.org> it's waaaaaay dumber than embassy
<re_irc>
<@jamesmunns:matrix.org> but I think it could be a reasonable model.
<re_irc>
<@lachlansneff:matrix.org> That's essentially what it would be, just with `wfe` when no tasks are pending
<re_irc>
<@jamesmunns:matrix.org> esp if rtic had a "native executor" that was a little smarter, or could handle task<->waker events/messages/notifications.
<re_irc>
<@lachlansneff:matrix.org> Would there be any interop issues between owned interrupts and RTIC?
<re_irc>
<@dirbaio:matrix.org> you can still use custom `#[interrupt]` with RTIC. It only touches the interrupts you tell it to
<re_irc>
<@dirbaio:matrix.org> so you're free to do whatever you want with interrupts not used by rtic
<re_irc>
<@lachlansneff:matrix.org> True.
<re_irc>
<@dirbaio:matrix.org> so yes, it works
<re_irc>
<@dirbaio:matrix.org> embassy's works
<re_irc>
<@dirbaio:matrix.org> you even get a compile-time error if you try to use the same interrupt with both :D
<re_irc>
<@lachlansneff:matrix.org> I wonder if it could be integrated into the way rtic handles the extra interrupts
<re_irc>
<@lachlansneff:matrix.org> Since you can hand it an interrupt to use for timers
<re_irc>
<@ryan-summers:matrix.org> Or you could just bind it manually - it's not too much work honestly
<re_irc>
<@ryan-summers:matrix.org> RTIC supports hardware interrupt sources or software sources - just bind the ISR to your peripheral ISR and you're good to go
<re_irc>
<@ryan-summers:matrix.org> Then in the task, just run some schedule updater on the executor
<re_irc>
<@lachlansneff:matrix.org> What if we had this trait in embedded-hal:
<re_irc>
<@lachlansneff:matrix.org> /// A duration of time, no smaller than 1 microsecond.
<re_irc>
<@lachlansneff:matrix.org> `DelayMs` and `DelayUs` could be replaced with a single delay trait.
<re_irc>
<@lachlansneff:matrix.org> `embedded-time` has its own `Duration` trait, but it's too complex to put in `embedded-hal` imo. And things like `CountDown` would be a lot simpler to use with this trait.
<re_irc>
<@adamgreig:matrix.org> shame we can't all just use core's Duration but I guess having the fractional part always be nanos means everyone has to do some maths to get millis or micros
<re_irc>
<@adamgreig:matrix.org> but jeez, would simplify having a different duration trait everywhere
<re_irc>
<@lachlansneff:matrix.org> Also means that your platform needs to support `u128`
<re_irc>
<@lachlansneff:matrix.org> I mean, I'd be all for adding `Duration` to core, if that's what you're suggesting
<re_irc>
<@lachlansneff:matrix.org> Wait what?!
<re_irc>
<@adamgreig:matrix.org> it's in core
<re_irc>
<@lachlansneff:matrix.org> `core` has `Duration`??
<re_irc>
<@adamgreig:matrix.org> always has been
<re_irc>
<@lachlansneff:matrix.org> Amazing
<re_irc>
<@adamgreig:matrix.org> it's a u32 seconds and u64 nanos
<re_irc>
<@lachlansneff:matrix.org> Well, lets just use that then
<re_irc>
<@dirbaio:matrix.org> problem is that forces maths and u64 on everyone
<re_irc>
<@adamgreig:matrix.org> I mean, I think I'm onboard, but a lot of people don't like it because of the u64
<re_irc>
<@dirbaio:matrix.org> u32 secs + u64 nanos is even worse
<re_irc>
<@adamgreig:matrix.org> sorry, I had it wrong
<re_irc>
<@lachlansneff:matrix.org> It has methods to return the time in different units thogh
<re_irc>
<@adamgreig:matrix.org> obviously u64 nanos would be senseless
<re_irc>
<@adamgreig:matrix.org> yea, but to return the time in different units, you potentially have to do maths on a u64
<re_irc>
<@dirbaio:matrix.org> and splitting secs/nanos means you have to mul/div by 1e9 to do maths which is not free
<re_irc>
<@adamgreig:matrix.org> I mean, mostly I don't think this is a huge problem, but on lower-resource microcontrollers doing things like division can involve a big bundle of aeabi software impls
<re_irc>
<@adamgreig:matrix.org> so there's definitely appetite for a non-u64 version for embedded use
<re_irc>
<@adamgreig:matrix.org> (specifically cortex-m0 would suffer this problem due to being armv6 and so not having good support for longs)
<re_irc>
<@adamgreig:matrix.org> how bad it is depends a lot on use case though, it would be catastrophic on 8-bit avrs, probably
<re_irc>
<@adamgreig:matrix.org> otoh maybe using a u32 for seconds would be asking for trouble :P
<re_irc>
<@adamgreig:matrix.org> I think the other half of it is that most use cases in embedded want millis or micros, so dealing with nanos means a conversion every time, but that's a u32 conversion which should not be that expensive
<re_irc>
<@lachlansneff:matrix.org> Yeah, that would just be a bitshift and add I think
<re_irc>
<@lachlansneff:matrix.org> Well no, not quite a bitshift
<re_irc>
<@lachlansneff:matrix.org> But pretty cheap
<re_irc>
<@adamgreig:matrix.org> it would be ok if it was a bitshift
<re_irc>
<@adamgreig:matrix.org> sadly not though
<re_irc>
<@pinkhatbeard:matrix.org> pinkhatbeard: For those following along. I was finally able to get the modem working from Rust on the `nrf9160`. Sometime after I get past this demo on Friday I will make a PR somewhere showing the correct order of operations so hopefully someone else has less banging of their head against the wall.
<re_irc>
<@pinkhatbeard:matrix.org> ...now that I've got a working modem....hopefully I still have time to do the actual work of the project!
<re_irc>
<@adamgreig:matrix.org> nanos -> micros/millis requires a u32 division which adds at least a few hundred bytes of software routines to a cortex-m0 binary
<re_irc>
<@adamgreig:matrix.org> (actually maybe more like 100 bytes... idk)
<re_irc>
<@lachlansneff:matrix.org> Maybe time should be represented in terms kibinanoseconds to all these things are bitshifts
<re_irc>
<@adamgreig:matrix.org> probably in some cases the compiler can optimise that away but probably not in others
<re_irc>
<@adamgreig:matrix.org> hah, binary SI time, dope
<re_irc>
<@lachlansneff:matrix.org> Lachlan Sneff: this is a joke btw
<re_irc>
<@lachlansneff:matrix.org> But yeah, binary SI time would be epic
<re_irc>
<@adamgreig:matrix.org> yea just divide by 1024 instead of 1000, "close enough" and very quick :P
<re_irc>
<@lachlansneff:matrix.org> I'm honestly kind of surprised that never was a thing. I would've thought programmers a couple decades would've done that for efficiency
<re_irc>
<@adamgreig:matrix.org> swatch really missed a trick
<re_irc>
<@adamgreig:matrix.org> "Instead of hours and minutes, the mean solar day is divided into 1000 parts called ".beats". Each .beat is equal to one decimal minute in the French Revolutionary decimal time system and lasts 1 minute and 26.4 seconds (86.4 seconds) in standard time. Times are notated as a 3-digit number out of 1000 after...
<re_irc>
... midnight." absolutely wild
<re_irc>
<@adamgreig:matrix.org> -> "french revolutionary decimal time system"
<re_irc>
<@lachlansneff:matrix.org> Unfortunately I think we're stuck with our weird time system
<re_irc>
<@lachlansneff:matrix.org> I wonder if there'd be any efficiency gains if `core::time::Duration` represented time as binary, and then converted to regular time when the methods were called.
<re_irc>
<@lachlansneff:matrix.org> And additional `as_kibi_*` methods were added
<re_irc>
<@lachlansneff:matrix.org> Which people could call if they needed really fast conversation
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 246 seconds]
<re_irc>
<@adamgreig:matrix.org> hi @room, meeting time again! We'll start in 5 minutes, agenda's up here: https://hackmd.io/5QOG78xsSvWiAVAilVTexA, please add anything you'd like to announce or discuss
<re_irc>
<@lachlansneff:matrix.org> I was going to say we should talk about time/duration stuff for embedded-hal, but I'm not sure what else could be said
<re_irc>
<@adamgreig:matrix.org> sorry, a cat jumped in my window.. ok, let's start!
<re_irc>
<@adamgreig:matrix.org> quick announcement for cortex-m, we released 0.7.3 which includes a simpler-to-use Delay impl from firefrommoonlight and also fixes building natively on non-x86 hosts
<re_irc>
<@adamgreig:matrix.org> there's a few more PRs that might be nice to get merged so perhaps we'll get another minor release out soonish
<re_irc>
<@adamgreig:matrix.org> (and I'm working on some sort of DSP intrinsics/functions for it too, hit me up if you're interested in that...)
<re_irc>
<@adamgreig:matrix.org> does anyone else have any announcements?
<re_irc>
<@jamesmunns:matrix.org> Super off topic, but I'm interested in feedback in how people could see a "Ferrous Supported Hardware" board: https://twitter.com/bitshiftmask/status/1412150675904118786 (happy to save this chat until the far end of the meeting)
<re_irc>
<@therealprof:matrix.org> adamgreig: LLVM patch for unsigned saturated add is in BTW. 😉
<re_irc>
<@therealprof:matrix.org> Still in review.
<re_irc>
<@thejpster:matrix.org> Could I get an update on the roadmap to 1.0 for our key crates? Or a pointer to a document that discusses it?
<re_irc>
<@adamgreig:matrix.org> dirbaio: ...would have been a better name :P the DSP thing is what led me down that road but I was expecting to do this in cortex-m itself using the existing asm infra
<re_irc>
<@jamesmunns:matrix.org> would it be possible to inline-outline-inline dsp instructions as well?
<re_irc>
<@adamgreig:matrix.org> yep
<re_irc>
<@adamgreig:matrix.org> well, it would still need the linker plugin lto to get it to inline properly
<re_irc>
<@adamgreig:matrix.org> but my experiments so far are fairly compelling
<re_irc>
<@adamgreig:matrix.org> lotta rust for literally one instruction
<re_irc>
<@jamesmunns:matrix.org> yooooooo
<re_irc>
<@jamesmunns:matrix.org> that's the happy path :D
<re_irc>
<@adamgreig:matrix.org> right??
<re_irc>
<@adamgreig:matrix.org> as far as I can tell, cortex-m can provide that unsafe{asm!()} bit in its usual way, and it should inline the same
<re_irc>
<@adamgreig:matrix.org> and I've already written all those wrappers in cortex-m too
<re_irc>
<@adamgreig:matrix.org> all 119 of them...
<re_irc>
<@therealprof:matrix.org> Yeah, I wouldn't hold my breath for LLVM automatic (and useful) code generation for everything... long way to go.
<re_irc>
<@adamgreig:matrix.org> for some use cases I think it's nice to be able to use intrinsics and know you'll get those instructions out the other end, but ultimately having llvm do it is really good
<re_irc>
<@therealprof:matrix.org> I might do a bit more depending on how smoothly that first one goes.
<re_irc>
<@therealprof:matrix.org> Reminds me of the good old times when I did pretty much the same thing for Altivec in gcc. 😀
<re_irc>
<@adamgreig:matrix.org> sounds good!
<re_irc>
<@adamgreig:matrix.org> so, I didn't get to adding anything else to the agenda, I was just looking over the embedded-hal PRs and I don't think any are _new_ beyond updating the readme, but are there any that want some further discussion?
<re_irc>
<@adamgreig:matrix.org> and/or Lachlan Sneff if you did want to chat about Durations, now might be a good time, if anyone else here has thoughts on the matter...
<re_irc>
<@lachlansneff:matrix.org> Yeah, I'm interested to hear if anyone has any additional thoughts.
<re_irc>
<@lachlansneff:matrix.org> e.g. a `Duration` trait, whether `core::time::Duration` could be changed (in a backwards-compatible way of course) to make it more palatable for embedded.
<re_irc>
<@lachlansneff:matrix.org> Stuff like that
<re_irc>
<@dirbaio:matrix.org> I don't think `core::time::Duration` is changeable
<re_irc>
<@adamgreig:matrix.org> I don't know if we have any document that's up-to-date about it really
<re_irc>
<@adamgreig:matrix.org> the update is that essentially we lost a bunch of momentum on key crates after getting r0 to 1.0 and then discovering we should deprecate it all together, and no one has pushed for the various interesting plans around splitting up cortex-m and/or implementing the porcelain/plumbing ideas for cortex-m-rt
<re_irc>
<@adamgreig:matrix.org> right now I'd say the most momentum is on embedded-hal 1.0
<re_irc>
<@adamgreig:matrix.org> `nb` also got to 1.0 and probably we'll also want to deprecate it once futures become suitably stable...
<re_irc>
<@yatekii:matrix.org> adamgreig: yesyes DSP is great :)
<re_irc>
<@lachlansneff:matrix.org> adamgreig: And this should wait for GATs to be stabilized imo
<re_irc>
<@adamgreig:matrix.org> well, we can always add futures in to 1.1 or whatever, so does it need to block 1.0?
<re_irc>
<@adamgreig:matrix.org> (or rather, stabilise them from out of an experimental feature flag)
<re_irc>
<@adamgreig:matrix.org> in any event that's where a lot of momentum is going
<re_irc>
<@lachlansneff:matrix.org> I guess not, but it does feel weird to go to 1.0 with the plan to depreciate the `nb` module later
<re_irc>
<@lachlansneff:matrix.org> Like, 1.0 should be for when you've sorted all that out
<re_irc>
<@lachlansneff:matrix.org> in my opinion
<re_irc>
<@therealprof:matrix.org> Let's just say 1.0 is long overdue anyway...
<re_irc>
<@adamgreig:matrix.org> perhaps! but I suspect it will be some time before we want to remove it all together, and not much harm in having it around in the nonblocking module alongside blocking and futures?
<re_irc>
<@lachlansneff:matrix.org> adamgreig: I suppose no harm, true!
<re_irc>
<@adamgreig:matrix.org> if there are people interested in pushing for cortex-m and cortex-m-rt to get to 1.0 as well, that could be cool, there were a lot of interesting ideas in the last year or two but I don't think there's been much experimentation
<re_irc>
<@adamgreig:matrix.org> dirbaio, have you found they mostly work for embassy style stuff too, or do you end up reimplementing a lot of that?
<re_irc>
<@jamesmunns:matrix.org> IMO if we had shipped 1.0 a year ago, it would have been a reasonable amount of time elapsed to start talking about 2.0 :)
<re_irc>
<@lachlansneff:matrix.org> Ship 1.0 now then, and then talk about 2.0 once all the futures experimentation has died down?
<re_irc>
<@dirbaio:matrix.org> the async traits? they're very similar to the embassy ones, embassy will switch over when they're out
<re_irc>
<@adamgreig:matrix.org> dirbaio: sorry, I mean the cortex-m and cortex-m-rt crates
<re_irc>
<@thejpster:matrix.org> My view is, you can (and people do) ship production code with these crates. So we should call it 1.0.
<re_irc>
<@adamgreig:matrix.org> yep, it's a fair point! we've certainly been _extremely_ reluctant to finally say "ok, we like this design enough" and "those ideas on the roadmap are not happening soon enough to be worth it"
<re_irc>
<@adamgreig:matrix.org> given how stable the cortex-m and cortex-m-rt APIs have been for the last 2 years or so I think in retrospect it would have been fair to call it 1.0
<re_irc>
<@adamgreig:matrix.org> but nevertheless people do still have some big and very disruptive ideas about ways to break them apart and put them back together better.
<re_irc>
<@adamgreig:matrix.org> not that that necessarily precludes releasing 1.0 first, of course
<re_irc>
<@thejpster:matrix.org> Exactly. That sounds like a good V2
<re_irc>
<@adamgreig:matrix.org> I think at the least we'd probably want to try and resolve some open PRs and issues though, since a few are fairly boring breaking changes that would suck to be stuck with til 2.0
<re_irc>
<@adamgreig:matrix.org> and it turns out in the last 18 months or so there's not been much energy to spend on that
<re_irc>
<@jamesmunns:matrix.org> If it's breaking changes, we'll have to break anything anyway
<re_irc>
<@jamesmunns:matrix.org> "if it hurts, do it more often"
<re_irc>
<@thejpster:matrix.org> A 1.0 also gives you a release branch you can make hot fixes on
<re_irc>
<@thejpster:matrix.org> Whilst main gets the wild stuff
<re_irc>
<@adamgreig:matrix.org> we have that for 0.5, 0.6, 0.7 too :P
<re_irc>
<@thejpster:matrix.org> So you shipped a 1.0 but didn't call it that
<re_irc>
<@jamesmunns:matrix.org> :D
<re_irc>
<@jamesmunns:matrix.org> let's just ship 2.0 and call it done
<re_irc>
<@adamgreig:matrix.org> I mean, we could just multiply all the version numbers by ten and I guess it wouldn't fundamentally change anything
<re_irc>
<@jamesmunns:matrix.org> hop right over the awkward "1.x" forever argument.
<re_irc>
<@thejpster:matrix.org> But yes, our models and workflows all still work
<re_irc>
<@adamgreig:matrix.org> I could imagine a concerted effort to push e.g. cortex-m-rt towards 1.0 by trying to nail a few last issues, make a few last hard decisions, then press go
<re_irc>
<@adamgreig:matrix.org> that's probably easiest to start with, since it has zero dependencies except its own macros, which in turn depend on >1.0 versions of quote, syn, and proc-macro2
<re_irc>
<@adamgreig:matrix.org> cortex-m is a little trickier given the current dep on bare-metal 0.2 which we can't easily bump to 1.0 without removing cortex_m::interrupt::Mutex which would be quite an exciting breaking change for everyone, and volatile-register 0.2, bitfield 0.13, embedded-hal 0.2... shrug
<re_irc>
<@adamgreig:matrix.org> I don't personally mind too much the idea of releasing a 1.0 crate with <1.0 dependencies, but I understand in principle it's recommended not to?
<re_irc>
<@eldruin:matrix.org> no <1.0 dependencies for stuff in the public api is the requirement IIRC
<re_irc>
<@thejpster:matrix.org> porcelain / plumbing. To me, version numbers speak to the external interface
<re_irc>
<@dirbaio:matrix.org> adamgreig: Yeah, works fine! the only thing it's reimplementing is `#[interrupt]` for registering owned interrupts, because it breaks when reexported
<re_irc>
<@adamgreig:matrix.org> ah, ok, so we could feature-gate the e-h impls until e-h 1.0, not sure about Mutex but maybe vendor it, I don't think we expose volatile-register or bitfield (and anyway we should replace volatile-register due to the dereferenceablegate thing)
<re_irc>
<@adamgreig:matrix.org> so probably not a million miles away from being able to 1.0 cortex-m either, except generally it having a lot more open issues and PRs that should probably get looked at
<re_irc>
<@adamgreig:matrix.org> thejpster: sure, but that external interface is a big part of what we'd be ripping up and replacing
<re_irc>
<@dirbaio:matrix.org> for CMRT 1.0 i'd remove the "resources" thing though
<re_irc>
<@adamgreig:matrix.org> i want a shiny new toilet to sit on, not just a larger sewage pipe or whatever the metaphor is
<re_irc>
<@therealprof:matrix.org> LOL
<re_irc>
<@adamgreig:matrix.org> dirbaio: yea.. have you seen the new RTIC resources?
<re_irc>
<@adamgreig:matrix.org> but perhaps it just shouldn't go in cortex-m-rt as it stands today
<re_irc>
<@dirbaio:matrix.org> if you want resources you use RTIC or some other abstraction built "on top of" cmrt
<re_irc>
<@dirbaio:matrix.org> no need to have it in cmrt itself
<re_irc>
<@adamgreig:matrix.org> maybe, but since cmrt does provide the basic interrupt registration, it doesn't seem totally wild for the runtime to also provide interrupt-local resources like that
<re_irc>
<@adamgreig:matrix.org> I think it's a balance of whether it's worth the extra complexity in the macros and potential for confusion
<re_irc>
<@adamgreig:matrix.org> (and perhaps it's not worth the balance, but doesn't mean there's no use in the idea being in c-m-rt, imo)
<re_irc>
<@thalesfragoso:matrix.org> how is it today for interrupts ? do they also gain a resource struct or the old static mut transformation ?
<re_irc>
<@adamgreig:matrix.org> I think that's compelling, and after all you can always put your static resource inside your ISR without c-m-rt's help, and you just need to use unsafe to access it or use something with interior mutability (which could be provided by another crate)
<re_irc>
<@adamgreig:matrix.org> the static mut transform
<re_irc>
<@dirbaio:matrix.org> also the cmrt resources don't cover the most common usecase which is moving stuff from main to interrupt
<re_irc>
<@thalesfragoso:matrix.org> I think the transform is really unexpected
<re_irc>
<@dirbaio:matrix.org> imo there's 2 things
<re_irc>
<@dirbaio:matrix.org> 1. the static mut transform is super unintuitive indeed. can be fixed by switching to another syntax, like that PR does, which looks much nicer
<re_irc>
<@dirbaio:matrix.org> 2. imo cmrt is the wrong place for a resource abstraction in the first place, no matter how nice the syntax is...
<cr1901>
What's the static mut transform (sorry, not up to date w/ cmrt land lately)?
<re_irc>
<@adamgreig:matrix.org> this is where you type ```#[interrupt] fn SysTick() { static mut CTR: u32 = 0u32; *ctr++; }```
<re_irc>
<@adamgreig:matrix.org> and you wonder " 🤔 why don't i need unsafe"
<re_irc>
<@adamgreig:matrix.org> and it's because c-m-rt's interrupt macro has rewritten your handler through a trampline to instead receive CTR: &mut u32, a reference to the static mut, which you can now safely write to
<re_irc>
<@dirbaio:matrix.org> and you try to pass that to something requiring `&'static mut` and it doesn't work, where it'd work normally
<re_irc>
<@adamgreig:matrix.org> it's not a &'static mut is why :P
<re_irc>
<@thalesfragoso:matrix.org> "And also, why if I put a couple lines down I now need unsafe"
<cr1901>
> "And also, why if I put a couple lines down I now need unsafe"
<cr1901>
Which couple of lines?
<re_irc>
<@adamgreig:matrix.org> the macro only transforms static muts at the start of a function
<re_irc>
<@thalesfragoso:matrix.org> it has to be the first thing in the interrupt for it to work
<re_irc>
<@adamgreig:matrix.org> so if you have anything else before one, it's left alone
<cr1901>
And I remember this feature, I don't think I ever used it
<re_irc>
<@adamgreig:matrix.org> indeed, as dirbaio points out it's not actually that useful
<re_irc>
<@adamgreig:matrix.org> since you can't then move that resource out of the interrupt handler
<re_irc>
<@thalesfragoso:matrix.org> It's somewhat useful to keep some state in the interrupt, like led on or off or something
<re_irc>
<@thalesfragoso:matrix.org> but it isn't that nice to be worth it
<re_irc>
<@adamgreig:matrix.org> yea, that's exactly what it's useful for, but...
<cr1901>
I use Cells for everything mostly and just eat the cost
<cr1901>
On msp430 the cost is reduced because you get a free CriticalSection token at the beginning of your interrupt
<re_irc>
<@therealprof:matrix.org> Of course you can move things in and out of those static muts. I'm doing that all the time.
<re_irc>
<@adamgreig:matrix.org> therealprof: the interrupt handler gets given a &mut with a lifetime bound to the interrupt, so iirc you can't move that reference out or share it in any way
<re_irc>
<@adamgreig:matrix.org> the ones declared inside the interrupt handlers, which the macro transforms?
<re_irc>
<@adamgreig:matrix.org> i mean, of course you can mutate them, so you can store things in them for later or copy/move values out of them
<re_irc>
<@adamgreig:matrix.org> but you can't give anything else a reference to them
<cr1901>
You can't access them from another thread, which is usually want you want
<re_irc>
<@thalesfragoso:matrix.org> cr1901: but Cell isn't Sync
<re_irc>
<@therealprof:matrix.org> Nope, but you can make it an `Option` and then permanently move something out of a `Mutex` protected Cell into the interrupt handler.
<cr1901>
thalesfragoso: Mutex<Cell<>>*
<re_irc>
<@adamgreig:matrix.org> thejpster: so this sort of breaking change is the sort of thing I had in mind for "a few things that would need wrapping up before 1.0"
<cr1901>
therealprof: Could I see an example? I'm interested :o
<re_irc>
<@therealprof:matrix.org> therealprof: Or also move it back if you're so inclined.
<re_irc>
<@thejpster:matrix.org> This all sounds very good. And I know each crate has tickets, some labelled 1.0
<re_irc>
<@thalesfragoso:matrix.org> oh yeah, that's another use case
<re_irc>
<@adamgreig:matrix.org> therealprof: oh, I see! So you'd have a mutex cell at global scope, move a peripheral into it from main, then in the interrupt you first move it into the interrupt;
<re_irc>
<@thejpster:matrix.org> But does EWG track this in any way?
<re_irc>
<@thejpster:matrix.org> Or do we have the exact same convo next week.
<re_irc>
<@thalesfragoso:matrix.org> it's useful, but just one unsafe away
<re_irc>
<@adamgreig:matrix.org> beyond issues in repos and people's general working knowledge, I don't think we have much coherent cross-repo planning documents, no
<re_irc>
<@eldruin:matrix.org> wasn't there an issue in the wg repo tracking the 1.0 status of the main projects?
<re_irc>
<@thalesfragoso:matrix.org> but it looks like you're initing the reference to zero though, just noticed that
<re_irc>
<@lachlansneff:matrix.org> can it take any expr?
<cr1901>
I'm w/ dirbaio on this one... this cmrt doesn't seem like the right place for these
<re_irc>
<@thalesfragoso:matrix.org> Lachlan Sneff: Only consts
<re_irc>
<@thalesfragoso:matrix.org> but probably a const fn ? not sure, I haven't looked that much at the PR
<re_irc>
<@lachlansneff:matrix.org> thalesfragoso: Maybe it should be `#[init(value = 0)]` then
<re_irc>
<@per.lindgren:matrix.org> You may have a look at the new RTIC syntax, where the `static mut` transform is now gone. Instead you give the init value in the attribute (to the function item).
<re_irc>
<@per.lindgren:matrix.org> (The idea is that the function body should remain pure Rust.)
<re_irc>
<@adamgreig:matrix.org> yea, I think it's quite similar to the RFC in c-m-rt, and motivated by the same reasoning
<re_irc>
<@adamgreig:matrix.org> but perhaps if people want these things they should be gently encouraged to check out rtic
SomeWeirdAnon has joined #rust-embedded
<re_irc>
<@dirbaio:matrix.org> who here is using the cmrt static mut transform?
<re_irc>
<@therealprof:matrix.org> Every cmrt user?
<re_irc>
<@thalesfragoso:matrix.org> dirbaio: Used on the past for simple code
<re_irc>
<@thalesfragoso:matrix.org> where I didn't really needed RTIC
<re_irc>
<@thalesfragoso:matrix.org> creating it outside just for that doesn't seem that good, now I'm balancing to have it on cm-rt, hah
<re_irc>
<@thalesfragoso:matrix.org> we already have the interrupt macro in place, but again, pointing people to RTIC isn't half bad
<re_irc>
<@therealprof:matrix.org> It's not great but it is there and it works.
<re_irc>
<@per.lindgren:matrix.org> The upcoming RTIC 0.6.x will still be monolithic (i.e., provide all functionality out the box). We are discussing a modular approach, (multi-stage pipelined architecture), where the last stage is a very simple extension of CMRT, basically just the resource management.
<re_irc>
<@therealprof:matrix.org> Getting it of it without alternative is not an option for me.
<re_irc>
<@thalesfragoso:matrix.org> With the new syntax I wouldn't oppose it
<re_irc>
<@adamgreig:matrix.org> therealprof: what if the replacement was a simple external crate just for providing safe interrupt-handler resources?
<re_irc>
<@therealprof:matrix.org> thalesfragoso: Do we still get to use the "move-out-of-mutex" trick with that?
<re_irc>
<@therealprof:matrix.org> adamgreig: That sounds too god to be true. I'd absolutely take it. 😉
<re_irc>
<@dirbaio:matrix.org> yeah the resources can be a `macro_rules!`on top of CMRT, doesn't need to be in CMRT
<cr1901>
^These don't require proc-macros?
<re_irc>
<@adamgreig:matrix.org> the new syntax adds like 600 lines of fairly complicated proc macro code to c-m-rt, whereas getting rid of the current resource handling would remove a bunch of the existing complexity, which is kinda nice
<re_irc>
<@dirbaio:matrix.org> the static mut transform did require proc macros
<re_irc>
<@dirbaio:matrix.org> the new syntax might be doable with declarative macros as it's less "horrible hack"?
<re_irc>
<@thalesfragoso:matrix.org> dirbaio: you need at least a trampoline to reduce the borrow, no ?
<re_irc>
<@therealprof:matrix.org> thalesfragoso: Ah, so it's basically taking the function arguments and turning them into `static muts` instead out of the top of the body? That'd work.
<re_irc>
<@adamgreig:matrix.org> well, it sounds like it might at least be an interesting avenue for investigation
<re_irc>
<@adamgreig:matrix.org> we're out of time (in fact a bit overtime) for the meeting, thanks for your input everyone!
<re_irc>
<@thalesfragoso:matrix.org> thanks adam
<re_irc>
<@adamgreig:matrix.org> thejpster: I'm not sure how close we came to forward progress though... I think mostly what we need is some enthusiasm injected towards the goal, and probably c-m-rt is the first place to try and tackle that just because ti's smaller and simpler?
<re_irc>
<@adamgreig:matrix.org> thalesfragoso: I couldn't immediately think of any way to do it without a trampoline, but I guess maybe you could have the macro_rules create the trampline if it contained the whole ISR? bit gross though
<re_irc>
<@adamgreig:matrix.org> wonder how far into the rabbit hole you'd go trying to make this crate before you realised you'd rewritten RTIC
<re_irc>
<@lachlansneff:matrix.org> Should `Error` associated types require `Debug` so that `.unwrap` can work on them without extra bounds?
<re_irc>
<@dirbaio:matrix.org> requiring it is annoying
<re_irc>
<@dirbaio:matrix.org> if users want to unwrap they can do `where T: Uart, T::Error: Debug`
<re_irc>
<@lachlansneff:matrix.org> Is there documentation on rational for `InputPin` returning a `Result`?
<re_irc>
<@adamgreig:matrix.org> because for example your inputpin might be on linux, or implemented over an i2c gpio expander, or otherwise might be able to fail and return an error
<re_irc>
<@adamgreig:matrix.org> implementations that directly access a hardware peripheral (like gpio on most mcus) can't fail, but the trait covers more than that, so returns a result
<re_irc>
<@lachlansneff:matrix.org> Makes sense
<re_irc>
<@lachlansneff:matrix.org> Thanks
<re_irc>
<@sympatron:matrix.org> Is there a difference between `struct T;` and `struct T(());`?
<re_irc>
<@jamesmunns:matrix.org> Yes, they are different types, but they are both zero sized
<re_irc>
<@jamesmunns:matrix.org> Like, they are not exchangeable, but the net effect is the same.
<re_irc>
<@dirbaio:matrix.org> `struct T(());` cannot be constructed from outside the current mod/crate (you'd need `struct T(pub ());` for that
<re_irc>
<@jamesmunns:matrix.org> Ahhhh good call
<re_irc>
<@jamesmunns:matrix.org> I forgot about visibility
<re_irc>
<@dirbaio:matrix.org> I find writing it like this is a bit more readable
<re_irc>
<@adamgreig:matrix.org> i'm not sure you can do it with a macro_rules
<re_irc>
<@adamgreig:matrix.org> you need to write the outer lifetime yourself otherwise a cheeky user could put `<'a: 'static>` lol
<re_irc>
<@adamgreig:matrix.org> annoying though, I really want to be able to just decorate the resource, not the function itself
<re_irc>
<@dirbaio:matrix.org> so the macro would only generate the "statik" thing?
<re_irc>
<@adamgreig:matrix.org> well I'd like that but I don't think it works with what's in that playground
<re_irc>
<@adamgreig:matrix.org> because you can't trust the user to have provided a suitable lifetime
<re_irc>
<@dirbaio:matrix.org> not just that, you can't trust the user to call that macro only in an irq handler 🤣
<re_irc>
<@adamgreig:matrix.org> sure, that too, although
<re_irc>
<@dirbaio:matrix.org> they could call it in a normal functoin and call it reentrantly
<re_irc>
<@adamgreig:matrix.org> mmm, yea
<re_irc>
<@adamgreig:matrix.org> yea, forgot the function still must not be callable from anywhere else
<re_irc>
<@adamgreig:matrix.org> so you probably do need to create the function inside the macro one way or another
<re_irc>
<@adamgreig:matrix.org> might avoid the trampoline this way though
<re_irc>
<@adamgreig:matrix.org> and generating the function from a macro-by-example is a bit boring so i suspect it will have to be a proc macro one way or another
<re_irc>
<@dirbaio:matrix.org> proc macros are definitely more *exciting* :)
<re_irc>
<@adamgreig:matrix.org> only way the proc macro can really be sure it's also making an ISR is probably for it to call the c-m-rt interrupt macro itself, too, at which point it seems less and less useful to put it into its own crate instead of having it be in c-m-rt :/
<re_irc>
<@adamgreig:matrix.org> maybe it could at least just see that you've also put #[interrupt] on it
rektide has joined #rust-embedded
<cr1901>
I'll let the ARM ppl fight it out and take inspiration from the decisions :)
<re_irc>
<@therealprof:matrix.org> Hm, weird. Mutably iterating over an `Option` produces smaller code than simply `as_mut`ing it...