diff --git a/embedded-examples/stm32h7-rtic/Cargo.lock b/embedded-examples/stm32h7-rtic/Cargo.lock index 862eb61..757e7f1 100644 --- a/embedded-examples/stm32h7-rtic/Cargo.lock +++ b/embedded-examples/stm32h7-rtic/Cargo.lock @@ -529,7 +529,7 @@ dependencies = [ ] [[package]] -name = "satrs-stm32h7-rtic" +name = "satrs-stm32h7-nucleo-rtic" version = "0.1.0" dependencies = [ "cortex-m", diff --git a/embedded-examples/stm32h7-rtic/Cargo.toml b/embedded-examples/stm32h7-rtic/Cargo.toml index d9d2bd6..3b5f920 100644 --- a/embedded-examples/stm32h7-rtic/Cargo.toml +++ b/embedded-examples/stm32h7-rtic/Cargo.toml @@ -1,9 +1,9 @@ [package] authors = ["Robin Mueller "] -name = "satrs-stm32h7-rtic" +name = "satrs-stm32h7-nucleo-rtic" edition = "2021" version = "0.1.0" -default-run = "satrs-stm32h7-rtic" +default-run = "satrs-stm32h7-nucleo-rtic" [lib] harness = false diff --git a/embedded-examples/stm32h7-rtic/src/bin/blinky.rs b/embedded-examples/stm32h7-rtic/src/bin/blinky.rs index 3f164d4..209f5b6 100644 --- a/embedded-examples/stm32h7-rtic/src/bin/blinky.rs +++ b/embedded-examples/stm32h7-rtic/src/bin/blinky.rs @@ -5,14 +5,12 @@ #![no_std] #![no_main] -use satrs_stm32h7_rtic as _; +use satrs_stm32h7_nucleo_rtic as _; use stm32h7xx_hal::{block, prelude::*, timer::Timer}; use cortex_m_rt::entry; -// use embedded_hal::digital::v2::OutputPin; - #[entry] fn main() -> ! { // Get access to the device specific peripherals from the peripheral access crate @@ -45,6 +43,8 @@ fn main() -> ! { let mut timer = Timer::tim1(dp.TIM1, ccdr.peripheral.TIM1, &ccdr.clocks); timer.start(1.Hz()); + defmt::info!("starting stm32h7 blinky example"); + // Wait for the timer to trigger an update and change the state of the LED loop { ld1.toggle(); diff --git a/embedded-examples/stm32h7-rtic/src/bin/hello.rs b/embedded-examples/stm32h7-rtic/src/bin/hello.rs index 7bc9992..cc90058 100644 --- a/embedded-examples/stm32h7-rtic/src/bin/hello.rs +++ b/embedded-examples/stm32h7-rtic/src/bin/hello.rs @@ -1,11 +1,11 @@ #![no_main] #![no_std] -use satrs_stm32h7_rtic as _; // global logger + panicking-behavior + memory layout +use satrs_stm32h7_nucleo_rtic as _; // global logger + panicking-behavior + memory layout #[cortex_m_rt::entry] fn main() -> ! { defmt::println!("Hello, world!"); - satrs_stm32h7_rtic::exit() + satrs_stm32h7_nucleo_rtic::exit() } diff --git a/embedded-examples/stm32h7-rtic/src/main.rs b/embedded-examples/stm32h7-rtic/src/main.rs index 125628a..82e0c94 100644 --- a/embedded-examples/stm32h7-rtic/src/main.rs +++ b/embedded-examples/stm32h7-rtic/src/main.rs @@ -2,7 +2,7 @@ #![no_std] use rtic::app; -use satrs_stm32h7_rtic as _; +use satrs_stm32h7_nucleo_rtic as _; // global logger + panicking-behavior + memory layout const DEFAULT_BLINK_FREQ_MS: u32 = 1000; @@ -20,7 +20,7 @@ mod app { } struct Leds { - led0: Pin<'A', 1, Output>, + led0: Pin<'B', 0, Output>, led1: Pin<'B', 7, Output>, led2: Pin<'B', 14, Output>, } @@ -38,38 +38,32 @@ mod app { // Try to keep the clock configuration similar to one used in STM examples: // https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Projects/NUCLEO-H743ZI/Examples/GPIO/GPIO_EXTI/Src/main.c let ccdr = rcc - /* .sys_ck(400.MHz()) .hclk(200.MHz()) - */ .use_hse(8.MHz()) .bypass_hse() - /* .pclk1(100.MHz()) .pclk2(100.MHz()) .pclk3(100.MHz()) .pclk4(100.MHz()) - */ .freeze(pwrcfg, &cx.device.SYSCFG); // Initialize the systick interrupt & obtain the token to prove that we did let systick_mono_token = rtic_monotonics::create_systick_token!(); Systick::start( cx.core.SYST, - 8_000_000, - //ccdr.clocks.sys_ck().to_Hz(), - //8_000_000, + ccdr.clocks.sys_ck().to_Hz(), systick_mono_token, ); defmt::info!("Starting sat-rs demo application for the STM32H743ZIT"); - let gpioa = cx.device.GPIOA.split(ccdr.peripheral.GPIOA); let gpiob = cx.device.GPIOB.split(ccdr.peripheral.GPIOB); - let led0 = gpioa.pa1.into_push_pull_output(); + let led0 = gpiob.pb0.into_push_pull_output(); let led1 = gpiob.pb7.into_push_pull_output(); let led2 = gpiob.pb14.into_push_pull_output(); let leds = Leds { led0, led1, led2 }; + blink::spawn().expect("spawning blink task failed"); ( Shared { blink_freq: MillisDurationU32::from_ticks(DEFAULT_BLINK_FREQ_MS), @@ -81,10 +75,12 @@ mod app { #[task(local = [leds], shared=[blink_freq])] async fn blink(mut cx: blink::Context) { let leds = cx.local.leds; - leds.led0.toggle(); - leds.led1.toggle(); - leds.led2.toggle(); - let current_blink_freq = cx.shared.blink_freq.lock(|current| *current); - Systick::delay(current_blink_freq).await; + loop { + leds.led0.toggle(); + leds.led1.toggle(); + leds.led2.toggle(); + let current_blink_freq = cx.shared.blink_freq.lock(|current| *current); + Systick::delay(current_blink_freq).await; + } } }