<sajattack[m]1>
Is there a better way to share data between interrupts than static mut or not really?
<sajattack[m]1>
Rtic probably has something fancy I guess
<adamgreig[m]>
RTIC is the something fancy, really
<sajattack[m]1>
Ok thx
<adamgreig[m]>
if you just want to share little data, Atomics are really nice
<adamgreig[m]>
like, up to a u32
<sajattack[m]1>
It's funny I've done a lot on the hal side but not a lot on the applications side and I finally have a good excuse to learn all this stuff
<sajattack[m]1>
And suppose I have a driver struct that defines the structs, data, and methods it needs, how do I work that into rtic? Like I vaguely recal rtic apps have resources or something. How does it work for a generic driver to define what it wants from rtic? Or is it just a matter of making the resource a parameter of the ISR?
<adamgreig[m]>
if you have a driver struct and the user wants to interact with it from both an interrupt and some other interrupt or the main thread, the user can put that driver struct into a resource and rtic will allow them to access it from those different places
<adamgreig[m]>
so the driver just has one struct and maybe it has a method like "call me from this interrupt" and "call me in your main loop" or whatever
<sajattack[m]1>
yeah that's kinda what I was thinking too - but what I'm thinking about is how to define the shared mutable state. Maybe it can just be part of the struct. But usually static mut's can't be part of a struct.
<adamgreig[m]>
can't you just put it directly inside the struct?
<sajattack[m]1>
probably that's what I'm asking
<adamgreig[m]>
you can't put a static mut inside the struct, but you can just put data inside the struct
<sajattack[m]1>
yeah nevermind I'm dumb
<adamgreig[m]>
there's potentially some downsides if it's like 1kB+ of data, because it might end up moved around on the stack a bit to get to its final place
<adamgreig[m]>
if you don't want to store the data inside the driver struct, take a `&'static mut Data` in your constructor, and let the user worry about providing it somehow (rtic can help)
<sajattack[m]1>
thanks
<JamesMunns[m]>
<adamgreig[m]> "if you don't want to store the..." <- Or the singleton macro in cmrt, or StaricCell
<jamwaffles[m]>
Hey all, is there an `async` equivalent of [embedded-io](https://docs.rs/embedded-io/latest/embedded_io/)? Maybe something in Embassy? I'd like to provide an async reader trait bound to something so I can abstract over a real device or a mock in my unit tests. Nightly is ok.
<jamwaffles[m]>
Ah I knew I'd seen it somewhere. Thank you!
starblue has quit [Ping timeout: 256 seconds]
starblue has joined #rust-embedded
<rukai[m]>
<M9names[m]> "https://github.com/dlkj/usbd-..." <- This was exactly what I needed, thanks! I swapped out keyberons USB keyboard parts with this crate and then was able to add a mouse device and got it all working together.