summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2021-05-10 00:24:24 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2021-05-10 00:24:24 +0200
commit8201255a9d6dde4b29a5a539a1d6aeefcbd467df (patch)
tree3366939a2c4b121091eb1abb3605f82e750b5c2f
parent7e0bf163f35dca8a1daba11429035a7780f5f4b7 (diff)
downloadnrf-softdevice-8201255a9d6dde4b29a5a539a1d6aeefcbd467df.zip
Update embassy
-rw-r--r--.vscode/settings.json1
-rw-r--r--Cargo.lock246
-rwxr-xr-xci.sh2
-rw-r--r--examples/Cargo.toml13
-rw-r--r--examples/src/bin/ble_bas_central.rs11
-rw-r--r--examples/src/bin/ble_bas_peripheral.rs13
-rw-r--r--examples/src/bin/ble_l2cap_central.rs10
-rw-r--r--examples/src/bin/ble_l2cap_peripheral.rs17
-rw-r--r--examples/src/bin/ble_peripheral_onoff.rs36
-rw-r--r--examples/src/bin/ble_scan.rs11
-rw-r--r--examples/src/bin/flash.rs15
-rw-r--r--examples/src/bin/rtic.rs168
-rw-r--r--examples/src/example_common.rs146
-rw-r--r--nrf-softdevice/src/flash.rs11
-rw-r--r--nrf-softdevice/src/lib.rs12
-rw-r--r--nrf-softdevice/src/softdevice.rs31
16 files changed, 158 insertions, 585 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 5f40426..953054c 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -6,6 +6,7 @@
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.procMacro.enable": true,
+ "rust-analyzer.assist.importMergeBehavior": "last",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
diff --git a/Cargo.lock b/Cargo.lock
index b15e6f9..1e994d4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14,9 +14,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
-version = "0.7.15"
+version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
+checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
@@ -54,18 +54,18 @@ dependencies = [
[[package]]
name = "atomic-polyfill"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b56892f5e1c2377f07ed6c7f5ca066d88b5ded79b052c44aa25f7d53c534227"
+checksum = "30302dda7a66f8c55932ebf208f7def840743ff64d495e9ceffcd97c18f11d39"
dependencies = [
"cortex-m 0.7.2",
]
[[package]]
-name = "autocfg"
-version = "1.0.1"
+name = "az"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+checksum = "822d7d63e0c0260a050f6b1f0d316f5c79b9eab830aca526ed904e1011bd64ca"
[[package]]
name = "bare-metal"
@@ -77,6 +77,12 @@ dependencies = [
]
[[package]]
+name = "bare-metal"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603"
+
+[[package]]
name = "bitfield"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -110,7 +116,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9075300b07c6a56263b9b582c214d0ff037b00d45ec9fde1cc711490c56f1bb9"
dependencies = [
"aligned",
- "bare-metal",
+ "bare-metal 0.2.5",
"bitfield",
"cortex-m 0.7.2",
"volatile-register",
@@ -122,7 +128,7 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643a210c1bdc23d0db511e2a576082f4ff4dcae9d0c37f50b431b8f8439d6d6b"
dependencies = [
- "bare-metal",
+ "bare-metal 0.2.5",
"bitfield",
"embedded-hal",
"volatile-register",
@@ -150,29 +156,14 @@ dependencies = [
]
[[package]]
-name = "cortex-m-rtic"
-version = "0.5.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa43f63284b363ac64f9ce5221a0f593b54f73258aba8e1a88c1feed8efdb664"
-dependencies = [
- "cortex-m 0.6.7",
- "cortex-m-rt",
- "cortex-m-rtic-macros",
- "heapless 0.6.1",
- "rtic-core",
- "version_check",
-]
-
-[[package]]
-name = "cortex-m-rtic-macros"
-version = "0.5.2"
+name = "critical-section"
+version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a1a6a4c9550373038c0e21a78d44d529bd697c25bbf6b8004bddc6e63b119c7"
+checksum = "48fd3697912f8f8a86f317ab6a67fb3aa46dcf7e0d1028f78520480cee82f295"
dependencies = [
- "proc-macro2",
- "quote",
- "rtic-syntax",
- "syn",
+ "bare-metal 1.0.0",
+ "cfg-if",
+ "cortex-m 0.7.2",
]
[[package]]
@@ -252,9 +243,10 @@ dependencies = [
[[package]]
name = "embassy"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#f14361835fb81726d71ac85f0f562ede8c1a6472"
+source = "git+https://github.com/embassy-rs/embassy#632572d1cb29ab6badb87c74a95c120b4238f7c6"
dependencies = [
"atomic-polyfill",
+ "cast",
"cortex-m 0.7.2",
"defmt",
"embassy-macros",
@@ -266,18 +258,20 @@ dependencies = [
[[package]]
name = "embassy-extras"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#f14361835fb81726d71ac85f0f562ede8c1a6472"
+source = "git+https://github.com/embassy-rs/embassy#632572d1cb29ab6badb87c74a95c120b4238f7c6"
dependencies = [
"cortex-m 0.7.2",
"embassy",
+ "usb-device",
]
[[package]]
name = "embassy-macros"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#f14361835fb81726d71ac85f0f562ede8c1a6472"
+source = "git+https://github.com/embassy-rs/embassy#632572d1cb29ab6badb87c74a95c120b4238f7c6"
dependencies = [
"darling",
+ "proc-macro2",
"quote",
"syn",
]
@@ -285,24 +279,24 @@ dependencies = [
[[package]]
name = "embassy-nrf"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#f14361835fb81726d71ac85f0f562ede8c1a6472"
+source = "git+https://github.com/embassy-rs/embassy#632572d1cb29ab6badb87c74a95c120b4238f7c6"
dependencies = [
"cortex-m 0.7.2",
"cortex-m-rt",
"defmt",
"embassy",
"embassy-extras",
+ "embassy-macros",
"embedded-dma",
"embedded-hal",
"futures",
- "nrf52840-hal",
"nrf52840-pac",
]
[[package]]
name = "embassy-traits"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#f14361835fb81726d71ac85f0f562ede8c1a6472"
+source = "git+https://github.com/embassy-rs/embassy#632572d1cb29ab6badb87c74a95c120b4238f7c6"
dependencies = [
"defmt",
"embedded-hal",
@@ -319,9 +313,9 @@ dependencies = [
[[package]]
name = "embedded-hal"
-version = "0.2.4"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb"
+checksum = "db184d3fa27bc7a2344250394c0264144dfe0bc81a4401801dcb964b8dd172ad"
dependencies = [
"nb 0.1.3",
"void",
@@ -329,10 +323,12 @@ dependencies = [
[[package]]
name = "fixed"
-version = "1.6.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ed9c66f2c3a8da3aed1c98c2bd9d345a213fcbeb0f408369a970ffdcdc86a3f"
+checksum = "699e185585f30812375dab120221f3451b063aeff29dadf6fd3a3ac2e30c8486"
dependencies = [
+ "az",
+ "half",
"typenum",
]
@@ -344,9 +340,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "futures"
-version = "0.3.13"
+version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1"
+checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253"
dependencies = [
"futures-channel",
"futures-core",
@@ -358,9 +354,9 @@ dependencies = [
[[package]]
name = "futures-channel"
-version = "0.3.13"
+version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939"
+checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25"
dependencies = [
"futures-core",
"futures-sink",
@@ -368,33 +364,33 @@ dependencies = [
[[package]]
name = "futures-core"
-version = "0.3.13"
+version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94"
+checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815"
[[package]]
name = "futures-io"
-version = "0.3.13"
+version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59"
+checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04"
[[package]]
name = "futures-sink"
-version = "0.3.13"
+version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3"
+checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23"
[[package]]
name = "futures-task"
-version = "0.3.13"
+version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80"
+checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc"
[[package]]
name = "futures-util"
-version = "0.3.13"
+version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1"
+checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025"
dependencies = [
"futures-core",
"futures-sink",
@@ -432,6 +428,12 @@ dependencies = [
]
[[package]]
+name = "half"
+version = "1.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3"
+
+[[package]]
name = "hash32"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -441,12 +443,6 @@ dependencies = [
]
[[package]]
-name = "hashbrown"
-version = "0.9.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
-
-[[package]]
name = "heapless"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -459,34 +455,12 @@ dependencies = [
]
[[package]]
-name = "heapless"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634bd4d29cbf24424d0a4bfcbf80c6960129dc24424752a7d1d1390607023422"
-dependencies = [
- "as-slice",
- "generic-array 0.14.4",
- "hash32",
- "stable_deref_trait",
-]
-
-[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
-name = "indexmap"
-version = "1.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
-dependencies = [
- "autocfg",
- "hashbrown",
-]
-
-[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -509,9 +483,9 @@ dependencies = [
[[package]]
name = "memchr"
-version = "2.3.4"
+version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
+checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "nb"
@@ -529,33 +503,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae"
[[package]]
-name = "nrf-hal-common"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e3ce1e61f6222645cf43103bb3c2ad2cbf5227496586aaeab299c79b03c5730"
-dependencies = [
- "cast",
- "cfg-if",
- "cortex-m 0.6.7",
- "embedded-dma",
- "embedded-hal",
- "fixed",
- "nb 1.0.0",
- "nrf52840-pac",
- "rand_core",
- "void",
-]
-
-[[package]]
name = "nrf-softdevice"
version = "0.1.0"
dependencies = [
"cortex-m 0.6.7",
"cortex-m-rt",
+ "critical-section",
"defmt",
"embassy",
"fixed",
- "heapless 0.5.6",
+ "heapless",
"log",
"nrf-softdevice-macro",
"nrf-softdevice-s112",
@@ -576,6 +533,7 @@ name = "nrf-softdevice-defmt-rtt"
version = "0.1.0"
dependencies = [
"cortex-m 0.6.7",
+ "critical-section",
"defmt",
"nrf-softdevice",
]
@@ -587,18 +545,16 @@ dependencies = [
"alloc-cortex-m",
"cortex-m 0.6.7",
"cortex-m-rt",
- "cortex-m-rtic",
"defmt",
"embassy",
"embassy-nrf",
"embassy-traits",
"fixed",
"futures",
- "heapless 0.5.6",
+ "heapless",
"nrf-softdevice",
"nrf-softdevice-defmt-rtt",
"nrf-softdevice-s140",
- "nrf52840-hal",
"panic-probe",
]
@@ -644,7 +600,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "136a10e0a338c3b46370a37c7986d78880714abae701d6a9a5fbdfde9a6397ea"
dependencies = [
- "bare-metal",
+ "bare-metal 0.2.5",
"cortex-m 0.6.7",
"cortex-m-rt",
"vcell",
@@ -656,7 +612,7 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ef7b4920d2f4316e54af7180bef23d64b5749eaa48ddb22398026c14e716036"
dependencies = [
- "bare-metal",
+ "bare-metal 0.2.5",
"cortex-m 0.6.7",
"cortex-m-rt",
"vcell",
@@ -668,7 +624,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72920484274fae0792a40345049da2723612465c7202561b6a17ad3c127259db"
dependencies = [
- "bare-metal",
+ "bare-metal 0.2.5",
"cortex-m 0.6.7",
"cortex-m-rt",
"vcell",
@@ -680,30 +636,19 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed3dee38c8f33516f9fab44ac568f79f82cfcd0d5747f1cb6276a17d0fd9801d"
dependencies = [
- "bare-metal",
+ "bare-metal 0.2.5",
"cortex-m 0.6.7",
"cortex-m-rt",
"vcell",
]
[[package]]
-name = "nrf52840-hal"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc4324000cdeb61b5e95b9cd5a1ce73f1cafa532fcedd63ea8d07685f21b001c"
-dependencies = [
- "embedded-hal",
- "nrf-hal-common",
- "nrf52840-pac",
-]
-
-[[package]]
name = "nrf52840-pac"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1b780a5afd2621774652f28c82837f6aa6d19cf0ad71c734fc1fe53298a2d73"
dependencies = [
- "bare-metal",
+ "bare-metal 0.2.5",
"cortex-m 0.6.7",
"cortex-m-rt",
"vcell",
@@ -751,18 +696,18 @@ dependencies = [
[[package]]
name = "pin-project"
-version = "1.0.5"
+version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63"
+checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
-version = "1.0.5"
+version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
+checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f"
dependencies = [
"proc-macro2",
"quote",
@@ -783,9 +728,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "proc-macro2"
-version = "1.0.24"
+version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
+checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
dependencies = [
"unicode-xid",
]
@@ -806,16 +751,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f"
[[package]]
-name = "rand_core"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
-
-[[package]]
name = "regex"
-version = "1.4.5"
+version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
+checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
@@ -824,26 +763,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.23"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
-
-[[package]]
-name = "rtic-core"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8bd58a6949de8ff797a346a28d9f13f7b8f54fa61bb5e3cb0985a4efb497a5ef"
-
-[[package]]
-name = "rtic-syntax"
-version = "0.4.0"
+version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8152fcaa845720d61e6cc570548b89144c2c307f18a480bbd97e55e9f6eeff04"
-dependencies = [
- "indexmap",
- "proc-macro2",
- "syn",
-]
+checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rustc_version"
@@ -901,9 +823,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]]
name = "syn"
-version = "1.0.64"
+version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f"
+checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
dependencies = [
"proc-macro2",
"quote",
@@ -924,9 +846,15 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unicode-xid"
-version = "0.2.1"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
+
+[[package]]
+name = "usb-device"
+version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
+checksum = "6be90410d4772074ea49525e2e753b65920b94b57eee21a6ef7b6a6fe6296245"
[[package]]
name = "uuid"
diff --git a/ci.sh b/ci.sh
index 4e89ded..c566e74 100755
--- a/ci.sh
+++ b/ci.sh
@@ -5,7 +5,7 @@ set -euxo pipefail
# build examples
#==================
-(cd examples; cargo build --target thumbv7em-none-eabihf --features cortex-m-rtic --bins)
+(cd examples; cargo build --target thumbv7em-none-eabihf --bins)
# build with log/defmt combinations
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 09449c6..6b54d8a 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -28,23 +28,16 @@ embassy-traits = { version = "0.1.0", features = ["defmt"]}
embassy-nrf = { version = "0.1.0", features = [ "defmt", "52840" ]}
cortex-m = { version = "0.6.4" }
cortex-m-rt = "0.6.13"
-cortex-m-rtic = { version = "0.5.5", optional = true }
defmt = { version = "0.2.0", features = ["alloc"] }
nrf-softdevice-defmt-rtt = { path = "../nrf-softdevice-defmt-rtt", version = "0.1.0" }
panic-probe = "0.1.0"
-nrf52840-hal = { version = "0.12.0" }
-nrf-softdevice = { version = "0.1.0", path = "../nrf-softdevice", features = ["defmt", "defmt-trace", "nrf52840", "s140", "ble-peripheral", "ble-central"] }
+nrf-softdevice = { version = "0.1.0", path = "../nrf-softdevice", features = ["defmt", "defmt-trace", "nrf52840", "s140", "ble-peripheral", "ble-central", "critical-section-impl"] }
nrf-softdevice-s140 = { version = "0.1.1", path = "../nrf-softdevice-s140" }
futures = { version = "0.3.5", default-features = false }
fixed = "1.2.0"
heapless = "0.5.6"
alloc-cortex-m = "0.4.0"
-
-[[bin]]
-name = "rtic"
-required-features = ["cortex-m-rtic"]
-
[[bin]]
name = "ble_bas_peripheral"
required-features = ["ble-gatt-server"]
@@ -60,7 +53,3 @@ required-features = ["ble-gatt-server"]
[[bin]]
name = "flash"
required-features = []
-
-[[bin]]
-name = "interrupts"
-required-features = []
diff --git a/examples/src/bin/ble_bas_central.rs b/examples/src/bin/ble_bas_central.rs
index 5e56d9d..8911ca8 100644
--- a/examples/src/bin/ble_bas_central.rs
+++ b/examples/src/bin/ble_bas_central.rs
@@ -4,16 +4,16 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(alloc_error_handler)]
+#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
-use example_common::*;
use core::mem;
use cortex_m_rt::entry;
use defmt::info;
use defmt::*;
-use embassy::executor::{task, Executor};
+use embassy::executor::Executor;
use embassy::util::Forever;
use nrf_softdevice::ble::{central, gatt_client, Address, AddressType};
@@ -22,7 +22,7 @@ use nrf_softdevice::Softdevice;
static EXECUTOR: Forever<Executor> = Forever::new();
-#[task]
+#[embassy::task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
@@ -33,7 +33,7 @@ struct BatteryServiceClient {
battery_level: u8,
}
-#[task]
+#[embassy::task]
async fn ble_central_task(sd: &'static Softdevice) {
let addrs = &[&Address::new(
AddressType::RandomStatic,
@@ -97,8 +97,7 @@ fn main() -> ! {
..Default::default()
};
- let (sdp, _p) = take_peripherals();
- let sd = Softdevice::enable(sdp, &config);
+ let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
diff --git a/examples/src/bin/ble_bas_peripheral.rs b/examples/src/bin/ble_bas_peripheral.rs
index e2a7846..949a5cc 100644
--- a/examples/src/bin/ble_bas_peripheral.rs
+++ b/examples/src/bin/ble_bas_peripheral.rs
@@ -4,24 +4,24 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(alloc_error_handler)]
+#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
-use example_common::*;
use core::mem;
use cortex_m_rt::entry;
use defmt::info;
use defmt::*;
+use embassy::executor::Executor;
+use embassy::util::Forever;
use nrf_softdevice::ble::{gatt_server, peripheral};
use nrf_softdevice::{raw, Softdevice};
-use embassy::executor::{task, Executor};
-use embassy::util::Forever;
static EXECUTOR: Forever<Executor> = Forever::new();
-#[task]
+#[embassy::task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
@@ -34,7 +34,7 @@ struct BatteryService {
foo: u16,
}
-#[task]
+#[embassy::task]
async fn bluetooth_task(sd: &'static Softdevice) {
let server: BatteryService = unwrap!(gatt_server::register(sd));
#[rustfmt::skip]
@@ -127,8 +127,7 @@ fn main() -> ! {
..Default::default()
};
- let (sdp, _p) = take_peripherals();
- let sd = Softdevice::enable(sdp, &config);
+ let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
diff --git a/examples/src/bin/ble_l2cap_central.rs b/examples/src/bin/ble_l2cap_central.rs
index 179fff7..1bb4e3f 100644
--- a/examples/src/bin/ble_l2cap_central.rs
+++ b/examples/src/bin/ble_l2cap_central.rs
@@ -4,6 +4,7 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(alloc_error_handler)]
+#![allow(incomplete_features)]
extern crate alloc;
#[path = "../example_common.rs"]
@@ -16,7 +17,7 @@ use core::slice;
use cortex_m_rt::entry;
use defmt::info;
use defmt::*;
-use embassy::executor::{task, Executor};
+use embassy::executor::Executor;
use embassy::util::Forever;
use nrf_softdevice::ble::l2cap::Packet as _;
@@ -28,12 +29,12 @@ static EXECUTOR: Forever<Executor> = Forever::new();
const PSM: u16 = 0x2349;
-#[task]
+#[embassy::task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
-#[task]
+#[embassy::task]
async fn ble_central_task(sd: &'static Softdevice) {
info!("Scanning for peer...");
@@ -173,8 +174,7 @@ fn main() -> ! {
..Default::default()
};
- let (sdp, _p) = take_peripherals();
- let sd = Softdevice::enable(sdp, &config);
+ let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
diff --git a/examples/src/bin/ble_l2cap_peripheral.rs b/examples/src/bin/ble_l2cap_peripheral.rs
index c88869f..0ab7369 100644
--- a/examples/src/bin/ble_l2cap_peripheral.rs
+++ b/examples/src/bin/ble_l2cap_peripheral.rs
@@ -4,33 +4,33 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(alloc_error_handler)]
+#![allow(incomplete_features)]
extern crate alloc;
#[path = "../example_common.rs"]
mod example_common;
-use example_common::*;
use core::mem;
use core::ptr::NonNull;
use cortex_m_rt::entry;
use defmt::*;
+use embassy::executor::Executor;
+use embassy::util::Forever;
-use nrf_softdevice::ble;
use nrf_softdevice::ble::{l2cap, peripheral};
+use nrf_softdevice::{ble, RawError};
use nrf_softdevice::{raw, Softdevice};
-use embassy::executor::{task, Executor};
-use embassy::util::Forever;
static EXECUTOR: Forever<Executor> = Forever::new();
const PSM: u16 = 0x2349;
-#[task]
+#[embassy::task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
-#[task]
+#[embassy::task]
async fn bluetooth_task(sd: &'static Softdevice) {
info!("My address: {:?}", ble::get_address(sd));
@@ -147,8 +147,9 @@ fn main() -> ! {
..Default::default()
};
- let (sdp, _p) = take_peripherals();
- let sd = Softdevice::enable(sdp, &config);
+ unwrap!(RawError::convert(unsafe { raw::sd_clock_hfclk_request() }));
+
+ let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs
index b8535a0..8e53c15 100644
--- a/examples/src/bin/ble_peripheral_onoff.rs
+++ b/examples/src/bin/ble_peripheral_onoff.rs
@@ -4,28 +4,28 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(alloc_error_handler)]
+#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
-use example_common::*;
use core::mem;
use cortex_m_rt::entry;
use defmt::{panic, *};
-use embassy::executor::{task, Executor};
+use embassy::executor::Executor;
use embassy::traits::gpio::WaitForLow;
use embassy::util::Forever;
-use embassy_nrf::gpiote::{Gpiote, GpiotePin};
+use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
+use embassy_nrf::gpiote::{self, PortInput};
use embassy_nrf::interrupt;
use futures::pin_mut;
-use nrf52840_hal::gpio;
use nrf_softdevice::ble::{gatt_server, peripheral};
-use nrf_softdevice::{pac, raw, Softdevice};
+use nrf_softdevice::{raw, Softdevice};
static EXECUTOR: Forever<Executor> = Forever::new();
-#[task]
+#[embassy::task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
@@ -76,18 +76,20 @@ async fn run_bluetooth(sd: &'static Softdevice, server: &FooService) {
}
}
-#[task]
-async fn bluetooth_task(sd: &'static Softdevice, gpiote: pac::GPIOTE, p0: pac::P0) {
+#[embassy::task]
+async fn bluetooth_task(
+ sd: &'static Softdevice,
+ gpiote: gpiote::Initialized,
+ button1: AnyPin,
+ button2: AnyPin,
+) {
let server: FooService = unwrap!(gatt_server::register(sd));
- let port0 = gpio::p0::Parts::new(p0);
- let (gpiote, _) = Gpiote::new(gpiote, interrupt::take!(GPIOTE));
-
info!("Bluetooth is OFF");
info!("Press nrf52840-dk button 1 to enable, button 2 to disable");
- let button1 = GpiotePin::new(gpiote, port0.p0_11.into_pullup_input().degrade());
- let button2 = GpiotePin::new(gpiote, port0.p0_12.into_pullup_input().degrade());
+ let button1 = PortInput::new(gpiote, Input::new(button1, Pull::Up));
+ let button2 = PortInput::new(gpiote, Input::new(button2, Pull::Up));
pin_mut!(button1);
pin_mut!(button2);
loop {
@@ -163,12 +165,14 @@ fn main() -> ! {
..Default::default()
};
- let (sdp, p) = take_peripherals();
- let sd = Softdevice::enable(sdp, &config);
+ let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
+ let p = embassy_nrf::Peripherals::take().unwrap();
+ let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
+
unwrap!(spawner.spawn(softdevice_task(sd)));
- unwrap!(spawner.spawn(bluetooth_task(sd, p.GPIOTE, p.P0,)));
+ unwrap!(spawner.spawn(bluetooth_task(sd, g, p.P0_11.degrade(), p.P0_12.degrade())));
});
}
diff --git a/examples/src/bin/ble_scan.rs b/examples/src/bin/ble_scan.rs
index b0b3421..df23162 100644
--- a/examples/src/bin/ble_scan.rs
+++ b/examples/src/bin/ble_scan.rs
@@ -4,16 +4,16 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(alloc_error_handler)]
+#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
-use example_common::*;
use core::mem;
use core::slice;
use cortex_m_rt::entry;
use defmt::*;
-use embassy::executor::{task, Executor};
+use embassy::executor::Executor;
use embassy::util::Forever;
use nrf_softdevice::ble::central;
@@ -22,12 +22,12 @@ use nrf_softdevice::Softdevice;
static EXECUTOR: Forever<Executor> = Forever::new();
-#[task]
+#[embassy::task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
-#[task]
+#[embassy::task]
async fn ble_task(sd: &'static Softdevice) {
let config = central::ScanConfig::default();
let res = central::scan(sd, &config, |params| unsafe {
@@ -108,8 +108,7 @@ fn main() -> ! {
..Default::default()
};
- let (sdp, _p) = take_peripherals();
- let sd = Softdevice::enable(sdp, &config);
+ let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
diff --git a/examples/src/bin/flash.rs b/examples/src/bin/flash.rs
index 174151d..3e5fe57 100644
--- a/examples/src/bin/flash.rs
+++ b/examples/src/bin/flash.rs
@@ -4,30 +4,30 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(alloc_error_handler)]
+#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
-use example_common::*;
use cortex_m_rt::entry;
use defmt::*;
-use embassy::executor::{task, Executor};
+use embassy::executor::Executor;
use embassy::traits::flash::Flash as _;
use embassy::util::Forever;
-
use futures::pin_mut;
+
use nrf_softdevice::{Flash, Softdevice};
static EXECUTOR: Forever<Executor> = Forever::new();
-#[task]
+#[embassy::task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
-#[task]
+#[embassy::task]
async fn flash_task(sd: &'static Softdevice) {
- let mut f = Flash::take(sd);
+ let f = Flash::take(sd);
pin_mut!(f);
info!("starting erase");
@@ -43,8 +43,7 @@ async fn flash_task(sd: &'static Softdevice) {
fn main() -> ! {
info!("Hello World!");
- let (sdp, _p) = take_peripherals();
- let sd = Softdevice::enable(sdp, &Default::default());
+ let sd = Softdevice::enable(&Default::default());
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
diff --git a/examples/src/bin/rtic.rs b/examples/src/bin/rtic.rs
deleted file mode 100644
index f7511f6..0000000
--- a/examples/src/bin/rtic.rs
+++ /dev/null
@@ -1,168 +0,0 @@
-//! This example showcases how to use nrf-softdevice inside RTIC.
-//!
-//! It mixes RTIC's real-time interrupt-based multitasking with
-//! static-executor's cooperative async/await multitasking.
-//!
-//! static-executor is run in RTIC's idle task, at lowest priority, so all RTIC
-//! tasks will preempt async tasks if needed.
-//!
-//! Note that this is not fully safe: you must not use the softdevice's reserved
-//! priorities for RTIC tasks. There is no compile-time checking for that for now.
-
-#![no_main]
-#![no_std]
-#![feature(type_alias_impl_trait)]
-#![feature(min_type_alias_impl_trait)]
-#![feature(impl_trait_in_bindings)]
-#![feature(alloc_error_handler)]
-
-#[path = "../example_common.rs"]
-mod example_common;
-use example_common::*;
-
-use core::mem;
-use defmt::*;
-use embassy::executor::{task, Executor};
-use embassy::util::Forever;
-use nrf52840_hal::pac::TIMER1;
-use nrf52840_hal::prelude::*;
-use nrf52840_hal::timer::{Periodic, Timer};
-use rtic::app;
-
-use nrf_softdevice::ble::peripheral;
-use nrf_softdevice::{raw, temperature_celsius, Softdevice};
-
-static EXECUTOR: Forever<Executor> = Forever::new();
-
-#[task]
-async fn softdevice_task(sd: &'static Softdevice) {
- sd.run().await;
-}
-
-#[task]
-async fn bluetooth_task(sd: &'static Softdevice) {
- #[rustfmt::skip]
- let adv_data = &[
- 0x02, 0x01, raw::BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE as u8,
- 0x03, 0x03, 0x09, 0x18,
- 0x0a, 0x09, b'H', b'e', b'l', b'l', b'o', b'R', b'T', b'I', b'C',
- ];
- #[rustfmt::skip]
- let scan_data = &[
- 0x03, 0x03, 0x09, 0x18,
- ];
-
- loop {
- let config = peripheral::Config::default();
- let adv = peripheral::ConnectableAdvertisement::ScannableUndirected {
- adv_data,
- scan_data,
- };
- let _conn = unwrap!(peripheral::advertise(sd, adv, &config).await);
-
- info!("advertising done!");
- }
-}
-
-#[app(device = nrf52840_hal::pac, peripherals = true)]
-const APP: () = {
- struct Resources {
- timer: Timer<TIMER1, Periodic>,
- sd_peripherals: Option<nrf_softdevice::Peripherals>,
- }
-
- #[init()]
- fn init(cx: init::Context) -> init::LateResources {
- info!("init");
-
- let mut timer = Timer::new(cx.device.TIMER1);
- timer.enable_interrupt();
- let mut timer = timer.into_periodic();
- timer.start(1_000_000u32); // 1Mhz, so once per second
-
- let sd_peripherals = nrf_softdevice::Peripherals {
- AAR: cx.device.AAR,
- ACL: cx.device.ACL,
- CCM: cx.device.CCM,
- CLOCK: cx.device.CLOCK,
- ECB: cx.device.ECB,
- EGU1: cx.device.EGU1,
- EGU2: cx.device.EGU2,
- EGU5: cx.device.EGU5,
- MWU: cx.device.MWU,
- NVMC: cx.device.NVMC,
- POWER: cx.device.POWER,
- RADIO: cx.device.RADIO,
- RNG: cx.device.RNG,
- RTC0: cx.device.RTC0,
- SWI1: cx.device.SWI1,
- SWI2: cx.device.SWI2,
- SWI5: cx.device.SWI5,
- TEMP: cx.device.TEMP,
- TIMER0: cx.device.TIMER0,
- };
-
- init::LateResources {
- timer,
- sd_peripherals: Some(sd_peripherals),
- }
- }
-
- #[idle(resources=[sd_peripherals])]
- fn idle(cx: idle::Context) -> ! {
- let config = nrf_softdevice::Config {
- clock: Some(raw::nrf_clock_lf_cfg_t {
- source: raw::NRF_CLOCK_LF_SRC_XTAL as u8,
- rc_ctiv: 0,
- rc_temp_ctiv: 0,
- accuracy: 7,
- }),
- conn_gap: Some(raw::ble_gap_conn_cfg_t {
- conn_count: 6,
- event_length: 6,
- }),
- conn_gatt: Some(raw::ble_gatt_conn_cfg_t { att_mtu: 128 }),
- gatts_attr_tab_size: Some(raw::ble_gatts_cfg_attr_tab_size_t {
- attr_tab_size: 32768,
- }),
- gap_role_count: Some(raw::ble_gap_cfg_role_count_t {
- adv_set_count: 1,
- periph_role_count: 3,
- central_role_count: 3,
- central_sec_count: 0,
- _bitfield_1: raw::ble_gap_cfg_role_count_t::new_bitfield_1(0),
- }),
- gap_device_name: Some(raw::ble_gap_cfg_device_name_t {
- p_value: b"HelloRTIC" as *const u8 as _,
- current_len: 9,
- max_len: 9,
- write_perm: unsafe { mem::zeroed() },
- _bitfield_1: raw::ble_gap_cfg_device_name_t::new_bitfield_1(
- raw::BLE_GATTS_VLOC_STACK as u8,
- ),
- }),
- ..Default::default()
- };
-
- // Softdevice enable must not be done in RTIC init
- // because RTIC runs init with interrupts disabled, and the
- // softdevice crashes if it's enabled with interrupts disabled.
- let sdp = cx.resources.sd_peripherals.take().unwrap();
- let sd = Softdevice::enable(sdp, &config);
-
- let temp = unwrap!(temperature_celsius(&sd));
- info!("{}°C", temp.to_num::<i32>());
-
- let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
- unwrap!(spawner.spawn(softdevice_task(sd)));
- unwrap!(spawner.spawn(bluetooth_task(sd)));
- });
- }
-
- #[task(binds = TIMER1, resources = [timer], priority = 1)]
- fn exec(cx: exec::Context) {
- cx.resources.timer.wait().unwrap();
- info!("tick");
- }
-};
diff --git a/examples/src/example_common.rs b/examples/src/example_common.rs
index c73099d..503e67a 100644
--- a/examples/src/example_common.rs
+++ b/examples/src/example_common.rs
@@ -1,14 +1,12 @@
#![macro_use]
-use nrf52840_hal as _;
-use nrf_softdevice::pac;
use nrf_softdevice_defmt_rtt as _; // global logger
use panic_probe as _;
use alloc_cortex_m::CortexMHeap;
use core::alloc::Layout;
use core::sync::atomic::{AtomicUsize, Ordering};
-use defmt::{panic, *};
+use defmt::panic;
// this is the allocator the application will use
#[global_allocator]
@@ -30,145 +28,3 @@ defmt::timestamp! {"{=u64}", {
n as u64
}
}
-
-// Take peripherals, split by softdevice and application
-pub fn take_peripherals() -> (nrf_softdevice::Peripherals, Peripherals) {
- // Initialize the allocator BEFORE you use it
- unsafe { ALLOCATOR.init(cortex_m_rt::heap_start() as usize, HEAP_SIZE) }
-
- let p = unwrap!(pac::Peripherals::take());
-
- (
- nrf_softdevice::Peripherals {
- AAR: p.AAR,
- ACL: p.ACL,
- CCM: p.CCM,
- CLOCK: p.CLOCK,
- ECB: p.ECB,
- EGU1: p.EGU1,
- EGU2: p.EGU2,
- EGU5: p.EGU5,
- MWU: p.MWU,
- NVMC: p.NVMC,
- POWER: p.POWER,
- RADIO: p.RADIO,
- RNG: p.RNG,
- RTC0: p.RTC0,
- SWI1: p.SWI1,
- SWI2: p.SWI2,
- SWI5: p.SWI5,
- TEMP: p.TEMP,
- TIMER0: p.TIMER0,
- },
- Peripherals {
- CC_HOST_RGF: p.CC_HOST_RGF,
- COMP: p.COMP,
- CRYPTOCELL: p.CRYPTOCELL,
- EGU0: p.EGU0,
- EGU3: p.EGU3,
- EGU4: p.EGU4,
- FICR: p.FICR,
- GPIOTE: p.GPIOTE,
- I2S: p.I2S,
- LPCOMP: p.LPCOMP,
- NFCT: p.NFCT,
- P0: p.P0,
- P1: p.P1,
- PDM: p.PDM,
- PPI: p.PPI,
- PWM0: p.PWM0,
- PWM1: p.PWM1,
- PWM2: p.PWM2,
- PWM3: p.PWM3,
- QDEC: p.QDEC,
- QSPI: p.QSPI,
- RTC2: p.RTC2,
- SAADC: p.SAADC,
- SPI0: p.SPI0,
- SPI1: p.SPI1,
- SPI2: p.SPI2,
- SPIM0: p.SPIM0,
- SPIM1: p.SPIM1,
- SPIM2: p.SPIM2,
- SPIM3: p.SPIM3,
- SPIS0: p.SPIS0,
- SPIS1: p.SPIS1,
- SPIS2: p.SPIS2,
- SWI0: p.SWI0,
- SWI3: p.SWI3,
- SWI4: p.SWI4,
- TIMER1: p.TIMER1,
- TIMER2: p.TIMER2,
- TIMER3: p.TIMER3,
- TIMER4: p.TIMER4,
- TWI0: p.TWI0,
- TWI1: p.TWI1,
- TWIM0: p.TWIM0,
- TWIM1: p.TWIM1,
- TWIS0: p.TWIS0,
- TWIS1: p.TWIS1,
- UART0: p.UART0,
- UARTE0: p.UARTE0,
- UARTE1: p.UARTE1,
- UICR: p.UICR,
- USBD: p.USBD,
- WDT: p.WDT,
- },
- )
-}
-
-#[allow(non_snake_case)]
-pub struct Peripherals {
- pub CC_HOST_RGF: pac::CC_HOST_RGF,
- pub COMP: pac::COMP,
- pub CRYPTOCELL: pac::CRYPTOCELL,
- pub EGU0: pac::EGU0,
- pub EGU3: pac::EGU3,
- pub EGU4: pac::EGU4,
- pub FICR: pac::FICR,
- pub GPIOTE: pac::GPIOTE,
- pub I2S: pac::I2S,
- pub LPCOMP: pac::LPCOMP,
- pub NFCT: pac::NFCT,
- pub P0: pac::P0,
- pub P1: pac::P1,
- pub PDM: pac::PDM,
- pub PPI: pac::PPI,
- pub PWM0: pac::PWM0,
- pub PWM1: pac::PWM1,
- pub PWM2: pac::PWM2,
- pub PWM3: pac::PWM3,
- pub QDEC: pac::QDEC,
- pub QSPI: pac::QSPI,
- pub RTC2: pac::RTC2,
- pub SAADC: pac::SAADC,
- pub SPI0: pac::SPI0,
- pub SPI1: pac::SPI1,
- pub SPI2: pac::SPI2,
- pub SPIM0: pac::SPIM0,
- pub SPIM1: pac::SPIM1,
- pub SPIM2: pac::SPIM2,
- pub SPIM3: pac::SPIM3,
- pub SPIS0: pac::SPIS0,
- pub SPIS1: pac::SPIS1,
- pub SPIS2: pac::SPIS2,
- pub SWI0: pac::SWI0,
- pub SWI3: pac::SWI3,
- pub SWI4: pac::SWI4,
- pub TIMER1: pac::TIMER1,
- pub TIMER2: pac::TIMER2,
- pub TIMER3: pac::TIMER3,
- pub TIMER4: pac::TIMER4,
- pub TWI0: pac::TWI0,
- pub TWI1: pac::TWI1,
- pub TWIM0: pac::TWIM0,
- pub TWIM1: pac::TWIM1,
- pub TWIS0: pac::TWIS0,
- pub TWIS1: pac::TWIS1,
- pub UART0: pac::UART0,
- pub UARTE0: pac::UARTE0,
- pub UARTE1: pac::UARTE1,
- pub UICR: pac::UICR,
- pub USBD: pac::USBD,
- pub WDT: pac::WDT,
-}
diff --git a/nrf-softdevice/src/flash.rs b/nrf-softdevice/src/flash.rs
index 4fd2db6..7ff40ad 100644
--- a/nrf-softdevice/src/flash.rs
+++ b/nrf-softdevice/src/flash.rs
@@ -1,6 +1,5 @@
use core::future::Future;
use core::marker::PhantomData;
-use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
use embassy::traits::flash::Error as FlashError;
@@ -54,11 +53,7 @@ impl embassy::traits::flash::Flash for Flash {
type WriteFuture<'a> = impl Future<Output = Result<(), FlashError>> + 'a;
type ErasePageFuture<'a> = impl Future<Output = Result<(), FlashError>> + 'a;
- fn read<'a>(
- self: Pin<&'a mut Self>,
- address: usize,
- data: &'a mut [u8],
- ) -> Self::ReadFuture<'a> {
+ fn read<'a>(&'a mut self, address: usize, data: &'a mut [u8]) -> Self::ReadFuture<'a> {
async move {
// Reading is simple since SoC flash is memory-mapped :)
// TODO check addr/len is in bounds.
@@ -71,7 +66,7 @@ impl embassy::traits::flash::Flash for Flash {
}
}
- fn write<'a>(self: Pin<&'a mut Self>, address: usize, data: &'a [u8]) -> Self::WriteFuture<'a> {
+ fn write<'a>(&'a mut self, address: usize, data: &'a [u8]) -> Self::WriteFuture<'a> {
async move {
let data_ptr = data.as_ptr();
let data_len = data.len() as u32;
@@ -102,7 +97,7 @@ impl embassy::traits::flash::Flash for Flash {
}
}
- fn erase<'a>(self: Pin<&'a mut Self>, address: usize) -> Self::ErasePageFuture<'a> {
+ fn erase<'a>(&'a mut self, address: usize) -> Self::ErasePageFuture<'a> {
async move {
if address % Self::PAGE_SIZE != 0 {
return Err(FlashError::AddressMisaligned);
diff --git a/nrf-softdevice/src/lib.rs b/nrf-softdevice/src/lib.rs
index ecb67f8..273a255 100644
--- a/nrf-softdevice/src/lib.rs
+++ b/nrf-softdevice/src/lib.rs
@@ -4,7 +4,7 @@
#![feature(type_alias_impl_trait)]
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
-#![feature(const_fn)]
+#![feature(const_fn_trait_bound)]
#![feature(cell_update)]
#![allow(incomplete_features)]
@@ -109,15 +109,15 @@ compile_error!("The selected softdevice does not support ble-peripheral.");
compile_error!("The selected softdevice does not support ble-l2cap.");
#[cfg(feature = "nrf52810")]
-pub use nrf52810_pac as pac;
+use nrf52810_pac as pac;
#[cfg(feature = "nrf52811")]
-pub use nrf52811_pac as pac;
+use nrf52811_pac as pac;
#[cfg(feature = "nrf52832")]
-pub use nrf52832_pac as pac;
+use nrf52832_pac as pac;
#[cfg(feature = "nrf52833")]
-pub use nrf52833_pac as pac;
+use nrf52833_pac as pac;
#[cfg(feature = "nrf52840")]
-pub use nrf52840_pac as pac;
+use nrf52840_pac as pac;
#[cfg(feature = "s112")]
pub use nrf_softdevice_s112 as raw;
diff --git a/nrf-softdevice/src/softdevice.rs b/nrf-softdevice/src/softdevice.rs
index b4cc9fa..5f003e5 100644
--- a/nrf-softdevice/src/softdevice.rs
+++ b/nrf-softdevice/src/softdevice.rs
@@ -29,35 +29,6 @@ unsafe extern "C" fn fault_handler(id: u32, pc: u32, info: u32) {
}
}
-#[allow(non_snake_case)]
-pub struct Peripherals {
- pub AAR: pac::AAR,
- #[cfg(not(any(feature = "nrf52810", feature = "nrf52811", feature = "nrf52832")))]
- pub ACL: pac::ACL,
- #[cfg(any(feature = "nrf52810", feature = "nrf52811", feature = "nrf52832"))]
- pub BPROT: pac::BPROT,
- pub CCM: pac::CCM,
- pub CLOCK: pac::CLOCK,
- pub ECB: pac::ECB,
- pub EGU1: pac::EGU1,
- #[cfg(not(any(feature = "nrf52810", feature = "nrf52811")))]
- pub EGU2: pac::EGU2,
- #[cfg(not(any(feature = "nrf52810", feature = "nrf52811")))]
- pub EGU5: pac::EGU5,
- #[cfg(any(feature = "nrf52832", feature = "nrf52833", feature = "nrf52840"))]
- pub MWU: pac::MWU,
- pub NVMC: pac::NVMC,
- pub POWER: pac::POWER,
- pub RADIO: pac::RADIO,
- pub RNG: pac::RNG,
- pub RTC0: pac::RTC0,
- pub SWI1: pac::SWI1,
- pub SWI2: pac::SWI2,
- pub SWI5: pac::SWI5,
- pub TEMP: pac::TEMP,
- pub TIMER0: pac::TIMER0,
-}
-
/// Singleton instance of the enabled softdevice.
///
/// The `Softdevice` instance can be obtaind by enabling it with [`Softdevice::enable`]. Once
@@ -125,7 +96,7 @@ impl Softdevice {
/// - Panics if the requested configuration requires more memory than reserved for the softdevice. In that case, you can give more memory to the softdevice by editing the RAM start address in `memory.x`. The required start address is logged prior to panic.
/// - Panics if the requested configuration has too high memory requirements for the softdevice. The softdevice supports a maximum dynamic memory size of 64kb.
/// - Panics if called multiple times. Must be called at most once.
- pub fn enable(_peripherals: Peripherals, config: &Config) -> &'static Softdevice {
+ pub fn enable(config: &Config) -> &'static Softdevice {
if ENABLED
.compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire)
.is_err()