diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-01-15 02:09:24 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-01-15 02:15:30 +0100 |
| commit | 2fab8d0b9ba8eecc40b76c00fab19abf0426a8ff (patch) | |
| tree | 77e783e5626db5204639bd42ea938441294726b8 /docs/examples/layer-by-layer/blinky-pac | |
| parent | 4d9b2798fa807052a0d2fb49d50232ecd05d4a4c (diff) | |
Update doc projects deps, don't use patch.crates-io
Diffstat (limited to 'docs/examples/layer-by-layer/blinky-pac')
| -rw-r--r-- | docs/examples/layer-by-layer/blinky-pac/Cargo.toml | 6 | ||||
| -rw-r--r-- | docs/examples/layer-by-layer/blinky-pac/src/main.rs | 48 |
2 files changed, 23 insertions, 31 deletions
diff --git a/docs/examples/layer-by-layer/blinky-pac/Cargo.toml b/docs/examples/layer-by-layer/blinky-pac/Cargo.toml index f872b94cb..cf2d7fede 100644 --- a/docs/examples/layer-by-layer/blinky-pac/Cargo.toml +++ b/docs/examples/layer-by-layer/blinky-pac/Cargo.toml | |||
| @@ -7,8 +7,8 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | cortex-m = "0.7" | 8 | cortex-m = "0.7" |
| 9 | cortex-m-rt = "0.7" | 9 | cortex-m-rt = "0.7" |
| 10 | stm32-metapac = { version = "1", features = ["stm32l475vg", "memory-x"] } | 10 | stm32-metapac = { version = "16", features = ["stm32l475vg"] } |
| 11 | 11 | ||
| 12 | defmt = "0.3.0" | 12 | defmt = "0.3" |
| 13 | defmt-rtt = "0.3.0" | 13 | defmt-rtt = "0.4" |
| 14 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | 14 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } |
diff --git a/docs/examples/layer-by-layer/blinky-pac/src/main.rs b/docs/examples/layer-by-layer/blinky-pac/src/main.rs index 990d46cb6..cfbd91306 100644 --- a/docs/examples/layer-by-layer/blinky-pac/src/main.rs +++ b/docs/examples/layer-by-layer/blinky-pac/src/main.rs | |||
| @@ -8,46 +8,38 @@ use {defmt_rtt as _, panic_probe as _, stm32_metapac as pac}; | |||
| 8 | fn main() -> ! { | 8 | fn main() -> ! { |
| 9 | // Enable GPIO clock | 9 | // Enable GPIO clock |
| 10 | let rcc = pac::RCC; | 10 | let rcc = pac::RCC; |
| 11 | unsafe { | 11 | rcc.ahb2enr().modify(|w| { |
| 12 | rcc.ahb2enr().modify(|w| { | 12 | w.set_gpioben(true); |
| 13 | w.set_gpioben(true); | 13 | w.set_gpiocen(true); |
| 14 | w.set_gpiocen(true); | 14 | }); |
| 15 | }); | ||
| 16 | 15 | ||
| 17 | rcc.ahb2rstr().modify(|w| { | 16 | rcc.ahb2rstr().modify(|w| { |
| 18 | w.set_gpiobrst(true); | 17 | w.set_gpiobrst(true); |
| 19 | w.set_gpiocrst(true); | 18 | w.set_gpiocrst(true); |
| 20 | w.set_gpiobrst(false); | 19 | w.set_gpiobrst(false); |
| 21 | w.set_gpiocrst(false); | 20 | w.set_gpiocrst(false); |
| 22 | }); | 21 | }); |
| 23 | } | ||
| 24 | 22 | ||
| 25 | // Setup button | 23 | // Setup button |
| 26 | let gpioc = pac::GPIOC; | 24 | let gpioc = pac::GPIOC; |
| 27 | const BUTTON_PIN: usize = 13; | 25 | const BUTTON_PIN: usize = 13; |
| 28 | unsafe { | 26 | gpioc.pupdr().modify(|w| w.set_pupdr(BUTTON_PIN, vals::Pupdr::PULL_UP)); |
| 29 | gpioc.pupdr().modify(|w| w.set_pupdr(BUTTON_PIN, vals::Pupdr::PULLUP)); | 27 | gpioc.otyper().modify(|w| w.set_ot(BUTTON_PIN, vals::Ot::PUSH_PULL)); |
| 30 | gpioc.otyper().modify(|w| w.set_ot(BUTTON_PIN, vals::Ot::PUSHPULL)); | 28 | gpioc.moder().modify(|w| w.set_moder(BUTTON_PIN, vals::Moder::INPUT)); |
| 31 | gpioc.moder().modify(|w| w.set_moder(BUTTON_PIN, vals::Moder::INPUT)); | ||
| 32 | } | ||
| 33 | 29 | ||
| 34 | // Setup LED | 30 | // Setup LED |
| 35 | let gpiob = pac::GPIOB; | 31 | let gpiob = pac::GPIOB; |
| 36 | const LED_PIN: usize = 14; | 32 | const LED_PIN: usize = 14; |
| 37 | unsafe { | 33 | gpiob.pupdr().modify(|w| w.set_pupdr(LED_PIN, vals::Pupdr::FLOATING)); |
| 38 | gpiob.pupdr().modify(|w| w.set_pupdr(LED_PIN, vals::Pupdr::FLOATING)); | 34 | gpiob.otyper().modify(|w| w.set_ot(LED_PIN, vals::Ot::PUSH_PULL)); |
| 39 | gpiob.otyper().modify(|w| w.set_ot(LED_PIN, vals::Ot::PUSHPULL)); | 35 | gpiob.moder().modify(|w| w.set_moder(LED_PIN, vals::Moder::OUTPUT)); |
| 40 | gpiob.moder().modify(|w| w.set_moder(LED_PIN, vals::Moder::OUTPUT)); | ||
| 41 | } | ||
| 42 | 36 | ||
| 43 | // Main loop | 37 | // Main loop |
| 44 | loop { | 38 | loop { |
| 45 | unsafe { | 39 | if gpioc.idr().read().idr(BUTTON_PIN) == vals::Idr::LOW { |
| 46 | if gpioc.idr().read().idr(BUTTON_PIN) == vals::Idr::LOW { | 40 | gpiob.bsrr().write(|w| w.set_bs(LED_PIN, true)); |
| 47 | gpiob.bsrr().write(|w| w.set_bs(LED_PIN, true)); | 41 | } else { |
| 48 | } else { | 42 | gpiob.bsrr().write(|w| w.set_br(LED_PIN, true)); |
| 49 | gpiob.bsrr().write(|w| w.set_br(LED_PIN, true)); | ||
| 50 | } | ||
| 51 | } | 43 | } |
| 52 | } | 44 | } |
| 53 | } | 45 | } |
