Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Global object like LCD/USART in Rust
I would like to know how to create a static (global) LCD
or USART
object that different parts of my program can use. I've tried various approaches, but I believe it may not be possible.
In embedded Rust, you need to take ownership of the hardware, as shown below:
rust
let mut dp = pac::Peripherals::take().unwrap();
Once you take ownership, you cannot take it again. Taking partial ownership also prevents you from passing dp
to other places.
How can you send text to USART
or LCD
from different functionsโnot just from main
? I am beginning to think this might not be feasible.
Please avoid suggesting the use of Mutex
or other multi-thread-safe constructs. This issue is not about safety; itโs about the ability to access peripherals from different functions within my project. Thank you.
6 posts - 3 participants
๐ท๏ธ rust_feed