Skip to content

Commit 23b372d

Browse files
committed
Update to critical-section 1.0, atomic-polyfill 1.0
1 parent 6ffca81 commit 23b372d

File tree

15 files changed

+85
-29
lines changed

15 files changed

+85
-29
lines changed

.vscode/settings.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"editor.formatOnSave": true,
3-
"rust-analyzer.checkOnSave.allFeatures": false,
43
"rust-analyzer.checkOnSave.allTargets": false,
54
"rust-analyzer.checkOnSave.noDefaultFeatures": true,
6-
"rust-analyzer.cargo.allFeatures": false,
75
"rust-analyzer.cargo.noDefaultFeatures": true,
86
"rust-analyzer.procMacro.enable": true,
97
"rust-analyzer.cargo.target": "thumbv7em-none-eabi",

embassy-cortex-m/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ embassy-util = { version = "0.1.0", path = "../embassy-util" }
3939
embassy-executor = { version = "0.1.0", path = "../embassy-executor"}
4040
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
4141
embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"}
42-
atomic-polyfill = "0.1.5"
43-
critical-section = "0.2.5"
42+
atomic-polyfill = "1.0.1"
43+
critical-section = "1.0"
4444
cfg-if = "1.0.0"
4545
cortex-m = "0.7.3"
4646

embassy-embedded-hal/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ name = "embassy-embedded-hal"
33
version = "0.1.0"
44
edition = "2021"
55

6+
7+
[package.metadata.embassy_docs]
8+
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/"
9+
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/"
10+
features = ["nightly"]
11+
flavors = [
12+
{ name = "default", target = "x86_64-unknown-linux-gnu", features = ["std"] },
13+
]
14+
15+
616
[features]
717
std = []
818
# Enable nightly-only features

embassy-executor/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ embedded-hal-async = { version = "0.1.0-alpha.1", optional = true}
6060

6161
futures-util = { version = "0.3.17", default-features = false }
6262
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
63-
atomic-polyfill = "0.1.5"
64-
critical-section = "0.2.5"
63+
atomic-polyfill = "1.0.1"
64+
critical-section = "1.0"
6565
cfg-if = "1.0.0"
6666

6767
# WASM dependencies

embassy-nrf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ log = { version = "0.4.14", optional = true }
8282
cortex-m-rt = ">=0.6.15,<0.8"
8383
cortex-m = "0.7.3"
8484
futures = { version = "0.3.17", default-features = false }
85-
critical-section = "0.2.5"
85+
critical-section = "1.0"
8686
rand_core = "0.6.3"
8787
fixed = "1.10.0"
8888
embedded-storage = "0.3.0"

embassy-rp/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features =
3333
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
3434
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
3535
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]}
36-
atomic-polyfill = "0.1.5"
36+
atomic-polyfill = "1.0.1"
3737
defmt = { version = "0.3", optional = true }
3838
log = { version = "0.4.14", optional = true }
3939
cortex-m-rt = ">=0.6.15,<0.8"
4040
cortex-m = "0.7.3"
41-
critical-section = "0.2.5"
41+
critical-section = "1.0"
4242
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
4343

4444
rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="9ad7223a48a065e612bc7dc7be5bf5bd0b41cfc4", features = ["rt"] }

embassy-stm32/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
5555
rand_core = "0.6.3"
5656
sdio-host = "0.5.0"
5757
embedded-sdmmc = { git = "https://github.com/thalesfragoso/embedded-sdmmc-rs", branch = "async", optional = true }
58-
critical-section = "0.2.5"
58+
critical-section = "1.0"
5959
bare-metal = "1.0.0"
60-
atomic-polyfill = "0.1.5"
60+
atomic-polyfill = "1.0.1"
6161
stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"] }
6262
vcell = "0.1.3"
6363
bxcan = "0.7.0"

embassy-usb-hid/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[package.metadata.embassy_docs]
77
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-hid-v$VERSION/embassy-usb-hid/src/"
88
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-hid/src/"
9-
features = ["defmt", "embassy-executor/time-tick-1mhz"]
9+
features = ["defmt"]
1010
flavors = [
1111
{ name = "default", target = "thumbv7em-none-eabihf" },
1212
]

embassy-util/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ defmt = { version = "0.3", optional = true }
1919
log = { version = "0.4.14", optional = true }
2020

2121
futures-util = { version = "0.3.17", default-features = false }
22-
atomic-polyfill = "0.1.5"
23-
critical-section = "0.2.5"
22+
atomic-polyfill = "1.0.1"
23+
critical-section = "1.0"
2424
heapless = "0.7.5"
2525
cfg-if = "1.0.0"
2626
embedded-io = "0.3.0"

examples/nrf/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ embedded-io = "0.3.0"
2121
defmt = "0.3"
2222
defmt-rtt = "0.3"
2323

24-
cortex-m = "0.7.3"
24+
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
2525
cortex-m-rt = "0.7.0"
2626
panic-probe = { version = "0.3", features = ["print-defmt"] }
2727
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
2828
rand = { version = "0.8.4", default-features = false }
2929
embedded-storage = "0.3.0"
3030
usbd-hid = "0.5.2"
3131
serde = { version = "1.0.136", default-features = false }
32+
33+
[patch.crates-io]
34+
cortex-m = { git = "https://github.com/rust-embedded/cortex-m", rev = "df9a479f8a6260feb7e9fc05fa0e001f555b9340"}
35+
defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "372c0cc9951bdf596058b3396e62da6f67fb63bd"}
36+
defmt-macros = { git = "https://github.com/knurling-rs/defmt", rev = "372c0cc9951bdf596058b3396e62da6f67fb63bd"}
37+
defmt = { git = "https://github.com/knurling-rs/defmt", rev = "372c0cc9951bdf596058b3396e62da6f67fb63bd"}

examples/rp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version = "0.1.0"
88
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
99
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] }
1010
embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] }
11-
atomic-polyfill = "0.1.5"
11+
atomic-polyfill = "1.0.1"
1212

1313
defmt = "0.3"
1414
defmt-rtt = "0.3"

examples/rp/src/bin/blinky.rs

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,66 @@
22
#![no_main]
33
#![feature(type_alias_impl_trait)]
44

5-
use defmt::*;
5+
use defmt::{unwrap, *};
66
use embassy_executor::executor::Spawner;
77
use embassy_executor::time::{Duration, Timer};
88
use embassy_rp::{gpio, Peripherals};
9-
use gpio::{Level, Output};
9+
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
10+
use embassy_util::mutex::Mutex;
11+
use gpio::{Input, Level, Output, Pull};
1012
use {defmt_rtt as _, panic_probe as _};
1113

12-
#[embassy_executor::main]
13-
async fn main(_spawner: Spawner, p: Peripherals) {
14-
let mut led = Output::new(p.PIN_25, Level::Low);
14+
static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(20);
1515

16+
#[embassy_executor::task]
17+
async fn blinker(mut led: Output<'static, embassy_rp::peripherals::PIN_15>) {
18+
let mut delay: u32;
1619
loop {
17-
info!("led on!");
20+
{
21+
let m = MUTEX.lock().await;
22+
delay = *m;
23+
}
1824
led.set_high();
19-
Timer::after(Duration::from_secs(1)).await;
20-
21-
info!("led off!");
25+
Timer::after(Duration::from_millis(delay as u64)).await;
2226
led.set_low();
23-
Timer::after(Duration::from_secs(1)).await;
27+
Timer::after(Duration::from_millis(delay as u64)).await;
2428
}
2529
}
30+
31+
#[embassy_executor::task]
32+
async fn decrease_speed(mut button: Input<'static, embassy_rp::peripherals::PIN_10>) {
33+
loop {
34+
button.wait_for_falling_edge().await;
35+
{
36+
let mut m = MUTEX.lock().await;
37+
*m += 20;
38+
}
39+
}
40+
}
41+
42+
#[embassy_executor::task]
43+
async fn increase_speed(mut button: Input<'static, embassy_rp::peripherals::PIN_11>) {
44+
loop {
45+
button.wait_for_falling_edge().await;
46+
{
47+
let mut m = MUTEX.lock().await;
48+
*m -= 20;
49+
}
50+
}
51+
}
52+
53+
#[embassy_executor::main]
54+
async fn main(spawner: Spawner, p: Peripherals) {
55+
let led = Output::new(p.PIN_15, Level::Low);
56+
let mut button1 = Input::new(p.PIN_11, Pull::Up);
57+
let mut button2 = Input::new(p.PIN_10, Pull::Up);
58+
59+
loop {
60+
button1.wait_for_falling_edge().await;
61+
info!("EDGE");
62+
}
63+
64+
unwrap!(spawner.spawn(blinker(led)));
65+
unwrap!(spawner.spawn(decrease_speed(button2)));
66+
unwrap!(spawner.spawn(increase_speed(button1)));
67+
}

examples/stm32f7/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
2121
heapless = { version = "0.7.5", default-features = false }
2222
nb = "1.0.0"
2323
rand_core = "0.6.3"
24-
critical-section = "0.2.3"
24+
critical-section = "1.0"
2525
embedded-storage = "0.3.0"

examples/stm32h7/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ panic-probe = { version = "0.3", features = ["print-defmt"] }
2323
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
2424
heapless = { version = "0.7.5", default-features = false }
2525
rand_core = "0.6.3"
26-
critical-section = "0.2.5"
26+
critical-section = "1.0"
2727
micromath = "2.0.0"
2828
stm32-fmc = "0.2.4"
2929
embedded-storage = "0.3.0"

examples/wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ wasm-logger = "0.2.0"
1414
wasm-bindgen = "0.2"
1515
web-sys = { version = "0.3", features = ["Document", "Element", "HtmlElement", "Node", "Window" ] }
1616
log = "0.4.11"
17-
critical-section = "0.2.5"
17+
critical-section = "1.0"

0 commit comments

Comments
 (0)