You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! Thanks so much for this crate! I've run into an issue and I'm looking for some guidance.
I'm somewhat new to Rust and very new to embedded so hopefully my question will make sense. Is there a way to type alias expander pins as simply as an MCU pin? For example, the stm32f1xx-hal has simple type aliases for each pin, something like PA0 or PB9.
What I'm trying to solve:
In my project I've got a few basic components: single-pin LED, dual-pin LED and a switch. I've then created assemblies that combine these building blocks to create something like a "button that has a multi-color LED". I wrote them all with the embedded-halOuputPin or InputPin traits in mind. Here's a simplified version of the Led struct:
In order to control these components/assemblies I need to define them in rtic as resources in the Shared resource struct. The catch is, as far as I understand, that the Shared struct doesn't allow lifetimes or generic parameters. Before I added the expander I was just defining Led with the MCU pin within the struct like so:
I would do the same thing with GPIO expander pins but the type for a pin is incredibly complicated and has lifetime and generic parameters. I checked other expander crates and they all seems to have the same sort of complex type signatures. So I'm under the impression that the answer to my question is probably "no".
In any case, I tried using the full GPIO expander pin type definition and just giving it a static lifetime. But when I did that, rtic complained that the type (RefCell) was not thread safe. I know I'm running this single-threaded so I defined a Newtype around the GPIO expander pin type and implemented an unsafe Sync for it. Then I got lifetime issues which I wasn't surprised to see.
Thoughts? Is there something I'm missing? I feel like I'm doing something I shouldn't be doing as this is feeling way difficult. I'm currently stumped and have been considering just using a larger pin variant of the stm32. However I'd really love to get the expander working!
Thanks for taking the time! :D
For the sake of completion here's a fully "working" example that does not compile.
Hey! Thanks so much for this crate! I've run into an issue and I'm looking for some guidance.
I'm somewhat new to Rust and very new to embedded so hopefully my question will make sense. Is there a way to type alias expander pins as simply as an MCU pin? For example, the
stm32f1xx-hal
has simple type aliases for each pin, something likePA0
orPB9
.What I'm trying to solve:
In my project I've got a few basic components: single-pin LED, dual-pin LED and a switch. I've then created assemblies that combine these building blocks to create something like a "button that has a multi-color LED". I wrote them all with the
embedded-hal
OuputPin
orInputPin
traits in mind. Here's a simplified version of theLed
struct:In order to control these components/assemblies I need to define them in
rtic
as resources in theShared
resource struct. The catch is, as far as I understand, that theShared
struct doesn't allow lifetimes or generic parameters. Before I added the expander I was just definingLed
with the MCU pin within the struct like so:I would do the same thing with GPIO expander pins but the type for a pin is incredibly complicated and has lifetime and generic parameters. I checked other expander crates and they all seems to have the same sort of complex type signatures. So I'm under the impression that the answer to my question is probably "no".
In any case, I tried using the full GPIO expander pin type definition and just giving it a
static
lifetime. But when I did that,rtic
complained that the type (RefCell
) was not thread safe. I know I'm running this single-threaded so I defined a Newtype around the GPIO expander pin type and implemented an unsafeSync
for it. Then I got lifetime issues which I wasn't surprised to see.Thoughts? Is there something I'm missing? I feel like I'm doing something I shouldn't be doing as this is feeling way difficult. I'm currently stumped and have been considering just using a larger pin variant of the stm32. However I'd really love to get the expander working!
Thanks for taking the time! :D
For the sake of completion here's a fully "working" example that does not compile.
The text was updated successfully, but these errors were encountered: