Hi everyone,
I'm trying to implement a blink LED on the STM32G070RBT6 using RTIC, but I'm getting an error that I don't know how to fix. If anyone could help me, I would really appreciate it.
Thanks in advance!
The code is bellow and the image is the error I found. I kind of used these repository as a base: GitHub - rtic-rs/rtic-examples: Example projects using Real-Time Interrupt-driven Concurrency (RTIC) on different MCUs
main.rs:
#![no_main]
#![no_std]
use rtic::app;
use systick_monotonic::{fugit::{ExtU32, MillisDurationU64}, Systick};
use stm32g0xx_hal as hal;
use hal::prelude::*;
use hal::rcc::{Config, Prescaler};
use hal::stm32;
use stm32g0xx_hal::gpio::{Output, PushPull, PA5};
use panic_halt as _;
const INTERVAL_MS: u32 = 500;
#[app(
device = stm32g0xx_hal::pac,
peripherals = true,
dispatchers = [SPI1],
)]
mod app {
use super::*;
#[monotonic(binds = SysTick, default = true)]
type Tonic = Systick<1000>;
#[local]
struct Local {
led: PA5<Output<PushPull>>,
}
#[shared]
struct Shared {}
#[init]
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
let mut rcc = dp.RCC.freeze(Config::hsi(Prescaler::Div2));
let gpioa = dp.GPIOA.split(&mut rcc);
let led = gpioa.pa5.into_push_pull_output();
let mono = Systick::new(cx.core.SYST, 16_000_000);
let local = Local { led };
let _ = blink::spawn_after(INTERVAL_MS.millis().into());
(Shared {}, local, init::Monotonics(mono))
}
#[task(local = [led])]
fn blink(cx: blink::Context) {
let led = cx.local.led;
led.toggle().unwrap();
let _ = blink::spawn_after(INTERVAL_MS.millis().into());
}
}
cargo.toml:
[package]
name = "blink"
version = "0.1.0"
edition = "2021"
[dependencies]
cortex-m-rtic = "1.1.4"
systick-monotonic = "1.0.1"
panic-rtt-target = { version = "0.1.2", features = ["cortex-m"] }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
stm32g0 = { version = "0.15.1", default-features = false, features = ["rt", "stm32g070"] }
stm32g0xx-hal = { version = "0.2.0", features = ["rt", "stm32g070"] }
embedded-hal = "1.0.0"
defmt = "0.3.8"
defmt-rtt = "0.4.1"
heapless = { version = "0.8.0", default-features = false }
cortex-m-rt = "0.7.3" #em vez de 3 tava 1
panic-halt = "0.2.0"
nb = "1.1.0"
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
[build]
target = "thumbv6m-none-eabi"
[profile.dev]
opt-level = 1
codegen-units = 16
debug = true
lto = false
[profile.release]
opt-level = "s" # optimize for size
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations