diff options
| author | Ulf Lilleengen <[email protected]> | 2024-05-18 10:17:03 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2024-05-21 10:05:21 +0200 |
| commit | 739e5861c2e47db251725163fcd91cd822cf97b7 (patch) | |
| tree | 947dc7961ca7c42ec216056fc2adf616ab812b10 /docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src | |
| parent | 51d553092550059afb22b2620cea14bbed21abff (diff) | |
convert from antora to asciidoctor
Diffstat (limited to 'docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src')
| -rw-r--r-- | docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs deleted file mode 100644 index 990d46cb6..000000000 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/src/main.rs +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use pac::gpio::vals; | ||
| 5 | use {defmt_rtt as _, panic_probe as _, stm32_metapac as pac}; | ||
| 6 | |||
| 7 | #[cortex_m_rt::entry] | ||
| 8 | fn main() -> ! { | ||
| 9 | // Enable GPIO clock | ||
| 10 | let rcc = pac::RCC; | ||
| 11 | unsafe { | ||
| 12 | rcc.ahb2enr().modify(|w| { | ||
| 13 | w.set_gpioben(true); | ||
| 14 | w.set_gpiocen(true); | ||
| 15 | }); | ||
| 16 | |||
| 17 | rcc.ahb2rstr().modify(|w| { | ||
| 18 | w.set_gpiobrst(true); | ||
| 19 | w.set_gpiocrst(true); | ||
| 20 | w.set_gpiobrst(false); | ||
| 21 | w.set_gpiocrst(false); | ||
| 22 | }); | ||
| 23 | } | ||
| 24 | |||
| 25 | // Setup button | ||
| 26 | let gpioc = pac::GPIOC; | ||
| 27 | const BUTTON_PIN: usize = 13; | ||
| 28 | unsafe { | ||
| 29 | gpioc.pupdr().modify(|w| w.set_pupdr(BUTTON_PIN, vals::Pupdr::PULLUP)); | ||
| 30 | gpioc.otyper().modify(|w| w.set_ot(BUTTON_PIN, vals::Ot::PUSHPULL)); | ||
| 31 | gpioc.moder().modify(|w| w.set_moder(BUTTON_PIN, vals::Moder::INPUT)); | ||
| 32 | } | ||
| 33 | |||
| 34 | // Setup LED | ||
| 35 | let gpiob = pac::GPIOB; | ||
| 36 | const LED_PIN: usize = 14; | ||
| 37 | unsafe { | ||
| 38 | gpiob.pupdr().modify(|w| w.set_pupdr(LED_PIN, vals::Pupdr::FLOATING)); | ||
| 39 | gpiob.otyper().modify(|w| w.set_ot(LED_PIN, vals::Ot::PUSHPULL)); | ||
| 40 | gpiob.moder().modify(|w| w.set_moder(LED_PIN, vals::Moder::OUTPUT)); | ||
| 41 | } | ||
| 42 | |||
| 43 | // Main loop | ||
| 44 | loop { | ||
| 45 | unsafe { | ||
| 46 | if gpioc.idr().read().idr(BUTTON_PIN) == vals::Idr::LOW { | ||
| 47 | gpiob.bsrr().write(|w| w.set_bs(LED_PIN, true)); | ||
| 48 | } else { | ||
| 49 | gpiob.bsrr().write(|w| w.set_br(LED_PIN, true)); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
