Skip to content

Commit 1830113

Browse files
bors[bot]alexxy
andauthored
Merge #551
551: Rtic examples r=burrbull a=alexxy Co-authored-by: Alexey Shvetsov <[email protected]>
2 parents 6c585f5 + 0a38431 commit 1830113

File tree

5 files changed

+516
-22
lines changed

5 files changed

+516
-22
lines changed

CHANGELOG.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2424
- Bump `embedded-hal` to `1.0.0-alpha.8` [#510]
2525
- Update `bxcan`, `rtic` and other dependencies [#519]
2626
- Bump `synopsys-usb-otg` to `0.3.1` [#535]
27+
- Renamed and updated rtic-button example (was rtic) [#551]
2728

2829
### Removed
2930
- `i2s-audio-out-dma.rs` example, too difficult to fix.
@@ -34,17 +35,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3435

3536
### Added
3637

37-
- Serial Tx, Rx containing pins [#514] [#515] [#540]
38-
- example of using ft6x06 touchscreen driver for stm32f412 and stm32f413 [#527]
39-
- Serial Tx, Rx containing pins [#514] [#515]
40-
- Implementation of From trait for Pin-to-PartiallyErasedPin [#507]
41-
- Implementation of From trait for Pin-to-ErasedPin [#507]
42-
- Implementation of From trait for PartiallyErasedPin-to-ErasedPin [#507]
43-
- `SysMonoTimerExt` helper trait, `Pwm::(get/set)_duty_time` [#497]
44-
- example of using i2s in out with rtic and interrupt.
45-
- example of using USB CDC with interrupts.
46-
- Added non-blocking I2C based on DMA [#534]
47-
- Added Transactional I2C API [#542]
38+
- Serial Tx, Rx containing pins [#514] [#515] [#540]
39+
- example of using ft6x06 touchscreen driver for stm32f412 and stm32f413 [#527]
40+
- Serial Tx, Rx containing pins [#514] [#515]
41+
- Implementation of From trait for Pin-to-PartiallyErasedPin [#507]
42+
- Implementation of From trait for Pin-to-ErasedPin [#507]
43+
- Implementation of From trait for PartiallyErasedPin-to-ErasedPin [#507]
44+
- `SysMonoTimerExt` helper trait, `Pwm::(get/set)_duty_time` [#497]
45+
- example of using i2s in out with rtic and interrupt.
46+
- example of using USB CDC with interrupts.
47+
- Added non-blocking I2C based on DMA [#534]
48+
- Added Transactional I2C API [#542]
49+
- Added rtic-usart-shell example [#551]
50+
- Added rtic-usart-shell-ssd1306 example [#551]
51+
4852

4953
[#481]: https://github.com/stm32-rs/stm32f4xx-hal/pull/481
5054
[#489]: https://github.com/stm32-rs/stm32f4xx-hal/pull/489
@@ -64,6 +68,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6468
[#540]: https://github.com/stm32-rs/stm32f4xx-hal/pull/540
6569
[#542]: https://github.com/stm32-rs/stm32f4xx-hal/pull/542
6670
[#527]: https://github.com/stm32-rs/stm32f4xx-hal/pull/527
71+
[#551]: https://github.com/stm32-rs/stm32f4xx-hal/pull/551
6772

6873
## [v0.13.2] - 2022-05-16
6974

Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ ws2812-spi = { version = "0.4.0", features = [] }
8383
hd44780-driver = "0.4.0"
8484
display-interface = "0.4"
8585
ft6x06 = "0.1.2"
86+
ushell = "0.3.5"
8687

8788
[dev-dependencies.time]
8889
version = "0.3"
@@ -438,13 +439,21 @@ name = "i2s-rtic-audio-in-out"
438439
required-features = ["stm32f411", "i2s", "rtic"]
439440

440441
[[example]]
441-
name = "rtic"
442-
required-features = ["gpiod", "rtic"] # stm32f407
442+
name = "rtic-button"
443+
required-features = ["stm32f411", "rtic"] # stm32f411
443444

444445
[[example]]
445446
name = "rtic-tick"
446447
required-features = ["tim2", "rtic"]
447448

449+
[[example]]
450+
name = "rtic-usart-shell"
451+
required-features = ["stm32f411", "rtic"] # stm32f411
452+
453+
[[example]]
454+
name = "rtic-usart-shell-ssd1306"
455+
required-features = ["stm32f411", "rtic"] # stm32f411
456+
448457
[[example]]
449458
name = "adc_dma_rtic"
450459
required-features = ["device-selected", "rtic"] # stm32f401

examples/rtic.rs renamed to examples/rtic-button.rs

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
#![deny(unsafe_code)]
22
#![deny(warnings)]
3-
#![no_std]
43
#![no_main]
4+
#![no_std]
55

66
use panic_halt as _;
77

8-
#[rtic::app(device = stm32f4xx_hal::pac)]
8+
#[rtic::app(device = stm32f4xx_hal::pac, peripherals = true)]
99
mod app {
1010
use stm32f4xx_hal::{
11-
gpio::{Edge, Input, Output, PushPull, PA0, PC13},
11+
gpio::{gpioa::PA0, gpioc::PC13, Edge, Input, Output, PushPull},
1212
prelude::*,
1313
};
14-
14+
const SYSFREQ: u32 = 100_000_000;
15+
// Shared resources go here
1516
#[shared]
1617
struct Shared {}
1718

19+
// Local resources go here
1820
#[local]
1921
struct Local {
2022
button: PA0<Input>,
@@ -23,18 +25,41 @@ mod app {
2325

2426
#[init]
2527
fn init(mut ctx: init::Context) -> (Shared, Local, init::Monotonics) {
28+
// syscfg
2629
let mut syscfg = ctx.device.SYSCFG.constrain();
27-
28-
let gpioc = ctx.device.GPIOC.split();
29-
let led = gpioc.pc13.into_push_pull_output();
30-
30+
// clocks
31+
let rcc = ctx.device.RCC.constrain();
32+
let _clocks = rcc.cfgr.sysclk(SYSFREQ.Hz()).use_hse(25.MHz()).freeze();
33+
// gpio ports A and C
3134
let gpioa = ctx.device.GPIOA.split();
35+
let gpioc = ctx.device.GPIOC.split();
36+
// button
3237
let mut button = gpioa.pa0.into_pull_up_input();
3338
button.make_interrupt_source(&mut syscfg);
3439
button.enable_interrupt(&mut ctx.device.EXTI);
3540
button.trigger_on_edge(&mut ctx.device.EXTI, Edge::Falling);
41+
// led
42+
let led = gpioc.pc13.into_push_pull_output();
43+
44+
(
45+
Shared {
46+
// Initialization of shared resources go here
47+
},
48+
Local {
49+
// Initialization of local resources go here
50+
button,
51+
led,
52+
},
53+
init::Monotonics(),
54+
)
55+
}
3656

37-
(Shared {}, Local { button, led }, init::Monotonics())
57+
// Optional idle, can be removed if not needed.
58+
#[idle]
59+
fn idle(_: idle::Context) -> ! {
60+
loop {
61+
continue;
62+
}
3863
}
3964

4065
#[task(binds = EXTI0, local = [button, led])]

0 commit comments

Comments
 (0)