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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Implementation of RTIC Monotonic for TIM2 & TIM5 under `rtic` feature [#380]
- `IoPin` for `Output<OpenDrain>> <-> Input<Floating>>` [#374]

[#380]: https://github.com/stm32-rs/stm32f4xx-hal/pull/380
[#374]: https://github.com/stm32-rs/stm32f4xx-hal/pull/374

### Changed
Expand Down
18 changes: 13 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ targets = ["thumbv7em-none-eabihf"]
[dependencies]
bxcan = { version = "0.6", optional = true }
cortex-m = "0.7"
cortex-m-rt = ">=0.6.15, <0.8"
cortex-m-rt = "0.7"
nb = "1"
rand_core = "0.6"
rtcc = "0.2"
Expand All @@ -41,6 +41,8 @@ cast = { default-features = false, version = "0.3.0" }
void = { default-features = false, version = "1.0.2" }
embedded-hal = { features = ["unproven"], version = "0.2.6" }
display-interface = { version = "0.4.1", optional = true }
fugit = "0.3.0"
rtic-monotonic = { version = "0.1.0-rc.2", optional = true }

[dependencies.stm32_i2s_v12x]
version = "0.2.0"
Expand All @@ -56,8 +58,8 @@ embedded-graphics = "0.7.1"
usb-device = "0.2.5"
usbd-serial = "0.1.0"
micromath = "2"
cortex-m-rtic = "0.6.0-rc.2"
dwt-systick-monotonic = "0.1.0-alpha.3"
cortex-m-rtic = "0.6.0-rc.4"
dwt-systick-monotonic = "0.1.0-rc.2"
st7789 = "0.6.1"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
display-interface-spi = "0.4"
Expand Down Expand Up @@ -337,6 +339,8 @@ uart8 = []
uart9 = []
uart10 = []

rtic = ["rt", "rtic-monotonic"]

[profile.dev]
debug = true
lto = true
Expand Down Expand Up @@ -404,11 +408,15 @@ required-features = ["stm32f411", "rt", "i2s"]

[[example]]
name = "rtic"
required-features = ["gpiod"] # stm32f407
required-features = ["gpiod", "rtic"] # stm32f407

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

[[example]]
name = "adc_dma_rtic"
required-features = ["device-selected"] # stm32f401
required-features = ["device-selected", "rtic"] # stm32f401

[[example]]
name = "serial-9bit"
Expand Down
6 changes: 3 additions & 3 deletions examples/adc_dma_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use panic_semihosting as _;
mod app {
use cortex_m_semihosting::hprintln;
use dwt_systick_monotonic::DwtSystick;
use rtic::time::duration::Seconds;
pub use fugit::ExtU32;

use stm32f4xx_hal::{
adc::{
Expand Down Expand Up @@ -82,7 +82,7 @@ mod app {
let second_buffer = Some(cortex_m::singleton!(: [u16; 2] = [0; 2]).unwrap());
let transfer = Transfer::init_peripheral_to_memory(dma.0, adc, first_buffer, None, config);

polling::spawn_after(Seconds(1_u32)).ok();
polling::spawn_after(1.secs()).ok();

(
Shared { transfer },
Expand All @@ -101,7 +101,7 @@ mod app {
});
});

polling::spawn_after(Seconds(1_u32)).ok();
polling::spawn_after(1.secs()).ok();
}

#[task(binds = DMA2_STREAM0, shared = [transfer], local = [buffer])]
Expand Down
50 changes: 50 additions & 0 deletions examples/rtic-tick.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#![no_main]
#![no_std]

use panic_halt as _;

#[rtic::app(device = stm32f4xx_hal::pac, dispatchers = [USART1])]
mod app {
use fugit::ExtU32;
use stm32f4xx_hal::{
gpio::{gpioc::PC13, Output, PushPull},
pac,
prelude::*,
timer::{monotonic::MonoTimer, Timer},
};

#[shared]
struct Shared {}

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

#[monotonic(binds = TIM2, default = true)]
type MicrosecMono = MonoTimer<pac::TIM2, 1_000_000>;

#[init]
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
let rcc = ctx.device.RCC.constrain();
let clocks = rcc.cfgr.sysclk(8.mhz()).freeze();

let gpioc = ctx.device.GPIOC.split();
let led = gpioc.pc13.into_push_pull_output();

let mono = Timer::new(ctx.device.TIM2, &clocks).monotonic();
tick::spawn().ok();
(Shared {}, Local { led }, init::Monotonics(mono))
}

#[idle]
fn idle(_: idle::Context) -> ! {
loop {}
}

#[task(local = [led])]
fn tick(ctx: tick::Context) {
tick::spawn_after(1.secs()).ok();
ctx.local.led.toggle();
}
}
Loading