4 ms·
As a hobbyist, I find Rust on embedded is wonderful. e.g. I prefer Rust's traits over C's CPP defines for configuring peripherals. > MY_GPIO.borrow(cs).borrow(
by rgoulter 3y ago
As a hobbyist, I find Rust on embedded is wonderful. e.g. I prefer Rust's traits over C's CPP defines for configuring peripherals.
> MY_GPIO.borrow(cs).borrow().as_ref().unwrap()
This code looks like it's some kind of global Mutex<RefCell<Option<LedPin>>>.
Looking at some other examples, setting an LED pin to high is just `.set_high()`
https://github.com/stm32-rs/stm32f4xx-hal/blob/master/examples/blinky.rs https://github.com/stm32-rs/stm32f4xx-hal/blob/master/exampl...
Though yeah, this example which passes a pin to an interrupt handler has similar dense `.borrow` calls
https://github.com/stm32-rs/stm32f4xx-hal/blob/master/examples/blinky-timer-irq.rs https://github.com/stm32-rs/stm32f4xx-hal/blob/master/exampl...
I think for sharing resources across functions, I've enjoyed using rtic; e.g. a similar example there:
https://github.com/rtic-rs/rtic-examples/blob/master/rtic_v1/stm32f3_blinky/src/main.rs https://github.com/rtic-rs/rtic-examples/blob/master/rtic_v1...