I'm completely new to Rust, and way out of my depth. I have a lot of C++ experience, though.
I'm trying to get the stm32f1xx_hal working. The examples for a simple LED seem fairly convoluted. Here's how to set up pin pc13 for output, for example:
let dp = pac::Peripherals::take().unwrap();
let mut rcc = dp.RCC.constrain();
let mut gpioc = dp.GPIOC.split(&mut rcc.apb2);
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
It would be nice if I could type something like
let mut pc13 = pin_out(PC13);
Maybe creating an enum Pin { ... }.
However, there appears to be easy way to do this. GPIOA, GPIOB, ... seem to be of fundamentally different and incompatible types, even though, presumably, what I'm trying to obtain is a standard output pin that is the same regardless of the GPIO port I use.
Hmmm. I don't think the stm32f103 hal actually provides a neat answer. It seems that I'd have to hard-code every GPIO pin possibility, or else basically come up with something that peeks and pokes raw register addresses.
Is there a simple solution to this?
Also, what if I want to blink two LEDs asynchronously? What's the "standard solution"?