I/O pin managment with embedded bare metal rust

⚓ Rust    📅 2025-10-18    👤 surdeus    👁️ 1      

surdeus

I have recently been working on a GPIO/I2C library for the RPI and have been trying to come up with a good method for keeping track of which GPIO pins are in use.

Specifically for things like serial communication (i.e. I2C, SPI, ect.). I was thinking that I could use an array and put the pins in use into that but I'm worried that that might be bad practice. The important thing to remember is that I can't use the std library because this is for embedded programming and their is no OS. I also checked over on stackoverflow and someone mentioned that embedded-hal uses the singleton pattern but I have been reading through that code and haven't seen anything for singleton in just the main crate.

Ideally this would be accessible between cores, so it would be atomic. I also need to be able to remove pins from the list. If anyone has any ideas or any opinions on using arrays your input would be much appreciated.

3 posts - 2 participants

Read full topic

🏷️ Rust_feed