3 ms·
Huh? Usually (using any of the `embedded_hal` crates) it'll be something like `let mut gpioa = dp.GPIOA.split();` to get the GPIO A port from the Device Periph
by SAI_Peregrinus 3y ago
Huh? Usually (using any of the `embedded_hal` crates) it'll be something like
`let mut gpioa = dp.GPIOA.split();` to get the GPIO A port from the Device Peripherals list `dp`.
`let pa5 = gpioa.pa5.into_push_pull_output();` to declare which pin in that GPIO port you're using, and set it into a push/pull output (input pull up, input pull down, input floating, and output open drain are of course also defined) and then
`pa5.set_high();` to set it high (`pa5.set_low()` for low).
There are HAL modules for most common MCUs, and a few uncommon MCUs. Use the HAL.
The official embedded Rust book also includes how to write such a HAL, which seems to be the bit you stumbled on. Ignore it if you're not writing a new HAL crate.