aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias <[email protected]>2022-10-11 09:19:55 +0200
committerMathias <[email protected]>2022-10-11 09:19:55 +0200
commitaff265a7f59acf84216a8127df23fd89cb62edbd (patch)
tree0e629de56f19b09efdb1226f9f7e5f1b1d00b28a
parent79cee7415110817b529a68848247a86708bcd6af (diff)
parent9d5b524bb083310c2e1753859ebc9fca080a4238 (diff)
Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-stm32/rtc
-rw-r--r--.github/workflows/doc.yml86
-rw-r--r--.github/workflows/rust.yml2
-rw-r--r--docs/modules/ROOT/examples/basic/Cargo.toml1
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml1
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml1
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml1
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml1
-rw-r--r--embassy-boot/boot/Cargo.toml1
-rw-r--r--embassy-boot/nrf/Cargo.toml1
-rw-r--r--embassy-boot/stm32/Cargo.toml1
-rw-r--r--embassy-cortex-m/Cargo.toml1
-rw-r--r--embassy-embedded-hal/Cargo.toml3
-rw-r--r--embassy-executor/Cargo.toml3
-rw-r--r--embassy-hal-common/Cargo.toml1
-rw-r--r--embassy-lora/Cargo.toml1
-rw-r--r--embassy-macros/Cargo.toml1
-rw-r--r--embassy-net/Cargo.toml1
-rw-r--r--embassy-nrf/Cargo.toml1
-rw-r--r--embassy-rp/Cargo.toml1
-rw-r--r--embassy-rp/src/gpio.rs32
-rw-r--r--embassy-stm32/Cargo.toml4
-rw-r--r--embassy-stm32/src/adc/mod.rs9
-rw-r--r--embassy-stm32/src/adc/v2.rs161
-rw-r--r--embassy-stm32/src/adc/v4.rs16
-rw-r--r--embassy-stm32/src/flash/mod.rs27
-rw-r--r--embassy-stm32/src/usart/mod.rs104
-rw-r--r--embassy-sync/Cargo.toml10
-rw-r--r--embassy-sync/README.md24
-rw-r--r--embassy-sync/src/pubsub/publisher.rs8
-rw-r--r--embassy-time/Cargo.toml1
-rw-r--r--embassy-usb-driver/Cargo.toml3
-rw-r--r--embassy-usb/Cargo.toml3
-rw-r--r--examples/boot/application/nrf/Cargo.toml1
-rw-r--r--examples/boot/application/stm32f3/Cargo.toml1
-rw-r--r--examples/boot/application/stm32f3/src/bin/a.rs2
-rw-r--r--examples/boot/application/stm32f7/Cargo.toml1
-rw-r--r--examples/boot/application/stm32f7/src/bin/a.rs2
-rw-r--r--examples/boot/application/stm32h7/Cargo.toml1
-rw-r--r--examples/boot/application/stm32h7/src/bin/a.rs2
-rw-r--r--examples/boot/application/stm32l0/Cargo.toml1
-rw-r--r--examples/boot/application/stm32l0/src/bin/a.rs2
-rw-r--r--examples/boot/application/stm32l1/Cargo.toml1
-rw-r--r--examples/boot/application/stm32l1/src/bin/a.rs2
-rw-r--r--examples/boot/application/stm32l4/Cargo.toml1
-rw-r--r--examples/boot/application/stm32l4/src/bin/a.rs2
-rw-r--r--examples/boot/application/stm32wl/Cargo.toml1
-rw-r--r--examples/boot/application/stm32wl/src/bin/a.rs2
-rw-r--r--examples/boot/bootloader/nrf/Cargo.toml1
-rw-r--r--examples/boot/bootloader/stm32/Cargo.toml1
-rw-r--r--examples/boot/bootloader/stm32/src/main.rs2
-rw-r--r--examples/nrf-rtos-trace/Cargo.toml1
-rw-r--r--examples/nrf/Cargo.toml1
-rw-r--r--examples/rp/Cargo.toml3
-rw-r--r--examples/rp/src/bin/i2c_blocking.rs70
-rw-r--r--examples/std/Cargo.toml1
-rw-r--r--examples/stm32f0/Cargo.toml1
-rw-r--r--examples/stm32f1/Cargo.toml1
-rw-r--r--examples/stm32f2/Cargo.toml1
-rw-r--r--examples/stm32f3/Cargo.toml1
-rw-r--r--examples/stm32f3/src/bin/flash.rs2
-rw-r--r--examples/stm32f4/Cargo.toml1
-rw-r--r--examples/stm32f4/src/bin/adc.rs25
-rw-r--r--examples/stm32f4/src/bin/flash.rs2
-rw-r--r--examples/stm32f7/Cargo.toml1
-rw-r--r--examples/stm32f7/src/bin/flash.rs2
-rw-r--r--examples/stm32g0/Cargo.toml1
-rw-r--r--examples/stm32g4/Cargo.toml1
-rw-r--r--examples/stm32h7/Cargo.toml1
-rw-r--r--examples/stm32h7/src/bin/flash.rs2
-rw-r--r--examples/stm32l0/Cargo.toml1
-rw-r--r--examples/stm32l0/src/bin/flash.rs2
-rw-r--r--examples/stm32l1/Cargo.toml1
-rw-r--r--examples/stm32l1/src/bin/flash.rs2
-rw-r--r--examples/stm32l4/Cargo.toml1
-rw-r--r--examples/stm32l5/Cargo.toml1
-rw-r--r--examples/stm32u5/Cargo.toml1
-rw-r--r--examples/stm32wb/Cargo.toml1
-rw-r--r--examples/stm32wl/Cargo.toml1
-rw-r--r--examples/stm32wl/src/bin/flash.rs2
-rw-r--r--examples/wasm/Cargo.toml1
-rw-r--r--stm32-gen-features/Cargo.toml1
-rw-r--r--stm32-metapac-gen/Cargo.toml1
-rw-r--r--tests/rp/Cargo.toml1
-rw-r--r--tests/stm32/Cargo.toml1
-rw-r--r--xtask/Cargo.toml1
85 files changed, 531 insertions, 143 deletions
diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml
new file mode 100644
index 000000000..eb460e738
--- /dev/null
+++ b/.github/workflows/doc.yml
@@ -0,0 +1,86 @@
1name: Docs
2
3on:
4 push:
5 branches: [master]
6
7env:
8 BUILDER_THREADS: '1'
9
10jobs:
11 doc:
12 runs-on: ubuntu-latest
13
14 # Since stm32 crates take SO LONG to build, we split them
15 # into a separate job. This way it doesn't slow down updating
16 # the rest.
17 strategy:
18 matrix:
19 crates:
20 - stm32
21 - rest
22
23 # This will ensure at most one doc build job is running at a time
24 # (for stm32 and non-stm32 independently).
25 # If another job is already running, the new job will wait.
26 # If another job is already waiting, it'll be canceled.
27 # This means some commits will be skipped, but that's fine because
28 # we only care that the latest gets built.
29 concurrency: doc-${{ matrix.crates }}
30
31 steps:
32 - uses: actions/checkout@v2
33 with:
34 submodules: true
35 - name: Install Rust targets
36 run: |
37 rustup target add x86_64-unknown-linux-gnu
38 rustup target add wasm32-unknown-unknown
39 rustup target add thumbv6m-none-eabi
40 rustup target add thumbv7m-none-eabi
41 rustup target add thumbv7em-none-eabi
42 rustup target add thumbv7em-none-eabihf
43 rustup target add thumbv8m.base-none-eabi
44 rustup target add thumbv8m.main-none-eabi
45 rustup target add thumbv8m.main-none-eabihf
46
47 - name: Install docserver
48 run: |
49 wget -q -O /usr/local/bin/builder "https://github.com/embassy-rs/docserver/releases/download/v0.3/builder"
50 chmod +x /usr/local/bin/builder
51
52 - name: build-stm32
53 if: ${{ matrix.crates=='stm32' }}
54 run: |
55 mkdir crates
56 builder ./embassy-stm32 crates/embassy-stm32/git.zup
57 builder ./stm32-metapac crates/stm32-metapac/git.zup
58
59 - name: build-rest
60 if: ${{ matrix.crates=='rest' }}
61 run: |
62 mkdir crates
63 builder ./embassy-boot/boot crates/embassy-boot/git.zup
64 builder ./embassy-boot/nrf crates/embassy-boot-nrf/git.zup
65 builder ./embassy-boot/stm32 crates/embassy-boot-stm32/git.zup
66 builder ./embassy-cortex-m crates/embassy-cortex-m/git.zup
67 builder ./embassy-embedded-hal crates/embassy-embedded-hal/git.zup
68 builder ./embassy-executor crates/embassy-executor/git.zup
69 builder ./embassy-futures crates/embassy-futures/git.zup
70 builder ./embassy-lora crates/embassy-lora/git.zup
71 builder ./embassy-net crates/embassy-net/git.zup
72 builder ./embassy-nrf crates/embassy-nrf/git.zup
73 builder ./embassy-rp crates/embassy-rp/git.zup
74 builder ./embassy-sync crates/embassy-sync/git.zup
75 builder ./embassy-time crates/embassy-time/git.zup
76 builder ./embassy-usb crates/embassy-usb/git.zup
77 builder ./embassy-usb-driver crates/embassy-usb-driver/git.zup
78
79 - name: upload
80 run: |
81 mkdir -p ~/.kube
82 echo "${{secrets.KUBECONFIG}}" > ~/.kube/config
83 POD=$(kubectl -n embassy get po -l app=docserver -o jsonpath={.items[0].metadata.name})
84 kubectl cp crates $POD:/data
85
86 \ No newline at end of file
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index d2e8e316b..b93c8783d 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -11,7 +11,7 @@ env:
11 11
12jobs: 12jobs:
13 all: 13 all:
14 runs-on: ubuntu-20.04 14 runs-on: ubuntu-latest
15 needs: [build-nightly, build-stable, test] 15 needs: [build-nightly, build-stable, test]
16 steps: 16 steps:
17 - name: Done 17 - name: Done
diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml
index ae124a871..c13f546e2 100644
--- a/docs/modules/ROOT/examples/basic/Cargo.toml
+++ b/docs/modules/ROOT/examples/basic/Cargo.toml
@@ -3,6 +3,7 @@ authors = ["Dario Nieuwenhuis <[email protected]>"]
3edition = "2018" 3edition = "2018"
4name = "embassy-basic-example" 4name = "embassy-basic-example"
5version = "0.1.0" 5version = "0.1.0"
6license = "MIT OR Apache-2.0"
6 7
7[dependencies] 8[dependencies]
8embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] } 9embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] }
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml
index e2933076f..c9a963d4d 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml
@@ -2,6 +2,7 @@
2name = "blinky-async" 2name = "blinky-async"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7cortex-m = "0.7" 8cortex-m = "0.7"
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml
index dbd3aba8b..f86361dd5 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml
@@ -2,6 +2,7 @@
2name = "blinky-hal" 2name = "blinky-hal"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7cortex-m = "0.7" 8cortex-m = "0.7"
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml
index 0dd326015..9733658b6 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml
@@ -2,6 +2,7 @@
2name = "blinky-irq" 2name = "blinky-irq"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7cortex-m = "0.7" 8cortex-m = "0.7"
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml
index e7f4f5d1f..a077f1828 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml
@@ -2,6 +2,7 @@
2name = "blinky-pac" 2name = "blinky-pac"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7cortex-m = "0.7" 8cortex-m = "0.7"
diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml
index a42f88688..54c67a375 100644
--- a/embassy-boot/boot/Cargo.toml
+++ b/embassy-boot/boot/Cargo.toml
@@ -3,6 +3,7 @@ edition = "2021"
3name = "embassy-boot" 3name = "embassy-boot"
4version = "0.1.0" 4version = "0.1.0"
5description = "Bootloader using Embassy" 5description = "Bootloader using Embassy"
6license = "MIT OR Apache-2.0"
6 7
7[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-v$VERSION/embassy-boot/boot/src/" 9src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-v$VERSION/embassy-boot/boot/src/"
diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml
index 234393e7c..c6af70144 100644
--- a/embassy-boot/nrf/Cargo.toml
+++ b/embassy-boot/nrf/Cargo.toml
@@ -3,6 +3,7 @@ edition = "2021"
3name = "embassy-boot-nrf" 3name = "embassy-boot-nrf"
4version = "0.1.0" 4version = "0.1.0"
5description = "Bootloader lib for nRF chips" 5description = "Bootloader lib for nRF chips"
6license = "MIT OR Apache-2.0"
6 7
7[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-nrf-v$VERSION/embassy-boot/nrf/src/" 9src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-nrf-v$VERSION/embassy-boot/nrf/src/"
diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml
index ad4657e0d..9d12c6cfd 100644
--- a/embassy-boot/stm32/Cargo.toml
+++ b/embassy-boot/stm32/Cargo.toml
@@ -3,6 +3,7 @@ edition = "2021"
3name = "embassy-boot-stm32" 3name = "embassy-boot-stm32"
4version = "0.1.0" 4version = "0.1.0"
5description = "Bootloader lib for STM32 chips" 5description = "Bootloader lib for STM32 chips"
6license = "MIT OR Apache-2.0"
6 7
7[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-nrf-v$VERSION/embassy-boot/stm32/src/" 9src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-nrf-v$VERSION/embassy-boot/stm32/src/"
diff --git a/embassy-cortex-m/Cargo.toml b/embassy-cortex-m/Cargo.toml
index 7efced669..5c5718d50 100644
--- a/embassy-cortex-m/Cargo.toml
+++ b/embassy-cortex-m/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-cortex-m" 2name = "embassy-cortex-m"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[package.metadata.embassy_docs] 7[package.metadata.embassy_docs]
7src_base = "https://github.com/embassy-rs/embassy/blob/embassy-cortex-m-v$VERSION/embassy-cortex-m/src/" 8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-cortex-m-v$VERSION/embassy-cortex-m/src/"
diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml
index fe8fac7c8..d0be6d195 100644
--- a/embassy-embedded-hal/Cargo.toml
+++ b/embassy-embedded-hal/Cargo.toml
@@ -2,13 +2,14 @@
2name = "embassy-embedded-hal" 2name = "embassy-embedded-hal"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6 7
7[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/" 9src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/"
9src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/" 10src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/"
10features = ["nightly", "std"] 11features = ["nightly", "std"]
11target = "thumbv7em-none-eabi" 12target = "x86_64-unknown-linux-gnu"
12 13
13[features] 14[features]
14std = [] 15std = []
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml
index fa3d0b2b6..d0f51646d 100644
--- a/embassy-executor/Cargo.toml
+++ b/embassy-executor/Cargo.toml
@@ -2,12 +2,13 @@
2name = "embassy-executor" 2name = "embassy-executor"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6 7
7[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/" 9src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/"
9src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/" 10src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/"
10features = ["nightly", "defmt", "unstable-traits"] 11features = ["nightly", "defmt"]
11flavors = [ 12flavors = [
12 { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, 13 { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] },
13 { name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] }, 14 { name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] },
diff --git a/embassy-hal-common/Cargo.toml b/embassy-hal-common/Cargo.toml
index 58f0af6ab..e8617c02f 100644
--- a/embassy-hal-common/Cargo.toml
+++ b/embassy-hal-common/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-hal-common" 2name = "embassy-hal-common"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[features] 7[features]
7 8
diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml
index dcb0d8245..0e7a982a1 100644
--- a/embassy-lora/Cargo.toml
+++ b/embassy-lora/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-lora" 2name = "embassy-lora"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[package.metadata.embassy_docs] 7[package.metadata.embassy_docs]
7src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/embassy-lora/src/" 8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/embassy-lora/src/"
diff --git a/embassy-macros/Cargo.toml b/embassy-macros/Cargo.toml
index 03fa79dd8..91d5ec8a3 100644
--- a/embassy-macros/Cargo.toml
+++ b/embassy-macros/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-macros" 2name = "embassy-macros"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7syn = { version = "1.0.76", features = ["full", "extra-traits"] } 8syn = { version = "1.0.76", features = ["full", "extra-traits"] }
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml
index d5b13204e..967ef26a7 100644
--- a/embassy-net/Cargo.toml
+++ b/embassy-net/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-net" 2name = "embassy-net"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6 7
7[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml
index 58b820242..5459bc90c 100644
--- a/embassy-nrf/Cargo.toml
+++ b/embassy-nrf/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-nrf" 2name = "embassy-nrf"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[package.metadata.embassy_docs] 7[package.metadata.embassy_docs]
7src_base = "https://github.com/embassy-rs/embassy/blob/embassy-nrf-v$VERSION/embassy-nrf/src/" 8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-nrf-v$VERSION/embassy-nrf/src/"
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml
index 3aca5dbb4..c56858415 100644
--- a/embassy-rp/Cargo.toml
+++ b/embassy-rp/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-rp" 2name = "embassy-rp"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[package.metadata.embassy_docs] 7[package.metadata.embassy_docs]
7src_base = "https://github.com/embassy-rs/embassy/blob/embassy-rp-v$VERSION/embassy-rp/src/" 8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-rp-v$VERSION/embassy-rp/src/"
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index a28bae96b..f79f592b4 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -599,12 +599,12 @@ pub(crate) mod sealed {
599 fn pin_bank(&self) -> u8; 599 fn pin_bank(&self) -> u8;
600 600
601 #[inline] 601 #[inline]
602 fn pin(&self) -> u8 { 602 fn _pin(&self) -> u8 {
603 self.pin_bank() & 0x1f 603 self.pin_bank() & 0x1f
604 } 604 }
605 605
606 #[inline] 606 #[inline]
607 fn bank(&self) -> Bank { 607 fn _bank(&self) -> Bank {
608 if self.pin_bank() & 0x20 == 0 { 608 if self.pin_bank() & 0x20 == 0 {
609 Bank::Bank0 609 Bank::Bank0
610 } else { 610 } else {
@@ -613,35 +613,35 @@ pub(crate) mod sealed {
613 } 613 }
614 614
615 fn io(&self) -> pac::io::Gpio { 615 fn io(&self) -> pac::io::Gpio {
616 let block = match self.bank() { 616 let block = match self._bank() {
617 Bank::Bank0 => crate::pac::IO_BANK0, 617 Bank::Bank0 => crate::pac::IO_BANK0,
618 Bank::Qspi => crate::pac::IO_QSPI, 618 Bank::Qspi => crate::pac::IO_QSPI,
619 }; 619 };
620 block.gpio(self.pin() as _) 620 block.gpio(self._pin() as _)
621 } 621 }
622 622
623 fn pad_ctrl(&self) -> Reg<pac::pads::regs::GpioCtrl, RW> { 623 fn pad_ctrl(&self) -> Reg<pac::pads::regs::GpioCtrl, RW> {
624 let block = match self.bank() { 624 let block = match self._bank() {
625 Bank::Bank0 => crate::pac::PADS_BANK0, 625 Bank::Bank0 => crate::pac::PADS_BANK0,
626 Bank::Qspi => crate::pac::PADS_QSPI, 626 Bank::Qspi => crate::pac::PADS_QSPI,
627 }; 627 };
628 block.gpio(self.pin() as _) 628 block.gpio(self._pin() as _)
629 } 629 }
630 630
631 fn sio_out(&self) -> pac::sio::Gpio { 631 fn sio_out(&self) -> pac::sio::Gpio {
632 SIO.gpio_out(self.bank() as _) 632 SIO.gpio_out(self._bank() as _)
633 } 633 }
634 634
635 fn sio_oe(&self) -> pac::sio::Gpio { 635 fn sio_oe(&self) -> pac::sio::Gpio {
636 SIO.gpio_oe(self.bank() as _) 636 SIO.gpio_oe(self._bank() as _)
637 } 637 }
638 638
639 fn sio_in(&self) -> Reg<u32, RW> { 639 fn sio_in(&self) -> Reg<u32, RW> {
640 SIO.gpio_in(self.bank() as _) 640 SIO.gpio_in(self._bank() as _)
641 } 641 }
642 642
643 fn int_proc(&self) -> pac::io::Int { 643 fn int_proc(&self) -> pac::io::Int {
644 let io_block = match self.bank() { 644 let io_block = match self._bank() {
645 Bank::Bank0 => crate::pac::IO_BANK0, 645 Bank::Bank0 => crate::pac::IO_BANK0,
646 Bank::Qspi => crate::pac::IO_QSPI, 646 Bank::Qspi => crate::pac::IO_QSPI,
647 }; 647 };
@@ -658,6 +658,18 @@ pub trait Pin: Peripheral<P = Self> + Into<AnyPin> + sealed::Pin + Sized + 'stat
658 pin_bank: self.pin_bank(), 658 pin_bank: self.pin_bank(),
659 } 659 }
660 } 660 }
661
662 /// Returns the pin number within a bank
663 #[inline]
664 fn pin(&self) -> u8 {
665 self._pin()
666 }
667
668 /// Returns the bank of this pin
669 #[inline]
670 fn bank(&self) -> Bank {
671 self._bank()
672 }
661} 673}
662 674
663pub struct AnyPin { 675pub struct AnyPin {
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 32e0b9d59..9050472c1 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-stm32" 2name = "embassy-stm32"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[package.metadata.embassy_docs] 7[package.metadata.embassy_docs]
7src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/" 8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/"
@@ -44,6 +45,7 @@ embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optiona
44embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } 45embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
45embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9", optional = true} 46embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9", optional = true}
46embedded-hal-async = { version = "=0.1.0-alpha.2", optional = true} 47embedded-hal-async = { version = "=0.1.0-alpha.2", optional = true}
48embedded-hal-nb = { version = "=1.0.0-alpha.1", optional = true}
47 49
48embedded-storage = "0.3.0" 50embedded-storage = "0.3.0"
49embedded-storage-async = { version = "0.3.0", optional = true } 51embedded-storage-async = { version = "0.3.0", optional = true }
@@ -103,7 +105,7 @@ unstable-pac = []
103 105
104# Implement embedded-hal 1.0 alpha traits. 106# Implement embedded-hal 1.0 alpha traits.
105# Implement embedded-hal-async traits if `nightly` is set as well. 107# Implement embedded-hal-async traits if `nightly` is set as well.
106unstable-traits = ["embedded-hal-1"] 108unstable-traits = ["embedded-hal-1", "dep:embedded-hal-nb"]
107 109
108# BEGIN GENERATED FEATURES 110# BEGIN GENERATED FEATURES
109# Generated by stm32-gen-features. DO NOT EDIT. 111# Generated by stm32-gen-features. DO NOT EDIT.
diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs
index 8da13073e..0eb4eba73 100644
--- a/embassy-stm32/src/adc/mod.rs
+++ b/embassy-stm32/src/adc/mod.rs
@@ -28,15 +28,20 @@ pub(crate) mod sealed {
28 pub trait AdcPin<T: Instance> { 28 pub trait AdcPin<T: Instance> {
29 fn channel(&self) -> u8; 29 fn channel(&self) -> u8;
30 } 30 }
31
32 pub trait InternalChannel<T> {
33 fn channel(&self) -> u8;
34 }
31} 35}
32 36
33#[cfg(not(adc_f1))] 37#[cfg(not(any(adc_f1, adc_v2)))]
34pub trait Instance: sealed::Instance + 'static {} 38pub trait Instance: sealed::Instance + 'static {}
35#[cfg(adc_f1)] 39#[cfg(any(adc_f1, adc_v2))]
36pub trait Instance: sealed::Instance + crate::rcc::RccPeripheral + 'static {} 40pub trait Instance: sealed::Instance + crate::rcc::RccPeripheral + 'static {}
37#[cfg(all(not(adc_f1), not(adc_v1)))] 41#[cfg(all(not(adc_f1), not(adc_v1)))]
38pub trait Common: sealed::Common + 'static {} 42pub trait Common: sealed::Common + 'static {}
39pub trait AdcPin<T: Instance>: sealed::AdcPin<T> {} 43pub trait AdcPin<T: Instance>: sealed::AdcPin<T> {}
44pub trait InternalChannel<T>: sealed::InternalChannel<T> {}
40 45
41#[cfg(not(stm32h7))] 46#[cfg(not(stm32h7))]
42foreach_peripheral!( 47foreach_peripheral!(
diff --git a/embassy-stm32/src/adc/v2.rs b/embassy-stm32/src/adc/v2.rs
index 25b7ba967..4fe4ad1f0 100644
--- a/embassy-stm32/src/adc/v2.rs
+++ b/embassy-stm32/src/adc/v2.rs
@@ -3,7 +3,9 @@ use core::marker::PhantomData;
3use embassy_hal_common::into_ref; 3use embassy_hal_common::into_ref;
4use embedded_hal_02::blocking::delay::DelayUs; 4use embedded_hal_02::blocking::delay::DelayUs;
5 5
6use super::InternalChannel;
6use crate::adc::{AdcPin, Instance}; 7use crate::adc::{AdcPin, Instance};
8use crate::peripherals::ADC1;
7use crate::time::Hertz; 9use crate::time::Hertz;
8use crate::Peripheral; 10use crate::Peripheral;
9 11
@@ -12,20 +14,8 @@ pub const VREF_DEFAULT_MV: u32 = 3300;
12/// VREF voltage used for factory calibration of VREFINTCAL register. 14/// VREF voltage used for factory calibration of VREFINTCAL register.
13pub const VREF_CALIB_MV: u32 = 3300; 15pub const VREF_CALIB_MV: u32 = 3300;
14 16
15#[cfg(not(any(rcc_f4, rcc_f7)))] 17/// ADC turn-on time
16fn enable() { 18pub const ADC_POWERUP_TIME_US: u32 = 3;
17 todo!()
18}
19
20#[cfg(any(rcc_f4, rcc_f7))]
21fn enable() {
22 critical_section::with(|_| unsafe {
23 // TODO do not enable all adc clocks if not needed
24 crate::pac::RCC.apb2enr().modify(|w| w.set_adc1en(true));
25 crate::pac::RCC.apb2enr().modify(|w| w.set_adc2en(true));
26 crate::pac::RCC.apb2enr().modify(|w| w.set_adc3en(true));
27 });
28}
29 19
30pub enum Resolution { 20pub enum Resolution {
31 TwelveBit, 21 TwelveBit,
@@ -61,24 +51,53 @@ impl Resolution {
61} 51}
62 52
63pub struct VrefInt; 53pub struct VrefInt;
64impl<T: Instance> AdcPin<T> for VrefInt {} 54impl InternalChannel<ADC1> for VrefInt {}
65impl<T: Instance> super::sealed::AdcPin<T> for VrefInt { 55impl super::sealed::InternalChannel<ADC1> for VrefInt {
66 fn channel(&self) -> u8 { 56 fn channel(&self) -> u8 {
67 17 57 17
68 } 58 }
69} 59}
70 60
61impl VrefInt {
62 /// Time needed for internal voltage reference to stabilize
63 pub fn start_time_us() -> u32 {
64 10
65 }
66}
67
71pub struct Temperature; 68pub struct Temperature;
72impl<T: Instance> AdcPin<T> for Temperature {} 69impl InternalChannel<ADC1> for Temperature {}
73impl<T: Instance> super::sealed::AdcPin<T> for Temperature { 70impl super::sealed::InternalChannel<ADC1> for Temperature {
74 fn channel(&self) -> u8 { 71 fn channel(&self) -> u8 {
75 16 72 cfg_if::cfg_if! {
73 if #[cfg(any(stm32f40, stm32f41))] {
74 16
75 } else {
76 18
77 }
78 }
79 }
80}
81
82impl Temperature {
83 /// Converts temperature sensor reading in millivolts to degrees celcius
84 pub fn to_celcius(sample_mv: u16) -> f32 {
85 // From 6.3.22 Temperature sensor characteristics
86 const V25: i32 = 760; // mV
87 const AVG_SLOPE: f32 = 2.5; // mV/C
88
89 (sample_mv as i32 - V25) as f32 / AVG_SLOPE + 25.0
90 }
91
92 /// Time needed for temperature sensor readings to stabilize
93 pub fn start_time_us() -> u32 {
94 10
76 } 95 }
77} 96}
78 97
79pub struct Vbat; 98pub struct Vbat;
80impl<T: Instance> AdcPin<T> for Vbat {} 99impl InternalChannel<ADC1> for Vbat {}
81impl<T: Instance> super::sealed::AdcPin<T> for Vbat { 100impl super::sealed::InternalChannel<ADC1> for Vbat {
82 fn channel(&self) -> u8 { 101 fn channel(&self) -> u8 {
83 18 102 18
84 } 103 }
@@ -164,21 +183,19 @@ where
164{ 183{
165 pub fn new(_peri: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { 184 pub fn new(_peri: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
166 into_ref!(_peri); 185 into_ref!(_peri);
167 enable(); 186 T::enable();
187 T::reset();
168 188
169 let presc = unsafe { Prescaler::from_pclk2(crate::rcc::get_freqs().apb2) }; 189 let presc = Prescaler::from_pclk2(T::frequency());
170 unsafe { 190 unsafe {
171 T::common_regs().ccr().modify(|w| w.set_adcpre(presc.adcpre())); 191 T::common_regs().ccr().modify(|w| w.set_adcpre(presc.adcpre()));
172 }
173 192
174 unsafe {
175 // disable before config is set
176 T::regs().cr2().modify(|reg| { 193 T::regs().cr2().modify(|reg| {
177 reg.set_adon(crate::pac::adc::vals::Adon::DISABLED); 194 reg.set_adon(crate::pac::adc::vals::Adon::ENABLED);
178 }); 195 });
179 } 196 }
180 197
181 delay.delay_us(20); // TODO? 198 delay.delay_us(ADC_POWERUP_TIME_US);
182 199
183 Self { 200 Self {
184 sample_time: Default::default(), 201 sample_time: Default::default(),
@@ -208,6 +225,45 @@ where
208 ((u32::from(sample) * self.vref_mv) / self.resolution.to_max_count()) as u16 225 ((u32::from(sample) * self.vref_mv) / self.resolution.to_max_count()) as u16
209 } 226 }
210 227
228 /// Enables internal voltage reference and returns [VrefInt], which can be used in
229 /// [Adc::read_internal()] to perform conversion.
230 pub fn enable_vrefint(&self) -> VrefInt {
231 unsafe {
232 T::common_regs().ccr().modify(|reg| {
233 reg.set_tsvrefe(crate::pac::adccommon::vals::Tsvrefe::ENABLED);
234 });
235 }
236
237 VrefInt {}
238 }
239
240 /// Enables internal temperature sensor and returns [Temperature], which can be used in
241 /// [Adc::read_internal()] to perform conversion.
242 ///
243 /// On STM32F42 and STM32F43 this can not be used together with [Vbat]. If both are enabled,
244 /// temperature sensor will return vbat value.
245 pub fn enable_temperature(&self) -> Temperature {
246 unsafe {
247 T::common_regs().ccr().modify(|reg| {
248 reg.set_tsvrefe(crate::pac::adccommon::vals::Tsvrefe::ENABLED);
249 });
250 }
251
252 Temperature {}
253 }
254
255 /// Enables vbat input and returns [Vbat], which can be used in
256 /// [Adc::read_internal()] to perform conversion.
257 pub fn enable_vbat(&self) -> Vbat {
258 unsafe {
259 T::common_regs().ccr().modify(|reg| {
260 reg.set_vbate(crate::pac::adccommon::vals::Vbate::ENABLED);
261 });
262 }
263
264 Vbat {}
265 }
266
211 /// Perform a single conversion. 267 /// Perform a single conversion.
212 fn convert(&mut self) -> u16 { 268 fn convert(&mut self) -> u16 {
213 unsafe { 269 unsafe {
@@ -238,42 +294,29 @@ where
238 P: crate::gpio::sealed::Pin, 294 P: crate::gpio::sealed::Pin,
239 { 295 {
240 unsafe { 296 unsafe {
241 // dissable ADC
242 T::regs().cr2().modify(|reg| {
243 reg.set_swstart(false);
244 });
245 T::regs().cr2().modify(|reg| {
246 reg.set_adon(crate::pac::adc::vals::Adon::DISABLED);
247 });
248
249 pin.set_as_analog(); 297 pin.set_as_analog();
250 298
251 // Configure ADC 299 self.read_channel(pin.channel())
252 T::regs().cr1().modify(|reg| reg.set_res(self.resolution.res())); 300 }
301 }
253 302
254 // Select channel 303 pub fn read_internal(&mut self, channel: &mut impl InternalChannel<T>) -> u16 {
255 T::regs().sqr3().write(|reg| reg.set_sq(0, pin.channel())); 304 unsafe { self.read_channel(channel.channel()) }
305 }
256 306
257 // Configure channel 307 unsafe fn read_channel(&mut self, channel: u8) -> u16 {
258 Self::set_channel_sample_time(pin.channel(), self.sample_time); 308 // Configure ADC
309 T::regs().cr1().modify(|reg| reg.set_res(self.resolution.res()));
259 310
260 // enable adc 311 // Select channel
261 T::regs().cr2().modify(|reg| { 312 T::regs().sqr3().write(|reg| reg.set_sq(0, channel));
262 reg.set_adon(crate::pac::adc::vals::Adon::ENABLED);
263 });
264 313
265 let val = self.convert(); 314 // Configure channel
315 Self::set_channel_sample_time(channel, self.sample_time);
266 316
267 // dissable ADC 317 let val = self.convert();
268 T::regs().cr2().modify(|reg| {
269 reg.set_swstart(false);
270 });
271 T::regs().cr2().modify(|reg| {
272 reg.set_adon(crate::pac::adc::vals::Adon::DISABLED);
273 });
274 318
275 val 319 val
276 }
277 } 320 }
278 321
279 unsafe fn set_channel_sample_time(ch: u8, sample_time: SampleTime) { 322 unsafe fn set_channel_sample_time(ch: u8, sample_time: SampleTime) {
@@ -288,3 +331,9 @@ where
288 } 331 }
289 } 332 }
290} 333}
334
335impl<'d, T: Instance> Drop for Adc<'d, T> {
336 fn drop(&mut self) {
337 T::disable();
338 }
339}
diff --git a/embassy-stm32/src/adc/v4.rs b/embassy-stm32/src/adc/v4.rs
index d356d7b66..eda2b2a72 100644
--- a/embassy-stm32/src/adc/v4.rs
+++ b/embassy-stm32/src/adc/v4.rs
@@ -5,7 +5,7 @@ use embedded_hal_02::blocking::delay::DelayUs;
5use pac::adc::vals::{Adcaldif, Boost, Difsel, Exten, Pcsel}; 5use pac::adc::vals::{Adcaldif, Boost, Difsel, Exten, Pcsel};
6use pac::adccommon::vals::Presc; 6use pac::adccommon::vals::Presc;
7 7
8use super::{AdcPin, Instance}; 8use super::{AdcPin, Instance, InternalChannel};
9use crate::time::Hertz; 9use crate::time::Hertz;
10use crate::{pac, Peripheral}; 10use crate::{pac, Peripheral};
11 11
@@ -50,18 +50,10 @@ impl Resolution {
50 } 50 }
51} 51}
52 52
53pub trait InternalChannel<T>: sealed::InternalChannel<T> {}
54
55mod sealed {
56 pub trait InternalChannel<T> {
57 fn channel(&self) -> u8;
58 }
59}
60
61// NOTE: Vrefint/Temperature/Vbat are only available on ADC3 on H7, this currently cannot be modeled with stm32-data, so these are available from the software on all ADCs 53// NOTE: Vrefint/Temperature/Vbat are only available on ADC3 on H7, this currently cannot be modeled with stm32-data, so these are available from the software on all ADCs
62pub struct VrefInt; 54pub struct VrefInt;
63impl<T: Instance> InternalChannel<T> for VrefInt {} 55impl<T: Instance> InternalChannel<T> for VrefInt {}
64impl<T: Instance> sealed::InternalChannel<T> for VrefInt { 56impl<T: Instance> super::sealed::InternalChannel<T> for VrefInt {
65 fn channel(&self) -> u8 { 57 fn channel(&self) -> u8 {
66 19 58 19
67 } 59 }
@@ -69,7 +61,7 @@ impl<T: Instance> sealed::InternalChannel<T> for VrefInt {
69 61
70pub struct Temperature; 62pub struct Temperature;
71impl<T: Instance> InternalChannel<T> for Temperature {} 63impl<T: Instance> InternalChannel<T> for Temperature {}
72impl<T: Instance> sealed::InternalChannel<T> for Temperature { 64impl<T: Instance> super::sealed::InternalChannel<T> for Temperature {
73 fn channel(&self) -> u8 { 65 fn channel(&self) -> u8 {
74 18 66 18
75 } 67 }
@@ -77,7 +69,7 @@ impl<T: Instance> sealed::InternalChannel<T> for Temperature {
77 69
78pub struct Vbat; 70pub struct Vbat;
79impl<T: Instance> InternalChannel<T> for Vbat {} 71impl<T: Instance> InternalChannel<T> for Vbat {}
80impl<T: Instance> sealed::InternalChannel<T> for Vbat { 72impl<T: Instance> super::sealed::InternalChannel<T> for Vbat {
81 fn channel(&self) -> u8 { 73 fn channel(&self) -> u8 {
82 // TODO this should be 14 for H7a/b/35 74 // TODO this should be 14 for H7a/b/35
83 17 75 17
diff --git a/embassy-stm32/src/flash/mod.rs b/embassy-stm32/src/flash/mod.rs
index 5258c9b04..988cf9fae 100644
--- a/embassy-stm32/src/flash/mod.rs
+++ b/embassy-stm32/src/flash/mod.rs
@@ -23,17 +23,6 @@ impl<'d> Flash<'d> {
23 Self { _inner: p } 23 Self { _inner: p }
24 } 24 }
25 25
26 pub fn unlock(p: impl Peripheral<P = FLASH> + 'd) -> Self {
27 let flash = Self::new(p);
28
29 unsafe { family::unlock() };
30 flash
31 }
32
33 pub fn lock(&mut self) {
34 unsafe { family::lock() };
35 }
36
37 pub fn blocking_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { 26 pub fn blocking_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
38 let offset = FLASH_BASE as u32 + offset; 27 let offset = FLASH_BASE as u32 + offset;
39 if offset as usize >= FLASH_END || offset as usize + bytes.len() > FLASH_END { 28 if offset as usize >= FLASH_END || offset as usize + bytes.len() > FLASH_END {
@@ -57,7 +46,12 @@ impl<'d> Flash<'d> {
57 46
58 self.clear_all_err(); 47 self.clear_all_err();
59 48
60 unsafe { family::blocking_write(offset, buf) } 49 unsafe {
50 family::unlock();
51 let res = family::blocking_write(offset, buf);
52 family::lock();
53 res
54 }
61 } 55 }
62 56
63 pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error> { 57 pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error> {
@@ -72,7 +66,12 @@ impl<'d> Flash<'d> {
72 66
73 self.clear_all_err(); 67 self.clear_all_err();
74 68
75 unsafe { family::blocking_erase(from, to) } 69 unsafe {
70 family::unlock();
71 let res = family::blocking_erase(from, to);
72 family::lock();
73 res
74 }
76 } 75 }
77 76
78 fn clear_all_err(&mut self) { 77 fn clear_all_err(&mut self) {
@@ -82,7 +81,7 @@ impl<'d> Flash<'d> {
82 81
83impl Drop for Flash<'_> { 82impl Drop for Flash<'_> {
84 fn drop(&mut self) { 83 fn drop(&mut self) {
85 self.lock(); 84 unsafe { family::lock() };
86 } 85 }
87} 86}
88 87
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs
index 6c2668748..a152a0c15 100644
--- a/embassy-stm32/src/usart/mod.rs
+++ b/embassy-stm32/src/usart/mod.rs
@@ -160,6 +160,30 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> {
160 Ok(()) 160 Ok(())
161 } 161 }
162 162
163 pub fn nb_read(&mut self) -> Result<u8, nb::Error<Error>> {
164 let r = T::regs();
165 unsafe {
166 let sr = sr(r).read();
167 if sr.pe() {
168 rdr(r).read_volatile();
169 Err(nb::Error::Other(Error::Parity))
170 } else if sr.fe() {
171 rdr(r).read_volatile();
172 Err(nb::Error::Other(Error::Framing))
173 } else if sr.ne() {
174 rdr(r).read_volatile();
175 Err(nb::Error::Other(Error::Noise))
176 } else if sr.ore() {
177 rdr(r).read_volatile();
178 Err(nb::Error::Other(Error::Overrun))
179 } else if sr.rxne() {
180 Ok(rdr(r).read_volatile())
181 } else {
182 Err(nb::Error::WouldBlock)
183 }
184 }
185 }
186
163 pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { 187 pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error> {
164 unsafe { 188 unsafe {
165 let r = T::regs(); 189 let r = T::regs();
@@ -263,6 +287,10 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
263 self.rx.read(buffer).await 287 self.rx.read(buffer).await
264 } 288 }
265 289
290 pub fn nb_read(&mut self) -> Result<u8, nb::Error<Error>> {
291 self.rx.nb_read()
292 }
293
266 pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { 294 pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error> {
267 self.rx.blocking_read(buffer) 295 self.rx.blocking_read(buffer)
268 } 296 }
@@ -281,27 +309,7 @@ mod eh02 {
281 impl<'d, T: BasicInstance, RxDma> embedded_hal_02::serial::Read<u8> for UartRx<'d, T, RxDma> { 309 impl<'d, T: BasicInstance, RxDma> embedded_hal_02::serial::Read<u8> for UartRx<'d, T, RxDma> {
282 type Error = Error; 310 type Error = Error;
283 fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> { 311 fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> {
284 let r = T::regs(); 312 self.nb_read()
285 unsafe {
286 let sr = sr(r).read();
287 if sr.pe() {
288 rdr(r).read_volatile();
289 Err(nb::Error::Other(Error::Parity))
290 } else if sr.fe() {
291 rdr(r).read_volatile();
292 Err(nb::Error::Other(Error::Framing))
293 } else if sr.ne() {
294 rdr(r).read_volatile();
295 Err(nb::Error::Other(Error::Noise))
296 } else if sr.ore() {
297 rdr(r).read_volatile();
298 Err(nb::Error::Other(Error::Overrun))
299 } else if sr.rxne() {
300 Ok(rdr(r).read_volatile())
301 } else {
302 Err(nb::Error::WouldBlock)
303 }
304 }
305 } 313 }
306 } 314 }
307 315
@@ -318,7 +326,7 @@ mod eh02 {
318 impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_02::serial::Read<u8> for Uart<'d, T, TxDma, RxDma> { 326 impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_02::serial::Read<u8> for Uart<'d, T, TxDma, RxDma> {
319 type Error = Error; 327 type Error = Error;
320 fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> { 328 fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> {
321 embedded_hal_02::serial::Read::read(&mut self.rx) 329 self.nb_read()
322 } 330 }
323 } 331 }
324 332
@@ -359,6 +367,58 @@ mod eh1 {
359 impl<'d, T: BasicInstance, RxDma> embedded_hal_1::serial::ErrorType for UartRx<'d, T, RxDma> { 367 impl<'d, T: BasicInstance, RxDma> embedded_hal_1::serial::ErrorType for UartRx<'d, T, RxDma> {
360 type Error = Error; 368 type Error = Error;
361 } 369 }
370
371 impl<'d, T: BasicInstance, RxDma> embedded_hal_nb::serial::Read for UartRx<'d, T, RxDma> {
372 fn read(&mut self) -> nb::Result<u8, Self::Error> {
373 self.nb_read()
374 }
375 }
376
377 impl<'d, T: BasicInstance, TxDma> embedded_hal_1::serial::Write for UartTx<'d, T, TxDma> {
378 fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> {
379 self.blocking_write(buffer)
380 }
381
382 fn flush(&mut self) -> Result<(), Self::Error> {
383 self.blocking_flush()
384 }
385 }
386
387 impl<'d, T: BasicInstance, TxDma> embedded_hal_nb::serial::Write for UartTx<'d, T, TxDma> {
388 fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> {
389 self.blocking_write(&[char]).map_err(nb::Error::Other)
390 }
391
392 fn flush(&mut self) -> nb::Result<(), Self::Error> {
393 self.blocking_flush().map_err(nb::Error::Other)
394 }
395 }
396
397 impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::Read for Uart<'d, T, TxDma, RxDma> {
398 fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> {
399 self.nb_read()
400 }
401 }
402
403 impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_1::serial::Write for Uart<'d, T, TxDma, RxDma> {
404 fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> {
405 self.blocking_write(buffer)
406 }
407
408 fn flush(&mut self) -> Result<(), Self::Error> {
409 self.blocking_flush()
410 }
411 }
412
413 impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::Write for Uart<'d, T, TxDma, RxDma> {
414 fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> {
415 self.blocking_write(&[char]).map_err(nb::Error::Other)
416 }
417
418 fn flush(&mut self) -> nb::Result<(), Self::Error> {
419 self.blocking_flush().map_err(nb::Error::Other)
420 }
421 }
362} 422}
363 423
364#[cfg(all( 424#[cfg(all(
diff --git a/embassy-sync/Cargo.toml b/embassy-sync/Cargo.toml
index 14ab1d003..584d5ba9f 100644
--- a/embassy-sync/Cargo.toml
+++ b/embassy-sync/Cargo.toml
@@ -2,6 +2,16 @@
2name = "embassy-sync" 2name = "embassy-sync"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5description = "no-std, no-alloc synchronization primitives with async support"
6repository = "https://github.com/embassy-rs/embassy"
7readme = "README.md"
8license = "MIT OR Apache-2.0"
9categories = [
10 "embedded",
11 "no-std",
12 "concurrency",
13 "asynchronous",
14]
5 15
6[package.metadata.embassy_docs] 16[package.metadata.embassy_docs]
7src_base = "https://github.com/embassy-rs/embassy/blob/embassy-sync-v$VERSION/embassy-sync/src/" 17src_base = "https://github.com/embassy-rs/embassy/blob/embassy-sync-v$VERSION/embassy-sync/src/"
diff --git a/embassy-sync/README.md b/embassy-sync/README.md
index 106295c0d..cc65cf6ef 100644
--- a/embassy-sync/README.md
+++ b/embassy-sync/README.md
@@ -1,12 +1,32 @@
1# embassy-sync 1# embassy-sync
2 2
3Synchronization primitives and data structures with an async API: 3An [Embassy](https://embassy.dev) project.
4
5Synchronization primitives and data structures with async support:
4 6
5- [`Channel`](channel::Channel) - A Multiple Producer Multiple Consumer (MPMC) channel. Each message is only received by a single consumer. 7- [`Channel`](channel::Channel) - A Multiple Producer Multiple Consumer (MPMC) channel. Each message is only received by a single consumer.
6- [`PubSubChannel`](pubsub::PubSubChannel) - A broadcast channel (publish-subscribe) channel. Each message is received by all consumers. 8- [`PubSubChannel`](pubsub::PubSubChannel) - A broadcast channel (publish-subscribe) channel. Each message is received by all consumers.
7- [`Signal`](signal::Signal) - Signalling latest value to a single consumer. 9- [`Signal`](signal::Signal) - Signalling latest value to a single consumer.
8- [`Mutex`](mutex::Mutex) - A Mutex for synchronizing state between asynchronous tasks. 10- [`Mutex`](mutex::Mutex) - Mutex for synchronizing state between asynchronous tasks.
9- [`Pipe`](pipe::Pipe) - Byte stream implementing `embedded_io` traits. 11- [`Pipe`](pipe::Pipe) - Byte stream implementing `embedded_io` traits.
10- [`WakerRegistration`](waitqueue::WakerRegistration) - Utility to register and wake a `Waker`. 12- [`WakerRegistration`](waitqueue::WakerRegistration) - Utility to register and wake a `Waker`.
11- [`AtomicWaker`](waitqueue::AtomicWaker) - A variant of `WakerRegistration` accessible using a non-mut API. 13- [`AtomicWaker`](waitqueue::AtomicWaker) - A variant of `WakerRegistration` accessible using a non-mut API.
12- [`MultiWakerRegistration`](waitqueue::MultiWakerRegistration) - Utility registering and waking multiple `Waker`'s. 14- [`MultiWakerRegistration`](waitqueue::MultiWakerRegistration) - Utility registering and waking multiple `Waker`'s.
15
16## Interoperability
17
18Futures from this crate can run on any executor.
19
20## Minimum supported Rust version (MSRV)
21
22Embassy is guaranteed to compile on the latest stable Rust version at the time of release. It might compile with older versions but that may change in any new patch release.
23
24## License
25
26This work is licensed under either of
27
28- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
29 <http://www.apache.org/licenses/LICENSE-2.0>)
30- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
31
32at your option.
diff --git a/embassy-sync/src/pubsub/publisher.rs b/embassy-sync/src/pubsub/publisher.rs
index faa67d947..e1edc9eb9 100644
--- a/embassy-sync/src/pubsub/publisher.rs
+++ b/embassy-sync/src/pubsub/publisher.rs
@@ -123,6 +123,14 @@ impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> ImmediatePub<'a, PSB, T> {
123 pub fn try_publish(&self, message: T) -> Result<(), T> { 123 pub fn try_publish(&self, message: T) -> Result<(), T> {
124 self.channel.publish_with_context(message, None) 124 self.channel.publish_with_context(message, None)
125 } 125 }
126
127 /// The amount of messages that can still be published without having to wait or without having to lag the subscribers
128 ///
129 /// *Note: In the time between checking this and a publish action, other publishers may have had time to publish something.
130 /// So checking doesn't give any guarantees.*
131 pub fn space(&self) -> usize {
132 self.channel.space()
133 }
126} 134}
127 135
128/// An immediate publisher that holds a dynamic reference to the channel 136/// An immediate publisher that holds a dynamic reference to the channel
diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml
index c3b361b8a..c51a71d01 100644
--- a/embassy-time/Cargo.toml
+++ b/embassy-time/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-time" 2name = "embassy-time"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6 7
7[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
diff --git a/embassy-usb-driver/Cargo.toml b/embassy-usb-driver/Cargo.toml
index b525df337..d22bf7d72 100644
--- a/embassy-usb-driver/Cargo.toml
+++ b/embassy-usb-driver/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-usb-driver" 2name = "embassy-usb-driver"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 8
@@ -13,4 +14,4 @@ target = "thumbv7em-none-eabi"
13 14
14[dependencies] 15[dependencies]
15defmt = { version = "0.3", optional = true } 16defmt = { version = "0.3", optional = true }
16log = { version = "0.4.14", optional = true } \ No newline at end of file 17log = { version = "0.4.14", optional = true }
diff --git a/embassy-usb/Cargo.toml b/embassy-usb/Cargo.toml
index aad54dbaf..b59ba8a22 100644
--- a/embassy-usb/Cargo.toml
+++ b/embassy-usb/Cargo.toml
@@ -2,11 +2,12 @@
2name = "embassy-usb" 2name = "embassy-usb"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6[package.metadata.embassy_docs] 7[package.metadata.embassy_docs]
7src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-v$VERSION/embassy-usb/src/" 8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-v$VERSION/embassy-usb/src/"
8src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb/src/" 9src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb/src/"
9features = ["defmt"] 10features = ["defmt", "usbd-hid"]
10target = "thumbv7em-none-eabi" 11target = "thumbv7em-none-eabi"
11 12
12[features] 13[features]
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml
index b9ff92578..a5d82b601 100644
--- a/examples/boot/application/nrf/Cargo.toml
+++ b/examples/boot/application/nrf/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-nrf-examples" 3name = "embassy-boot-nrf-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" }
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml
index ce1e6fe4a..3a1843562 100644
--- a/examples/boot/application/stm32f3/Cargo.toml
+++ b/examples/boot/application/stm32f3/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-stm32f3-examples" 3name = "embassy-boot-stm32f3-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs
index fdbd5ab99..d92d59b29 100644
--- a/examples/boot/application/stm32f3/src/bin/a.rs
+++ b/examples/boot/application/stm32f3/src/bin/a.rs
@@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
17#[embassy_executor::main] 17#[embassy_executor::main]
18async fn main(_spawner: Spawner) { 18async fn main(_spawner: Spawner) {
19 let p = embassy_stm32::init(Default::default()); 19 let p = embassy_stm32::init(Default::default());
20 let flash = Flash::unlock(p.FLASH); 20 let flash = Flash::new(p.FLASH);
21 let mut flash = BlockingAsync::new(flash); 21 let mut flash = BlockingAsync::new(flash);
22 22
23 let button = Input::new(p.PC13, Pull::Up); 23 let button = Input::new(p.PC13, Pull::Up);
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml
index 2fc7ae834..8d9c4490e 100644
--- a/examples/boot/application/stm32f7/Cargo.toml
+++ b/examples/boot/application/stm32f7/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-stm32f7-examples" 3name = "embassy-boot-stm32f7-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs
index 77b897b0f..79ab80e09 100644
--- a/examples/boot/application/stm32f7/src/bin/a.rs
+++ b/examples/boot/application/stm32f7/src/bin/a.rs
@@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
16#[embassy_executor::main] 16#[embassy_executor::main]
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let p = embassy_stm32::init(Default::default()); 18 let p = embassy_stm32::init(Default::default());
19 let mut flash = Flash::unlock(p.FLASH); 19 let mut flash = Flash::new(p.FLASH);
20 20
21 let button = Input::new(p.PC13, Pull::Down); 21 let button = Input::new(p.PC13, Pull::Down);
22 let mut button = ExtiInput::new(button, p.EXTI13); 22 let mut button = ExtiInput::new(button, p.EXTI13);
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml
index fd809714a..b4314aa72 100644
--- a/examples/boot/application/stm32h7/Cargo.toml
+++ b/examples/boot/application/stm32h7/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-stm32h7-examples" 3name = "embassy-boot-stm32h7-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" }
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs
index 0fe598a5d..8b452be34 100644
--- a/examples/boot/application/stm32h7/src/bin/a.rs
+++ b/examples/boot/application/stm32h7/src/bin/a.rs
@@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
16#[embassy_executor::main] 16#[embassy_executor::main]
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let p = embassy_stm32::init(Default::default()); 18 let p = embassy_stm32::init(Default::default());
19 let mut flash = Flash::unlock(p.FLASH); 19 let mut flash = Flash::new(p.FLASH);
20 20
21 let button = Input::new(p.PC13, Pull::Down); 21 let button = Input::new(p.PC13, Pull::Down);
22 let mut button = ExtiInput::new(button, p.EXTI13); 22 let mut button = ExtiInput::new(button, p.EXTI13);
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml
index 470eca52a..a17d336a6 100644
--- a/examples/boot/application/stm32l0/Cargo.toml
+++ b/examples/boot/application/stm32l0/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-stm32l0-examples" 3name = "embassy-boot-stm32l0-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs
index f0b0b80e3..59ca34386 100644
--- a/examples/boot/application/stm32l0/src/bin/a.rs
+++ b/examples/boot/application/stm32l0/src/bin/a.rs
@@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
18#[embassy_executor::main] 18#[embassy_executor::main]
19async fn main(_spawner: Spawner) { 19async fn main(_spawner: Spawner) {
20 let p = embassy_stm32::init(Default::default()); 20 let p = embassy_stm32::init(Default::default());
21 let flash = Flash::unlock(p.FLASH); 21 let flash = Flash::new(p.FLASH);
22 let mut flash = BlockingAsync::new(flash); 22 let mut flash = BlockingAsync::new(flash);
23 23
24 let button = Input::new(p.PB2, Pull::Up); 24 let button = Input::new(p.PB2, Pull::Up);
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml
index 2b4b29357..683f2c860 100644
--- a/examples/boot/application/stm32l1/Cargo.toml
+++ b/examples/boot/application/stm32l1/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-stm32l1-examples" 3name = "embassy-boot-stm32l1-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs
index f0b0b80e3..59ca34386 100644
--- a/examples/boot/application/stm32l1/src/bin/a.rs
+++ b/examples/boot/application/stm32l1/src/bin/a.rs
@@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
18#[embassy_executor::main] 18#[embassy_executor::main]
19async fn main(_spawner: Spawner) { 19async fn main(_spawner: Spawner) {
20 let p = embassy_stm32::init(Default::default()); 20 let p = embassy_stm32::init(Default::default());
21 let flash = Flash::unlock(p.FLASH); 21 let flash = Flash::new(p.FLASH);
22 let mut flash = BlockingAsync::new(flash); 22 let mut flash = BlockingAsync::new(flash);
23 23
24 let button = Input::new(p.PB2, Pull::Up); 24 let button = Input::new(p.PB2, Pull::Up);
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml
index 40bddd194..b879c0d76 100644
--- a/examples/boot/application/stm32l4/Cargo.toml
+++ b/examples/boot/application/stm32l4/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-stm32l4-examples" 3name = "embassy-boot-stm32l4-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs
index 5119bad2e..6cddc6cc8 100644
--- a/examples/boot/application/stm32l4/src/bin/a.rs
+++ b/examples/boot/application/stm32l4/src/bin/a.rs
@@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
17#[embassy_executor::main] 17#[embassy_executor::main]
18async fn main(_spawner: Spawner) { 18async fn main(_spawner: Spawner) {
19 let p = embassy_stm32::init(Default::default()); 19 let p = embassy_stm32::init(Default::default());
20 let flash = Flash::unlock(p.FLASH); 20 let flash = Flash::new(p.FLASH);
21 let mut flash = BlockingAsync::new(flash); 21 let mut flash = BlockingAsync::new(flash);
22 22
23 let button = Input::new(p.PC13, Pull::Up); 23 let button = Input::new(p.PC13, Pull::Up);
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml
index 5b4a61e8f..e3bc0e49c 100644
--- a/examples/boot/application/stm32wl/Cargo.toml
+++ b/examples/boot/application/stm32wl/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-boot-stm32wl-examples" 3name = "embassy-boot-stm32wl-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs
index faa650778..1ff47eddd 100644
--- a/examples/boot/application/stm32wl/src/bin/a.rs
+++ b/examples/boot/application/stm32wl/src/bin/a.rs
@@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
17#[embassy_executor::main] 17#[embassy_executor::main]
18async fn main(_spawner: Spawner) { 18async fn main(_spawner: Spawner) {
19 let p = embassy_stm32::init(Default::default()); 19 let p = embassy_stm32::init(Default::default());
20 let flash = Flash::unlock(p.FLASH); 20 let flash = Flash::new(p.FLASH);
21 let mut flash = BlockingAsync::new(flash); 21 let mut flash = BlockingAsync::new(flash);
22 22
23 let button = Input::new(p.PA0, Pull::Up); 23 let button = Input::new(p.PA0, Pull::Up);
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml
index aa2a13ecb..b417a40d1 100644
--- a/examples/boot/bootloader/nrf/Cargo.toml
+++ b/examples/boot/bootloader/nrf/Cargo.toml
@@ -3,6 +3,7 @@ edition = "2021"
3name = "nrf-bootloader-example" 3name = "nrf-bootloader-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Bootloader for nRF chips" 5description = "Bootloader for nRF chips"
6license = "MIT OR Apache-2.0"
6 7
7[dependencies] 8[dependencies]
8defmt = { version = "0.3", optional = true } 9defmt = { version = "0.3", optional = true }
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml
index 491777103..4ddd1c99c 100644
--- a/examples/boot/bootloader/stm32/Cargo.toml
+++ b/examples/boot/bootloader/stm32/Cargo.toml
@@ -3,6 +3,7 @@ edition = "2021"
3name = "stm32-bootloader-example" 3name = "stm32-bootloader-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Example bootloader for STM32 chips" 5description = "Example bootloader for STM32 chips"
6license = "MIT OR Apache-2.0"
6 7
7[dependencies] 8[dependencies]
8defmt = { version = "0.3", optional = true } 9defmt = { version = "0.3", optional = true }
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs
index 294464d1c..4b17cd799 100644
--- a/examples/boot/bootloader/stm32/src/main.rs
+++ b/examples/boot/bootloader/stm32/src/main.rs
@@ -20,7 +20,7 @@ fn main() -> ! {
20 */ 20 */
21 21
22 let mut bl: BootLoader<ERASE_SIZE, WRITE_SIZE> = BootLoader::default(); 22 let mut bl: BootLoader<ERASE_SIZE, WRITE_SIZE> = BootLoader::default();
23 let flash = Flash::unlock(p.FLASH); 23 let flash = Flash::new(p.FLASH);
24 let mut flash = BootFlash::<_, ERASE_SIZE, ERASE_VALUE>::new(flash); 24 let mut flash = BootFlash::<_, ERASE_SIZE, ERASE_VALUE>::new(flash);
25 let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); 25 let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash));
26 core::mem::drop(flash); 26 core::mem::drop(flash);
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml
index 87c9f33f5..d8c24dfad 100644
--- a/examples/nrf-rtos-trace/Cargo.toml
+++ b/examples/nrf-rtos-trace/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-nrf-rtos-trace-examples" 3name = "embassy-nrf-rtos-trace-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[features] 7[features]
7default = ["log", "nightly"] 8default = ["log", "nightly"]
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml
index a5d340c69..9ebd04845 100644
--- a/examples/nrf/Cargo.toml
+++ b/examples/nrf/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-nrf-examples" 3name = "embassy-nrf-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[features] 7[features]
7default = ["nightly"] 8default = ["nightly"]
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml
index 3c8f923e7..a5af8b2f0 100644
--- a/examples/rp/Cargo.toml
+++ b/examples/rp/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-rp-examples" 3name = "embassy-rp-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6 7
7[dependencies] 8[dependencies]
@@ -26,7 +27,7 @@ st7789 = "0.6.1"
26display-interface = "0.4.1" 27display-interface = "0.4.1"
27byte-slice-cast = { version = "1.2.0", default-features = false } 28byte-slice-cast = { version = "1.2.0", default-features = false }
28 29
29embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } 30embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
30embedded-hal-async = { version = "0.1.0-alpha.1" } 31embedded-hal-async = { version = "0.1.0-alpha.1" }
31embedded-io = { version = "0.3.0", features = ["async", "defmt"] } 32embedded-io = { version = "0.3.0", features = ["async", "defmt"] }
32static_cell = "1.0.0" 33static_cell = "1.0.0"
diff --git a/examples/rp/src/bin/i2c_blocking.rs b/examples/rp/src/bin/i2c_blocking.rs
new file mode 100644
index 000000000..7623e33c8
--- /dev/null
+++ b/examples/rp/src/bin/i2c_blocking.rs
@@ -0,0 +1,70 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_rp::i2c::{self, Config};
8use embassy_time::{Duration, Timer};
9use embedded_hal_1::i2c::I2c;
10use {defmt_rtt as _, panic_probe as _};
11
12#[allow(dead_code)]
13mod mcp23017 {
14 pub const ADDR: u8 = 0x20; // default addr
15
16 pub const IODIRA: u8 = 0x00;
17 pub const IPOLA: u8 = 0x02;
18 pub const GPINTENA: u8 = 0x04;
19 pub const DEFVALA: u8 = 0x06;
20 pub const INTCONA: u8 = 0x08;
21 pub const IOCONA: u8 = 0x0A;
22 pub const GPPUA: u8 = 0x0C;
23 pub const INTFA: u8 = 0x0E;
24 pub const INTCAPA: u8 = 0x10;
25 pub const GPIOA: u8 = 0x12;
26 pub const OLATA: u8 = 0x14;
27 pub const IODIRB: u8 = 0x01;
28 pub const IPOLB: u8 = 0x03;
29 pub const GPINTENB: u8 = 0x05;
30 pub const DEFVALB: u8 = 0x07;
31 pub const INTCONB: u8 = 0x09;
32 pub const IOCONB: u8 = 0x0B;
33 pub const GPPUB: u8 = 0x0D;
34 pub const INTFB: u8 = 0x0F;
35 pub const INTCAPB: u8 = 0x11;
36 pub const GPIOB: u8 = 0x13;
37 pub const OLATB: u8 = 0x15;
38}
39
40#[embassy_executor::main]
41async fn main(_spawner: Spawner) {
42 let p = embassy_rp::init(Default::default());
43
44 let sda = p.PIN_14;
45 let scl = p.PIN_15;
46
47 info!("set up i2c ");
48 let mut i2c = i2c::I2c::new_blocking(p.I2C1, scl, sda, Config::default());
49
50 use mcp23017::*;
51
52 info!("init mcp23017 config for IxpandO");
53 // init - a outputs, b inputs
54 i2c.write(ADDR, &[IODIRA, 0x00]).unwrap();
55 i2c.write(ADDR, &[IODIRB, 0xff]).unwrap();
56 i2c.write(ADDR, &[GPPUB, 0xff]).unwrap(); // pullups
57
58 let mut val = 0xaa;
59 loop {
60 let mut portb = [0];
61
62 i2c.write(mcp23017::ADDR, &[GPIOA, val]).unwrap();
63 i2c.write_read(mcp23017::ADDR, &[GPIOB], &mut portb).unwrap();
64
65 info!("portb = {:02x}", portb[0]);
66 val = !val;
67
68 Timer::after(Duration::from_secs(1)).await;
69 }
70}
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml
index dbfd9d625..b9bd1e718 100644
--- a/examples/std/Cargo.toml
+++ b/examples/std/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-std-examples" 3name = "embassy-std-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] }
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml
index c82b79c86..a56c546ee 100644
--- a/examples/stm32f0/Cargo.toml
+++ b/examples/stm32f0/Cargo.toml
@@ -2,6 +2,7 @@
2name = "embassy-stm32f0-examples" 2name = "embassy-stm32f0-examples"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 8
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml
index e6553789a..6be131f30 100644
--- a/examples/stm32f1/Cargo.toml
+++ b/examples/stm32f1/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32f1-examples" 3name = "embassy-stm32f1-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml
index 60cd54bd9..f6adda2a3 100644
--- a/examples/stm32f2/Cargo.toml
+++ b/examples/stm32f2/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32f2-examples" 3name = "embassy-stm32f2-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml
index f5b0b880c..27188dd19 100644
--- a/examples/stm32f3/Cargo.toml
+++ b/examples/stm32f3/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32f3-examples" 3name = "embassy-stm32f3-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs
index 2cf24dbd3..baa7484d0 100644
--- a/examples/stm32f3/src/bin/flash.rs
+++ b/examples/stm32f3/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x26000; 16 const ADDR: u32 = 0x26000;
17 17
18 let mut f = Flash::unlock(p.FLASH); 18 let mut f = Flash::new(p.FLASH);
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml
index ea5c47a43..6d4f09fba 100644
--- a/examples/stm32f4/Cargo.toml
+++ b/examples/stm32f4/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32f4-examples" 3name = "embassy-stm32f4-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6 7
7[dependencies] 8[dependencies]
diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs
index 871185074..1d030f7dc 100644
--- a/examples/stm32f4/src/bin/adc.rs
+++ b/examples/stm32f4/src/bin/adc.rs
@@ -2,9 +2,10 @@
2#![no_main] 2#![no_main]
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
5use defmt::*; 6use defmt::*;
6use embassy_executor::Spawner; 7use embassy_executor::Spawner;
7use embassy_stm32::adc::Adc; 8use embassy_stm32::adc::{Adc, Temperature, VrefInt};
8use embassy_time::{Delay, Duration, Timer}; 9use embassy_time::{Delay, Duration, Timer};
9use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
10 11
@@ -13,12 +14,30 @@ async fn main(_spawner: Spawner) {
13 let p = embassy_stm32::init(Default::default()); 14 let p = embassy_stm32::init(Default::default());
14 info!("Hello World!"); 15 info!("Hello World!");
15 16
16 let mut adc = Adc::new(p.ADC1, &mut Delay); 17 let mut delay = Delay;
18 let mut adc = Adc::new(p.ADC1, &mut delay);
17 let mut pin = p.PC1; 19 let mut pin = p.PC1;
18 20
21 let mut vrefint = adc.enable_vrefint();
22 let mut temp = adc.enable_temperature();
23
24 // Startup delay can be combined to the maximum of either
25 delay.delay_us(Temperature::start_time_us().max(VrefInt::start_time_us()));
26
19 loop { 27 loop {
28 // Read pin
20 let v = adc.read(&mut pin); 29 let v = adc.read(&mut pin);
21 info!("--> {} - {} mV", v, adc.to_millivolts(v)); 30 info!("PC1: {} ({} mV)", v, adc.to_millivolts(v));
31
32 // Read internal temperature
33 let v = adc.read_internal(&mut temp);
34 let celcius = Temperature::to_celcius(adc.to_millivolts(v));
35 info!("Internal temp: {} ({} C)", v, celcius);
36
37 // Read internal voltage reference
38 let v = adc.read_internal(&mut vrefint);
39 info!("VrefInt: {} ({} mV)", v, adc.to_millivolts(v));
40
22 Timer::after(Duration::from_millis(100)).await; 41 Timer::after(Duration::from_millis(100)).await;
23 } 42 }
24} 43}
diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs
index 393d61e86..7ea068a42 100644
--- a/examples/stm32f4/src/bin/flash.rs
+++ b/examples/stm32f4/src/bin/flash.rs
@@ -13,7 +13,7 @@ async fn main(_spawner: Spawner) {
13 let p = embassy_stm32::init(Default::default()); 13 let p = embassy_stm32::init(Default::default());
14 info!("Hello Flash!"); 14 info!("Hello Flash!");
15 15
16 let mut f = Flash::unlock(p.FLASH); 16 let mut f = Flash::new(p.FLASH);
17 17
18 // Sector 5 18 // Sector 5
19 test_flash(&mut f, 128 * 1024, 128 * 1024); 19 test_flash(&mut f, 128 * 1024, 128 * 1024);
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml
index 6c2f846fe..dad92c0fc 100644
--- a/examples/stm32f7/Cargo.toml
+++ b/examples/stm32f7/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32f7-examples" 3name = "embassy-stm32f7-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs
index c10781d0c..4a7bca1fa 100644
--- a/examples/stm32f7/src/bin/flash.rs
+++ b/examples/stm32f7/src/bin/flash.rs
@@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) {
19 // wait a bit before accessing the flash 19 // wait a bit before accessing the flash
20 Timer::after(Duration::from_millis(300)).await; 20 Timer::after(Duration::from_millis(300)).await;
21 21
22 let mut f = Flash::unlock(p.FLASH); 22 let mut f = Flash::new(p.FLASH);
23 23
24 info!("Reading..."); 24 info!("Reading...");
25 let mut buf = [0u8; 32]; 25 let mut buf = [0u8; 32];
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml
index 6baf17f36..f5673718d 100644
--- a/examples/stm32g0/Cargo.toml
+++ b/examples/stm32g0/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32g0-examples" 3name = "embassy-stm32g0-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml
index d8c05a979..ecda28805 100644
--- a/examples/stm32g4/Cargo.toml
+++ b/examples/stm32g4/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32g4-examples" 3name = "embassy-stm32g4-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml
index e725e03cb..1a05b9ecb 100644
--- a/examples/stm32h7/Cargo.toml
+++ b/examples/stm32h7/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32h7-examples" 3name = "embassy-stm32h7-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs
index 6682c64d5..ee86bdbf6 100644
--- a/examples/stm32h7/src/bin/flash.rs
+++ b/examples/stm32h7/src/bin/flash.rs
@@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) {
19 // wait a bit before accessing the flash 19 // wait a bit before accessing the flash
20 Timer::after(Duration::from_millis(300)).await; 20 Timer::after(Duration::from_millis(300)).await;
21 21
22 let mut f = Flash::unlock(p.FLASH); 22 let mut f = Flash::new(p.FLASH);
23 23
24 info!("Reading..."); 24 info!("Reading...");
25 let mut buf = [0u8; 32]; 25 let mut buf = [0u8; 32];
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml
index 7e61f0c19..7e1120f48 100644
--- a/examples/stm32l0/Cargo.toml
+++ b/examples/stm32l0/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32l0-examples" 3name = "embassy-stm32l0-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[features] 7[features]
7default = ["nightly"] 8default = ["nightly"]
diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs
index 867cb4d3e..ffe4fb10b 100644
--- a/examples/stm32l0/src/bin/flash.rs
+++ b/examples/stm32l0/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x26000; 16 const ADDR: u32 = 0x26000;
17 17
18 let mut f = Flash::unlock(p.FLASH); 18 let mut f = Flash::new(p.FLASH);
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml
index a943c73d2..9460febf5 100644
--- a/examples/stm32l1/Cargo.toml
+++ b/examples/stm32l1/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32l1-examples" 3name = "embassy-stm32l1-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs
index a76b9879f..476ed51a4 100644
--- a/examples/stm32l1/src/bin/flash.rs
+++ b/examples/stm32l1/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x26000; 16 const ADDR: u32 = 0x26000;
17 17
18 let mut f = Flash::unlock(p.FLASH); 18 let mut f = Flash::new(p.FLASH);
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml
index 2e2d07dc3..657605ebe 100644
--- a/examples/stm32l4/Cargo.toml
+++ b/examples/stm32l4/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32l4-examples" 3name = "embassy-stm32l4-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[features] 7[features]
7 8
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml
index 9ebab6476..63eac3ed2 100644
--- a/examples/stm32l5/Cargo.toml
+++ b/examples/stm32l5/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32l5-examples" 3name = "embassy-stm32l5-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[features] 7[features]
7 8
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml
index 164940586..3d704011b 100644
--- a/examples/stm32u5/Cargo.toml
+++ b/examples/stm32u5/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32u5-examples" 3name = "embassy-stm32u5-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml
index 923833e46..5b96fa191 100644
--- a/examples/stm32wb/Cargo.toml
+++ b/examples/stm32wb/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32wb-examples" 3name = "embassy-stm32wb-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml
index 94e0fb830..c827d2b71 100644
--- a/examples/stm32wl/Cargo.toml
+++ b/examples/stm32wl/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32wl-examples" 3name = "embassy-stm32wl-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs
index eb7489760..2a8880624 100644
--- a/examples/stm32wl/src/bin/flash.rs
+++ b/examples/stm32wl/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x36000; 16 const ADDR: u32 = 0x36000;
17 17
18 let mut f = Flash::unlock(p.FLASH); 18 let mut f = Flash::new(p.FLASH);
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml
index ea61fb921..e0e799a34 100644
--- a/examples/wasm/Cargo.toml
+++ b/examples/wasm/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-wasm-example" 3name = "embassy-wasm-example"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[lib] 7[lib]
7crate-type = ["cdylib"] 8crate-type = ["cdylib"]
diff --git a/stm32-gen-features/Cargo.toml b/stm32-gen-features/Cargo.toml
index f92d127ea..f4aa08ebe 100644
--- a/stm32-gen-features/Cargo.toml
+++ b/stm32-gen-features/Cargo.toml
@@ -2,6 +2,7 @@
2name = "gen_features" 2name = "gen_features"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 8
diff --git a/stm32-metapac-gen/Cargo.toml b/stm32-metapac-gen/Cargo.toml
index 0ec2075f3..3c1dab57a 100644
--- a/stm32-metapac-gen/Cargo.toml
+++ b/stm32-metapac-gen/Cargo.toml
@@ -2,6 +2,7 @@
2name = "stm32-metapac-gen" 2name = "stm32-metapac-gen"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5license = "MIT OR Apache-2.0"
5 6
6 7
7[dependencies] 8[dependencies]
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml
index 2745aef06..d6770d6e9 100644
--- a/tests/rp/Cargo.toml
+++ b/tests/rp/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-rp-tests" 3name = "embassy-rp-tests"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index daae3d464..bebbf557e 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "embassy-stm32-tests" 3name = "embassy-stm32-tests"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[features] 7[features]
7stm32f103c8 = ["embassy-stm32/stm32f103c8"] # Blue Pill 8stm32f103c8 = ["embassy-stm32/stm32f103c8"] # Blue Pill
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index d9d6c9b26..696cfdafe 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -2,6 +2,7 @@
2edition = "2021" 2edition = "2021"
3name = "xtask" 3name = "xtask"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0"
5 6
6[dependencies] 7[dependencies]
7anyhow = "1.0.43" 8anyhow = "1.0.43"