Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ jobs:
- stm32f479
rust:
- stable
features:
- usb_fs,sdio-host,can,i2s,fsmc_lcd,rtic1
include:
- rust: nightly
mcu: stm32f479
experimental: true
features: usb_fs,sdio-host,can,i2s,fsmc_lcd,rtic2

steps:
- uses: actions/checkout@v4
Expand All @@ -55,9 +58,9 @@ jobs:
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
key: v0.18.0-${{ matrix.mcu }}
key: v0.19.0-${{ matrix.mcu }}

- uses: actions-rs/cargo@v1
with:
command: check
args: --features=${{ matrix.mcu }},usb_fs,sdio-host,can,i2s,fsmc_lcd,rtic --examples
args: --features=${{ matrix.mcu }},${{ matrix.features }} --examples
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- bump embedded-hal to `1.0` (no more RC!)
- make `embedded-hal` `1.0` main implementation
- add `embedded-hal-nb::serial`
- rename `rtic` feature to `rtic1`, add `rtic2`

## [v0.19.0] - 2023-12-11

Expand Down
43 changes: 29 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repository = "https://github.com/stm32-rs/stm32f4xx-hal"
version = "0.19.0"

[package.metadata.docs.rs]
features = ["stm32f429", "usb_fs", "can", "i2s", "fsmc_lcd", "rtic", "defmt"]
features = ["stm32f429", "usb_fs", "can", "i2s", "fsmc_lcd", "rtic1", "defmt"]
targets = ["thumbv7em-none-eabihf"]

[dependencies]
Expand All @@ -42,8 +42,15 @@ void = { default-features = false, version = "1.0.2" }
display-interface = { version = "0.4.1", optional = true }
fugit = "0.3.7"
fugit-timer = "0.1.3"
# rtic1
rtic-monotonic = { version = "1.0", optional = true }
systick-monotonic = { version = "1.0", optional = true }
cortex-m-rtic = { version = "1.1.4", features = ["test-critical-section"], optional = true }
# rtic2
rtic-time = { version = "1.3", optional = true }
rtic-monotonics = { version = "1.5", features = ["cortex-m-systick"], optional = true }
rtic = { version = "2.0.1", features = ["thumbv7-backend"], optional = true }

enumflags2 = "0.7.8"
embedded-storage = "0.3"
vcell = "0.1.3"
Expand Down Expand Up @@ -81,7 +88,6 @@ embedded-graphics = "0.7.1"
usb-device = "0.3.1"
usbd-serial = "0.2.0"
micromath = "2"
cortex-m-rtic = { version = "1.1.4", features = ["test-critical-section"] }
dwt-systick-monotonic = "1.1"
st7789 = "0.7.0"
rtt-target = { version = "0.4.0" }
Expand Down Expand Up @@ -259,8 +265,13 @@ gpio-f469 = [
"usart3", "uart4", "uart5", "uart7", "uart8",
]

## Support monotonic timers that can be used by [RTIC framework](https://crates.io/crates/cortex-m-rtic)
rtic = ["dep:rtic-monotonic", "dep:systick-monotonic"]
## Support monotonic timers and other stuff that can be used by [RTICv1 framework](https://crates.io/crates/cortex-m-rtic)
rtic1 = ["dep:rtic-monotonic", "dep:systick-monotonic", "cortex-m-rtic"]

## Support monotonic timers and other stuff that can be used by [RTICv2 framework](https://crates.io/crates/rtic)
##
## Requires nightly rust compiler
rtic2 = ["dep:rtic-time", "dep:rtic-monotonics", "dep:rtic"]

## Implementation of `defmt::Format` for public enums and structures. See [defmt](https://crates.io/crates/defmt)
defmt = ["dep:defmt", "fugit/defmt", "nb/defmt-0-3"]
Expand Down Expand Up @@ -438,43 +449,47 @@ required-features = ["stm32f411"]

[[example]]
name = "rtic-adc-dma"
required-features = ["rtic"] # stm32f401
required-features = ["rtic1"] # stm32f401

[[example]]
name = "rtic-button"
required-features = ["stm32f411", "rtic"] # stm32f411
required-features = ["stm32f411", "rtic1"] # stm32f411

[[example]]
name = "rtic-i2s-audio-in-out"
required-features = ["stm32f411", "i2s", "rtic"]
required-features = ["stm32f411", "i2s", "rtic1"]

[[example]]
name = "rtic-dual-i2s-audio-in-out"
required-features = ["stm32f411", "i2s", "rtic"]
required-features = ["stm32f411", "i2s", "rtic1"]

[[example]]
name = "rtic-serial-dma-rx-idle"
required-features = ["stm32f411", "rtic"]
required-features = ["stm32f411", "rtic1"]

[[example]]
name = "rtic-spi-slave-dma"
required-features = ["stm32f411", "rtic"]
required-features = ["stm32f411", "rtic1"]

[[example]]
name = "rtic-tick"
required-features = ["tim2", "rtic"]
required-features = ["tim2", "rtic1"]

[[example]]
name = "rtic-usart-shell"
required-features = ["stm32f411", "rtic"] # stm32f411
required-features = ["stm32f411", "rtic1"] # stm32f411

[[example]]
name = "rtic-usart-shell-ssd1306"
required-features = ["stm32f411", "rtic"] # stm32f411
required-features = ["stm32f411", "rtic1"] # stm32f411

[[example]]
name = "rtic-usb-cdc-echo"
required-features = ["stm32f411", "rtic", "otg-fs", "usb_fs"] # stm32f411
required-features = ["stm32f411", "rtic1", "otg-fs", "usb_fs"] # stm32f411

[[example]]
name = "rtic2-systick"
required-features = ["rtic2"]

[[example]]
name = "sd"
Expand Down
54 changes: 54 additions & 0 deletions examples/rtic2-systick.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]

use defmt_rtt as _;
use panic_probe as _;
use rtic::app;
use rtic_monotonics::systick::*;
use stm32f4xx_hal::{
gpio::{Output, PC13},
pac,
prelude::*,
};

#[app(device = pac, dispatchers = [USART1], peripherals = true)]
mod app {
use super::*;

#[shared]
struct Shared {}

#[local]
struct Local {
led: PC13<Output>,
}

#[init]
fn init(ctx: init::Context) -> (Shared, Local) {
let rcc = ctx.device.RCC.constrain();
let freq = 48.MHz();
let _clocks = rcc.cfgr.sysclk(freq).freeze();

// Initialize the systick interrupt & obtain the token to prove that we did
let systick_mono_token = rtic_monotonics::create_systick_token!();
Systick::start(ctx.core.SYST, freq.to_Hz(), systick_mono_token);

let gpioc = ctx.device.GPIOC.split();
let led = gpioc.pc13.into_push_pull_output();
defmt::info!("Start");

tick::spawn().ok();
(Shared {}, Local { led })
}

#[task(local = [led, count: u32 = 0])]
async fn tick(ctx: tick::Context) {
loop {
ctx.local.led.toggle();
*ctx.local.count += 1;
defmt::info!("Tick {}", *ctx.local.count);
Systick::delay(500.millis()).await;
}
}
}
6 changes: 3 additions & 3 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ pub use crate::serial::TxListen as _stm32f4xx_hal_serial_TxListen;
pub use crate::spi::SpiExt as _stm32f4xx_hal_spi_SpiExt;
pub use crate::syscfg::SysCfgExt as _stm32f4xx_hal_syscfg_SysCfgExt;
pub use crate::time::U32Ext as _stm32f4xx_hal_time_U32Ext;
#[cfg(feature = "rtic")]
#[cfg(feature = "rtic1")]
pub use crate::timer::MonoTimer64Ext as _;
#[cfg(feature = "rtic")]
#[cfg(feature = "rtic1")]
pub use crate::timer::MonoTimerExt as _;
pub use crate::timer::PwmExt as _stm32f4xx_hal_timer_PwmExt;
#[cfg(feature = "rtic")]
#[cfg(feature = "rtic1")]
pub use crate::timer::SysMonoTimerExt as _stm32f4xx_hal_timer_SysMonoTimerExt;
pub use crate::timer::SysTimerExt as _stm32f4xx_hal_timer_SysCounterExt;
pub use crate::timer::TimerExt as _stm32f4xx_hal_timer_TimerExt;
Expand Down
4 changes: 2 additions & 2 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub use pwm::*;
pub mod pwm_input;
#[cfg(not(feature = "gpio-f410"))]
pub use pwm_input::PwmInput;
#[cfg(feature = "rtic")]
#[cfg(feature = "rtic1")]
pub mod monotonic;
#[cfg(feature = "rtic")]
#[cfg(feature = "rtic1")]
pub use monotonic::*;

mod hal_02;
Expand Down
2 changes: 1 addition & 1 deletion tools/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def main():

crate_info = cargo_meta["packages"][0]

features = ["{},usb_fs,can,i2s,fsmc_lcd,rtic,defmt".format(x)
features = ["{},usb_fs,can,i2s,fsmc_lcd,rtic1,defmt".format(x)
for x in crate_info["features"].keys()
if x.startswith("stm32f4")]

Expand Down