From 1094ac4d82c9c8eab75d3199a7da4e8db6d096b9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 18 Aug 2021 23:35:38 +0200 Subject: Update rust, embassy, PACs. Add support for nrf52805, 820. (#77) --- Cargo.lock | 228 +++++++++++++++---------------- ci.sh | 17 +-- examples/src/bin/ble_peripheral_onoff.rs | 1 + examples/src/example_common.rs | 2 + nrf-softdevice/Cargo.toml | 19 ++- nrf-softdevice/src/ble/central.rs | 7 +- nrf-softdevice/src/ble/connection.rs | 22 ++- nrf-softdevice/src/ble/gap.rs | 7 +- nrf-softdevice/src/ble/gatt_client.rs | 1 + nrf-softdevice/src/ble/gatt_server.rs | 5 +- nrf-softdevice/src/events.rs | 4 +- nrf-softdevice/src/lib.rs | 23 ++++ nrf-softdevice/src/softdevice.rs | 10 +- nrf-softdevice/src/util/mod.rs | 9 +- nrf-softdevice/src/util/portal.rs | 1 + rust-toolchain.toml | 2 +- 16 files changed, 189 insertions(+), 169 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 355cd1c..99db58e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,9 +23,9 @@ dependencies = [ [[package]] name = "aligned" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19796bd8d477f1a9d4ac2465b464a8b1359474f06a96bb3cda650b4fca309bf" +checksum = "3a785a543aea40f5e4e2e93bb2655d31bc21bb391fff65697150973e383f16bb" dependencies = [ "as-slice", ] @@ -54,11 +54,11 @@ dependencies = [ [[package]] name = "atomic-polyfill" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30302dda7a66f8c55932ebf208f7def840743ff64d495e9ceffcd97c18f11d39" +checksum = "4a93ba5d6053837dbb76fd0ae26fd4f0c1859a008a783b0ce072b797c07f0f27" dependencies = [ - "cortex-m 0.7.2", + "cortex-m 0.7.3", ] [[package]] @@ -96,9 +96,9 @@ checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" [[package]] name = "bytemuck" -version = "1.5.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58" +checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b" [[package]] name = "byteorder" @@ -121,15 +121,15 @@ dependencies = [ "aligned", "bare-metal 0.2.5", "bitfield", - "cortex-m 0.7.2", + "cortex-m 0.7.3", "volatile-register", ] [[package]] name = "cortex-m" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643a210c1bdc23d0db511e2a576082f4ff4dcae9d0c37f50b431b8f8439d6d6b" +checksum = "2ac919ef424449ec8c08d515590ce15d9262c0ca5f0da5b0c901e971a3b783b3" dependencies = [ "bare-metal 0.2.5", "bitfield", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "cortex-m-rt" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d8353767db816419630a76d5f1ad5b09610d22b67ceb59647df6a8abc667f8" +checksum = "454f278bf469e2de0a4d22ea019d169d8944f86957c8207a39e3f66c32be2fc6" dependencies = [ "cortex-m-rt-macros", "r0", @@ -149,9 +149,9 @@ dependencies = [ [[package]] name = "cortex-m-rt-macros" -version = "0.1.8" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4717562afbba06e760d34451919f5c3bf3ac15c7bb897e8b04862a7428378647" +checksum = "c8e3aa52243e26f5922fa522b0814019e0c98fc567e2756d715dce7ad7a81f49" dependencies = [ "proc-macro2", "quote", @@ -166,7 +166,7 @@ checksum = "84c1ce814a497d4fbc869a34a0da005fbd712d7034e4a48ee91e7f3c795a8b17" dependencies = [ "bare-metal 1.0.0", "cfg-if", - "cortex-m 0.7.2", + "cortex-m 0.7.3", ] [[package]] @@ -206,19 +206,19 @@ dependencies = [ [[package]] name = "defmt" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aba21ce228b4769b8b5b6d2e2ee28c5dcfbe60c46f76b63d88b3a6677c8dc5b" +checksum = "15fe96f5d208164afa70583ff8f062e7697cbbb0b98e5076fbf8ac6da9edff0f" dependencies = [ "defmt-macros", - "semver 0.11.0", + "semver 1.0.4", ] [[package]] name = "defmt-macros" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b101f3d11ecbbd6046cabd76e2c5b6b20eb493de5a83fea4c0704864b886dfd6" +checksum = "9bd2c3949cb76c25f48c363e61b97f05b317efe3c12fa45d54a6599c3949c85e" dependencies = [ "defmt-parser", "proc-macro2", @@ -228,9 +228,9 @@ dependencies = [ [[package]] name = "defmt-parser" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc63e313e87db4666440753288012024f117065b52e9b9f4d0d869e9fada6404" +checksum = "bc621c2b4f5f5635e34021c38af2ccb0c1dae38ba11ebee25258de8bb1cee9fe" [[package]] name = "derivative" @@ -246,10 +246,10 @@ dependencies = [ [[package]] name = "embassy" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#cfa1f61154193da9a12420cb9cf300b2f3d736b2" +source = "git+https://github.com/embassy-rs/embassy#c0fb534a00165a008f47556d12abd58b6510a82c" dependencies = [ "atomic-polyfill", - "cortex-m 0.7.2", + "cortex-m 0.7.3", "critical-section", "defmt", "embassy-macros", @@ -262,9 +262,9 @@ dependencies = [ [[package]] name = "embassy-hal-common" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#cfa1f61154193da9a12420cb9cf300b2f3d736b2" +source = "git+https://github.com/embassy-rs/embassy#c0fb534a00165a008f47556d12abd58b6510a82c" dependencies = [ - "cortex-m 0.7.2", + "cortex-m 0.7.3", "embassy", "usb-device", ] @@ -272,7 +272,7 @@ dependencies = [ [[package]] name = "embassy-macros" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#cfa1f61154193da9a12420cb9cf300b2f3d736b2" +source = "git+https://github.com/embassy-rs/embassy#c0fb534a00165a008f47556d12abd58b6510a82c" dependencies = [ "darling", "proc-macro2", @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "embassy-nrf" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#cfa1f61154193da9a12420cb9cf300b2f3d736b2" +source = "git+https://github.com/embassy-rs/embassy#c0fb534a00165a008f47556d12abd58b6510a82c" dependencies = [ - "cortex-m 0.7.2", + "cortex-m 0.7.3", "cortex-m-rt", "critical-section", "defmt", @@ -302,7 +302,7 @@ dependencies = [ [[package]] name = "embassy-traits" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#cfa1f61154193da9a12420cb9cf300b2f3d736b2" +source = "git+https://github.com/embassy-rs/embassy#c0fb534a00165a008f47556d12abd58b6510a82c" dependencies = [ "defmt", "embedded-hal", @@ -319,9 +319,9 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db184d3fa27bc7a2344250394c0264144dfe0bc81a4401801dcb964b8dd172ad" +checksum = "e36cfb62ff156596c892272f3015ef952fe1525e85261fa3a7f327bd6b384ab9" dependencies = [ "nb 0.1.3", "void", @@ -347,9 +347,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "futures" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27" +checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b" dependencies = [ "futures-channel", "futures-core", @@ -361,9 +361,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" +checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" dependencies = [ "futures-core", "futures-sink", @@ -371,33 +371,33 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" +checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" [[package]] name = "futures-io" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" +checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" [[package]] name = "futures-sink" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" +checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" [[package]] name = "futures-task" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" +checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" [[package]] name = "futures-util" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" +checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" dependencies = [ "autocfg", "futures-core", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "heapless" -version = "0.7.1" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7ee8a997d259962217f40279f34201fdf06e669bafa69d7c1f4c7ff1893b5f6" +checksum = "50530280e9a947b192e3a30a9d7bcead527b22da30ff7cbd334233d820aaf82a" dependencies = [ "atomic-polyfill", "hash32", @@ -490,9 +490,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "nb" @@ -513,7 +513,7 @@ checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" name = "nrf-softdevice" version = "0.1.0" dependencies = [ - "cortex-m 0.7.2", + "cortex-m 0.7.3", "cortex-m-rt", "critical-section", "defmt", @@ -527,8 +527,10 @@ dependencies = [ "nrf-softdevice-s122", "nrf-softdevice-s132", "nrf-softdevice-s140", + "nrf52805-pac", "nrf52810-pac", "nrf52811-pac", + "nrf52820-pac", "nrf52832-pac", "nrf52833-pac", "nrf52840-pac", @@ -550,7 +552,7 @@ name = "nrf-softdevice-examples" version = "0.1.0" dependencies = [ "alloc-cortex-m", - "cortex-m 0.7.2", + "cortex-m 0.7.3", "cortex-m-rt", "defmt", "embassy", @@ -601,71 +603,88 @@ version = "0.1.1" name = "nrf-softdevice-s140" version = "0.1.1" +[[package]] +name = "nrf52805-pac" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "480157a9f6469dad9a6378f59f87444f757b448f4d272b0ee76957f2be77230d" +dependencies = [ + "cortex-m 0.7.3", + "cortex-m-rt", + "vcell", +] + [[package]] name = "nrf52810-pac" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136a10e0a338c3b46370a37c7986d78880714abae701d6a9a5fbdfde9a6397ea" +checksum = "412b8be4e5a3c0f34ba161063cd8f80da17c9d3ae6aafb182e58bb921171ada1" dependencies = [ - "bare-metal 0.2.5", - "cortex-m 0.6.7", + "cortex-m 0.7.3", "cortex-m-rt", "vcell", ] [[package]] name = "nrf52811-pac" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef7b4920d2f4316e54af7180bef23d64b5749eaa48ddb22398026c14e716036" +checksum = "894def2fffbd17c2c8242f5d781626ca604e82c5637ada254c8a9e88e8e390c9" dependencies = [ - "bare-metal 0.2.5", - "cortex-m 0.6.7", + "cortex-m 0.7.3", + "cortex-m-rt", + "vcell", +] + +[[package]] +name = "nrf52820-pac" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e61af7030554095d06734db273319e6010edf7ba0a579dc69ff6c49be857e0c7" +dependencies = [ + "cortex-m 0.7.3", "cortex-m-rt", "vcell", ] [[package]] name = "nrf52832-pac" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72920484274fae0792a40345049da2723612465c7202561b6a17ad3c127259db" +checksum = "d0c3195dae1f3b472a530de7e446c65050fe4e436344aea0ce025968f4984a9d" dependencies = [ - "bare-metal 0.2.5", - "cortex-m 0.6.7", + "cortex-m 0.7.3", "cortex-m-rt", "vcell", ] [[package]] name = "nrf52833-pac" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3dee38c8f33516f9fab44ac568f79f82cfcd0d5747f1cb6276a17d0fd9801d" +checksum = "57da33932f7db075fe4137a96bd9f878bc2428075e949e5c297b0b727da70d5b" dependencies = [ - "bare-metal 0.2.5", - "cortex-m 0.6.7", + "cortex-m 0.7.3", "cortex-m-rt", "vcell", ] [[package]] name = "nrf52840-pac" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b780a5afd2621774652f28c82837f6aa6d19cf0ad71c734fc1fe53298a2d73" +checksum = "cd2678a032033e63b1f32b2d9b3256b98211bdca17e0c6d7938c0eb9d5821294" dependencies = [ - "bare-metal 0.2.5", - "cortex-m 0.6.7", + "cortex-m 0.7.3", "cortex-m-rt", "vcell", ] [[package]] name = "num_enum" -version = "0.5.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b45a5c2ac4dd696ed30fa6b94b057ad909c7b7fc2e0d0808192bced894066" +checksum = "3f9bd055fb730c4f8f4f57d45d35cd6b3f0980535b056dc7ff119cee6a66ed6f" dependencies = [ "derivative", "num_enum_derive", @@ -673,9 +692,9 @@ dependencies = [ [[package]] name = "num_enum_derive" -version = "0.5.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c0fd9eba1d5db0994a239e09c1be402d35622277e35468ba891aa5e3188ce7e" +checksum = "486ea01961c4a818096de679a8b740b26d9033146ac5291b1c98557658f8cdd9" dependencies = [ "proc-macro2", "quote", @@ -693,29 +712,20 @@ dependencies = [ "defmt", ] -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - [[package]] name = "pin-project" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" +checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" +checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" dependencies = [ "proc-macro2", "quote", @@ -724,9 +734,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pin-utils" @@ -736,9 +746,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" dependencies = [ "unicode-xid", ] @@ -796,17 +806,14 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0", + "semver-parser", ] [[package]] name = "semver" -version = "0.11.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser 0.10.2", -] +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "semver-parser" @@ -814,15 +821,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -837,9 +835,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" -version = "1.0.72" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" dependencies = [ "proc-macro2", "quote", @@ -852,12 +850,6 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - [[package]] name = "unicode-xid" version = "0.2.2" @@ -896,9 +888,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "volatile-register" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" +checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" dependencies = [ "vcell", ] diff --git a/ci.sh b/ci.sh index c566e74..3ec9441 100755 --- a/ci.sh +++ b/ci.sh @@ -18,25 +18,16 @@ cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s140,nrf cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s140,nrf52840,ble-central,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server,log -# build all softdevice+chip combinations (with all supported features enabled) +# build softdevice+chip combinations (with all supported features enabled) +# This htis each softdevice and each chip at least once. #================================================================================ -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s112,nrf52810,ble-peripheral,ble-gatt-client,ble-gatt-server -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s112,nrf52811,ble-peripheral,ble-gatt-client,ble-gatt-server -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s112,nrf52832,ble-peripheral,ble-gatt-client,ble-gatt-server - +cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s112,nrf52805,ble-peripheral,ble-gatt-client,ble-gatt-server cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s113,nrf52810,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s113,nrf52811,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s113,nrf52832,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s113,nrf52833,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server - cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s122,nrf52833,ble-central,ble-gatt-client,ble-gatt-server - -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s132,nrf52810,ble-central,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s132,nrf52832,ble-central,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server - cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s140,nrf52811,ble-central,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server -cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s140,nrf52833,ble-central,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server +cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s140,nrf52820,ble-central,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server cargo build --target thumbv7em-none-eabihf -p nrf-softdevice --features s140,nrf52840,ble-central,ble-peripheral,ble-l2cap,ble-gatt-client,ble-gatt-server diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs index 1d9e95b..e3f3943 100644 --- a/examples/src/bin/ble_peripheral_onoff.rs +++ b/examples/src/bin/ble_peripheral_onoff.rs @@ -126,6 +126,7 @@ fn main() -> ! { let mut config = embassy_nrf::config::Config::default(); config.gpiote_interrupt_priority = Priority::P2; + config.time_interrupt_priority = Priority::P2; let p = embassy_nrf::init(config); let config = nrf_softdevice::Config { diff --git a/examples/src/example_common.rs b/examples/src/example_common.rs index 503e67a..ba6eef0 100644 --- a/examples/src/example_common.rs +++ b/examples/src/example_common.rs @@ -3,6 +3,8 @@ use nrf_softdevice_defmt_rtt as _; // global logger use panic_probe as _; +use embassy_nrf as _; + use alloc_cortex_m::CortexMHeap; use core::alloc::Layout; use core::sync::atomic::{AtomicUsize, Ordering}; diff --git a/nrf-softdevice/Cargo.toml b/nrf-softdevice/Cargo.toml index 1fb39dc..1034aad 100644 --- a/nrf-softdevice/Cargo.toml +++ b/nrf-softdevice/Cargo.toml @@ -12,8 +12,10 @@ defmt-info = [] defmt-warn = [] defmt-error = [] +nrf52805 = ["nrf52805-pac"] nrf52810 = ["nrf52810-pac"] nrf52811 = ["nrf52811-pac"] +nrf52820 = ["nrf52820-pac"] nrf52832 = ["nrf52832-pac"] nrf52833 = ["nrf52833-pac"] nrf52840 = ["nrf52840-pac"] @@ -27,8 +29,9 @@ s140 = ["nrf-softdevice-s140"] ble-peripheral = [] ble-central = [] ble-l2cap = [] -ble-gatt-server = [] -ble-gatt-client = [] +ble-gatt = [] +ble-gatt-server = ["ble-gatt"] +ble-gatt-client = ["ble-gatt"] critical-section-impl = ["critical-section/custom-impl"] @@ -44,11 +47,13 @@ cortex-m-rt = "0.6.13" heapless = "0.7.1" fixed = "1.5.0" -nrf52810-pac = { version = "0.9.0", features = ["rt"], optional = true } -nrf52811-pac = { version = "0.9.0", features = ["rt"], optional = true } -nrf52832-pac = { version = "0.9.0", features = ["rt"], optional = true } -nrf52833-pac = { version = "0.9.0", features = ["rt"], optional = true } -nrf52840-pac = { version = "0.9.0", features = ["rt"], optional = true } +nrf52805-pac = { version = "0.10.0", features = ["rt"], optional = true } +nrf52810-pac = { version = "0.10.0", features = ["rt"], optional = true } +nrf52811-pac = { version = "0.10.0", features = ["rt"], optional = true } +nrf52820-pac = { version = "0.10.0", features = ["rt"], optional = true } +nrf52832-pac = { version = "0.10.0", features = ["rt"], optional = true } +nrf52833-pac = { version = "0.10.0", features = ["rt"], optional = true } +nrf52840-pac = { version = "0.10.0", features = ["rt"], optional = true } nrf-softdevice-s112 = { version = "0.1.1", path = "../nrf-softdevice-s112", optional = true } nrf-softdevice-s113 = { version = "0.1.1", path = "../nrf-softdevice-s113", optional = true } diff --git a/nrf-softdevice/src/ble/central.rs b/nrf-softdevice/src/ble/central.rs index c2356d4..c30da39 100644 --- a/nrf-softdevice/src/ble/central.rs +++ b/nrf-softdevice/src/ble/central.rs @@ -6,7 +6,6 @@ use core::mem; use core::ptr; -use crate::ble::gap; use crate::ble::types::*; use crate::ble::{Address, Connection}; use crate::raw; @@ -32,7 +31,7 @@ pub(crate) static CONNECT_PORTAL: Portal<*const raw::ble_evt_t> = Portal::new(); // Begins an ATT MTU exchange procedure, followed by a data length update request as necessary. pub async fn connect( - sd: &Softdevice, + _sd: &Softdevice, config: &ConnectConfig<'_>, ) -> Result { if let Some(w) = config.scan_config.whitelist { @@ -75,7 +74,7 @@ pub async fn connect( match Connection::new(conn_handle, role, peer_address, conn_params) { Ok(conn) => { #[cfg(any(feature = "s113", feature = "s132", feature = "s140"))] - gap::do_data_length_update(conn_handle, ptr::null()); + crate::ble::gap::do_data_length_update(conn_handle, ptr::null()); Ok(conn) } @@ -98,7 +97,7 @@ pub async fn connect( #[cfg(feature = "ble-gatt-client")] { - let mtu = config.att_mtu.unwrap_or(sd.att_mtu); + let mtu = config.att_mtu.unwrap_or(_sd.att_mtu); unwrap!(crate::ble::gatt_client::att_mtu_exchange(&conn, mtu).await); } diff --git a/nrf-softdevice/src/ble/connection.rs b/nrf-softdevice/src/ble/connection.rs index 342524f..eac0c00 100644 --- a/nrf-softdevice/src/ble/connection.rs +++ b/nrf-softdevice/src/ble/connection.rs @@ -3,11 +3,11 @@ use core::cell::UnsafeCell; use raw::ble_gap_conn_params_t; -use crate::ble::types::*; -use crate::ble::*; +use crate::ble::types::{Address, AddressType, Role}; use crate::raw; use crate::RawError; +#[cfg(any(feature = "s113", feature = "s132", feature = "s140"))] const BLE_GAP_DATA_LENGTH_DEFAULT: u8 = 27; // The stack's default data length. <27-251> #[derive(Debug, PartialEq, Eq, Clone, Copy)] @@ -66,6 +66,7 @@ pub(crate) struct ConnectionState { pub conn_params: ble_gap_conn_params_t, + #[cfg(feature = "ble-gatt")] pub att_mtu: u16, // Effective ATT_MTU size (in bytes). #[cfg(any(feature = "s113", feature = "s132", feature = "s140"))] pub data_length_effective: u8, // Effective data length (in bytes). @@ -90,6 +91,7 @@ impl ConnectionState { min_conn_interval: 0, slave_latency: 0, }, + #[cfg(feature = "ble-gatt")] att_mtu: 0, #[cfg(any(feature = "s113", feature = "s132", feature = "s140"))] data_length_effective: 0, @@ -118,7 +120,7 @@ impl ConnectionState { Ok(()) } - pub(crate) fn on_disconnected(&mut self, ble_evt: *const raw::ble_evt_t) { + pub(crate) fn on_disconnected(&mut self, _ble_evt: *const raw::ble_evt_t) { let conn_handle = unwrap!( self.conn_handle, "bug: on_disconnected when already disconnected" @@ -132,11 +134,11 @@ impl ConnectionState { // Signal possible in-progess operations that the connection has disconnected. #[cfg(feature = "ble-gatt-client")] - gatt_client::portal(conn_handle).call(ble_evt); + crate::ble::gatt_client::portal(conn_handle).call(_ble_evt); #[cfg(feature = "ble-gatt-server")] - gatt_server::portal(conn_handle).call(ble_evt); + crate::ble::gatt_server::portal(conn_handle).call(_ble_evt); #[cfg(feature = "ble-l2cap")] - l2cap::portal(conn_handle).call(ble_evt); + crate::ble::l2cap::portal(conn_handle).call(_ble_evt); trace!("conn {:?}: disconnected", _index); } @@ -215,6 +217,8 @@ impl Connection { disconnecting: false, conn_params, + + #[cfg(feature = "ble-gatt")] att_mtu: raw::BLE_GATT_ATT_MTU_DEFAULT as _, #[cfg(any(feature = "s113", feature = "s132", feature = "s140"))] @@ -236,6 +240,12 @@ impl Connection { with_state(self.index, |s| s.conn_params) } + /// Get the currently active ATT MTU. + #[cfg(feature = "ble-gatt")] + pub fn att_mtu(&self) -> u16 { + with_state(self.index, |s| s.att_mtu) + } + /// Set the connection params. /// /// Note that this just initiates the connection param change, it does not wait for completion. diff --git a/nrf-softdevice/src/ble/gap.rs b/nrf-softdevice/src/ble/gap.rs index b28a49f..7b6fca5 100644 --- a/nrf-softdevice/src/ble/gap.rs +++ b/nrf-softdevice/src/ble/gap.rs @@ -1,6 +1,3 @@ -use core::mem; -use core::ptr; - use crate::ble::*; use crate::raw; use crate::util::get_union_field; @@ -143,7 +140,7 @@ pub(crate) unsafe fn on_evt(ble_evt: *const raw::ble_evt_t) { ); let conn_handle = gap_evt.conn_handle; - do_data_length_update(conn_handle, ptr::null()); + do_data_length_update(conn_handle, core::ptr::null()); } #[cfg(any(feature = "s113", feature = "s132", feature = "s140"))] raw::BLE_GAP_EVTS_BLE_GAP_EVT_DATA_LENGTH_UPDATE => { @@ -171,7 +168,7 @@ pub(crate) unsafe fn do_data_length_update( conn_handle: u16, params: *const raw::ble_gap_data_length_params_t, ) { - let mut dl_limitation = mem::zeroed(); + let mut dl_limitation = core::mem::zeroed(); let ret = raw::sd_ble_gap_data_length_update(conn_handle, params, &mut dl_limitation); if let Err(_err) = RawError::convert(ret) { warn!("sd_ble_gap_data_length_update err {:?}", _err); diff --git a/nrf-softdevice/src/ble/gatt_client.rs b/nrf-softdevice/src/ble/gatt_client.rs index 48c5f72..5affd5f 100644 --- a/nrf-softdevice/src/ble/gatt_client.rs +++ b/nrf-softdevice/src/ble/gatt_client.rs @@ -605,6 +605,7 @@ impl From for MtuExchangeError { } } +#[cfg(feature = "ble-central")] pub(crate) async fn att_mtu_exchange(conn: &Connection, mtu: u16) -> Result<(), MtuExchangeError> { let conn_handle = conn.with_state(|state| state.check_connected())?; diff --git a/nrf-softdevice/src/ble/gatt_server.rs b/nrf-softdevice/src/ble/gatt_server.rs index 3634127..58663cc 100644 --- a/nrf-softdevice/src/ble/gatt_server.rs +++ b/nrf-softdevice/src/ble/gatt_server.rs @@ -7,7 +7,7 @@ use core::mem; use crate::ble::*; use crate::raw; -use crate::util::{get_flexarray, get_union_field, BoundedLifetime, Portal}; +use crate::util::{get_flexarray, get_union_field, Portal}; use crate::RawError; use crate::Softdevice; @@ -151,8 +151,7 @@ where return Some(Err(RunError::Disconnected)) } raw::BLE_GATTS_EVTS_BLE_GATTS_EVT_WRITE => { - let bounded = BoundedLifetime; - let evt = bounded.deref(ble_evt); + let evt = &*ble_evt; let gatts_evt = get_union_field(ble_evt, &evt.evt.gatts_evt); let params = get_union_field(ble_evt, &gatts_evt.params.write); let v = get_flexarray(ble_evt, ¶ms.data, params.len as usize); diff --git a/nrf-softdevice/src/events.rs b/nrf-softdevice/src/events.rs index f00de57..f74f256 100644 --- a/nrf-softdevice/src/events.rs +++ b/nrf-softdevice/src/events.rs @@ -80,13 +80,13 @@ pub(crate) async fn run() { } } -#[cfg(any(feature = "nrf52810", feature = "nrf52811"))] +#[cfg(any(feature = "nrf52805", feature = "nrf52810", feature = "nrf52811"))] #[interrupt] unsafe fn SWI2() { SWI2_SIGNAL.signal(()); } -#[cfg(not(any(feature = "nrf52810", feature = "nrf52811")))] +#[cfg(not(any(feature = "nrf52805", feature = "nrf52810", feature = "nrf52811")))] #[interrupt] unsafe fn SWI2_EGU2() { SWI2_SIGNAL.signal(()); diff --git a/nrf-softdevice/src/lib.rs b/nrf-softdevice/src/lib.rs index 44648fb..614cb1f 100644 --- a/nrf-softdevice/src/lib.rs +++ b/nrf-softdevice/src/lib.rs @@ -38,8 +38,10 @@ compile_error!("No softdevice feature activated. You must activate exactly one o compile_error!("Multiple softdevice features activated. You must activate exactly one of the following features: s112, s113, s122, s132, s140"); #[cfg(not(any( + feature = "nrf52805", feature = "nrf52810", feature = "nrf52811", + feature = "nrf52820", feature = "nrf52832", feature = "nrf52833", feature = "nrf52840", @@ -47,13 +49,24 @@ compile_error!("Multiple softdevice features activated. You must activate exactl compile_error!("No chip feature activated. You must activate exactly one of the following features: nrf52810, nrf52811, nrf52832, nrf52833, nrf52840"); #[cfg(any( + all(feature = "nrf52805", feature = "nrf52810"), + all(feature = "nrf52805", feature = "nrf52811"), + all(feature = "nrf52805", feature = "nrf52820"), + all(feature = "nrf52805", feature = "nrf52832"), + all(feature = "nrf52805", feature = "nrf52833"), + all(feature = "nrf52805", feature = "nrf52840"), all(feature = "nrf52810", feature = "nrf52811"), + all(feature = "nrf52810", feature = "nrf52820"), all(feature = "nrf52810", feature = "nrf52832"), all(feature = "nrf52810", feature = "nrf52833"), all(feature = "nrf52810", feature = "nrf52840"), + all(feature = "nrf52811", feature = "nrf52820"), all(feature = "nrf52811", feature = "nrf52832"), all(feature = "nrf52811", feature = "nrf52833"), all(feature = "nrf52811", feature = "nrf52840"), + all(feature = "nrf52820", feature = "nrf52832"), + all(feature = "nrf52820", feature = "nrf52833"), + all(feature = "nrf52820", feature = "nrf52840"), all(feature = "nrf52832", feature = "nrf52833"), all(feature = "nrf52832", feature = "nrf52840"), all(feature = "nrf52833", feature = "nrf52840"), @@ -71,12 +84,18 @@ compile_error!("Multile chip features activated. You must activate exactly one o // s140 | X X X | X X X X #[cfg(not(any( + all(feature = "nrf52805", feature = "s112"), + all(feature = "nrf52805", feature = "s113"), all(feature = "nrf52810", feature = "s112"), all(feature = "nrf52810", feature = "s113"), all(feature = "nrf52810", feature = "s132"), all(feature = "nrf52811", feature = "s112"), all(feature = "nrf52811", feature = "s113"), all(feature = "nrf52811", feature = "s140"), + all(feature = "nrf52820", feature = "s112"), + all(feature = "nrf52820", feature = "s113"), + all(feature = "nrf52820", feature = "s122"), + all(feature = "nrf52820", feature = "s140"), all(feature = "nrf52832", feature = "s112"), all(feature = "nrf52832", feature = "s113"), all(feature = "nrf52832", feature = "s132"), @@ -106,10 +125,14 @@ compile_error!("The selected softdevice does not support ble-peripheral."); ))] compile_error!("The selected softdevice does not support ble-l2cap."); +#[cfg(feature = "nrf52805")] +use nrf52805_pac as pac; #[cfg(feature = "nrf52810")] use nrf52810_pac as pac; #[cfg(feature = "nrf52811")] use nrf52811_pac as pac; +#[cfg(feature = "nrf52820")] +use nrf52820_pac as pac; #[cfg(feature = "nrf52832")] use nrf52832_pac as pac; #[cfg(feature = "nrf52833")] diff --git a/nrf-softdevice/src/softdevice.rs b/nrf-softdevice/src/softdevice.rs index 981ec5f..a306554 100644 --- a/nrf-softdevice/src/softdevice.rs +++ b/nrf-softdevice/src/softdevice.rs @@ -37,6 +37,8 @@ unsafe extern "C" fn fault_handler(id: u32, pc: u32, info: u32) { pub struct Softdevice { // Prevent Send, Sync _private: PhantomData<*mut ()>, + #[cfg(feature = "ble-gatt")] + #[allow(unused)] pub(crate) att_mtu: u16, #[cfg(feature = "ble-l2cap")] pub(crate) l2cap_rx_mps: u16, @@ -277,12 +279,13 @@ impl Softdevice { } unsafe { - #[cfg(any(feature = "nrf52810", feature = "nrf52811"))] + #[cfg(any(feature = "nrf52805", feature = "nrf52810", feature = "nrf52811"))] pac::NVIC::unmask(pac::interrupt::SWI2); - #[cfg(not(any(feature = "nrf52810", feature = "nrf52811")))] + #[cfg(not(any(feature = "nrf52805", feature = "nrf52810", feature = "nrf52811")))] pac::NVIC::unmask(pac::interrupt::SWI2_EGU2); } + #[cfg(feature = "ble-gatt")] let att_mtu = config .conn_gatt .map(|x| x.att_mtu) @@ -296,7 +299,10 @@ impl Softdevice { SOFTDEVICE.put(Softdevice { _private: PhantomData, + + #[cfg(feature = "ble-gatt")] att_mtu, + #[cfg(feature = "ble-l2cap")] l2cap_rx_mps, }) diff --git a/nrf-softdevice/src/util/mod.rs b/nrf-softdevice/src/util/mod.rs index b82c893..c341a1d 100644 --- a/nrf-softdevice/src/util/mod.rs +++ b/nrf-softdevice/src/util/mod.rs @@ -11,19 +11,12 @@ pub use on_drop::*; use crate::raw; -pub(crate) struct BoundedLifetime; - -impl BoundedLifetime { - pub(crate) unsafe fn deref(&self, ptr: *const T) -> &T { - &*ptr - } -} - /// Create a slice from a variable-length array in a BLE event. /// /// This function is a workaround for UB in __IncompleteArrayField /// see https://github.com/rust-lang/rust-bindgen/issues/1892 /// see https://github.com/rust-lang/unsafe-code-guidelines/issues/134 +#[allow(unused)] pub(crate) unsafe fn get_flexarray( orig_ptr: *const raw::ble_evt_t, array: &raw::__IncompleteArrayField, diff --git a/nrf-softdevice/src/util/portal.rs b/nrf-softdevice/src/util/portal.rs index 28c1d88..bc6becd 100644 --- a/nrf-softdevice/src/util/portal.rs +++ b/nrf-softdevice/src/util/portal.rs @@ -97,6 +97,7 @@ impl Portal { } } + #[allow(unused)] pub fn wait_many<'a, R, F>(&'a self, mut func: F) -> impl Future + 'a where F: FnMut(T) -> Option + 'a, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 2db8bbd..d1dcc3a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ # Before upgrading check that everything is available on all tier1 targets here: # https://rust-lang.github.io/rustup-components-history [toolchain] -channel = "nightly-2021-08-03" +channel = "nightly-2021-08-18" components = ["rust-src", "rustfmt"] targets = ["thumbv7em-none-eabihf"] -- cgit v1.2.3