Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How to place complex types into global statics?
Newbie here. How can I place this stuff into a global static?
let spi1hal: Spi<Enabled, SPI1, (Pin<Gpio11, FunctionSpi, PullDown>, Pin<Gpio12, FunctionSpi, PullDown>, Pin<Gpio10, FunctionSpi, PullDown>)>
It's the result of SPI initialization. I'd like to have it in a global static in order to access the peripherals from other functions (ISRs too, maybe?); and without the need to search for changes in the code every time I change a pin or a pullup/pulldown. It should be bus agnostic solution (ie: I've similar complex types for i2c and uarts).
Don't have to necessarily be a global static; but even if I place that nightmare into a function arg, I need to define the type and ... same problem apply: whenever I change 1 pin I must go searching for all the functions using that peripheral.
EDIT: I'm using rtic, so have that variable into the tasks' "Shared" resources, would probably be a better solution than a global static.
I'm missing something important; more than one thing. But I've no idea how to solve this kind of problem. I've been wrestling with structs and traits, lifetimes and the borrow checker, for 2 days before posting. I'm exhausted.
5 posts - 3 participants
🏷️ rust_feed