Firmware for the b-parasite board, but in Rust!

Initial working commit

+15
.cargo/config.toml
···
+
# This file was automatically generated.
+
+
[target.thumbv7em-none-eabihf]
+
linker = "flip-link"
+
runner = 'probe-rs run --chip nRF52840_xxAA'
+
+
[build]
+
target = "thumbv7em-none-eabihf"
+
rustflags = ["-Z", "unstable-options", "-C", "panic=immediate-abort"]
+
+
[env]
+
DEFMT_LOG = "info"
+
+
[unstable]
+
build-std = ["core"]
+1
.gitignore
···
+
/target
+4
.vscode/settings.json
···
+
{
+
"rust-analyzer.check.allTargets": false,
+
"rust-analyzer.check.targets": ["thumbv7em-none-eabihf"],
+
}
+1351
Cargo.lock
···
+
# This file is automatically @generated by Cargo.
+
# It is not intended for manual editing.
+
version = 4
+
+
[[package]]
+
name = "aho-corasick"
+
version = "1.1.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
+
dependencies = [
+
"memchr",
+
]
+
+
[[package]]
+
name = "autocfg"
+
version = "1.5.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
+
+
[[package]]
+
name = "az"
+
version = "1.2.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973"
+
+
[[package]]
+
name = "bare-metal"
+
version = "0.2.5"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
+
dependencies = [
+
"rustc_version",
+
]
+
+
[[package]]
+
name = "bindgen"
+
version = "0.72.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
+
dependencies = [
+
"bitflags 2.10.0",
+
"cexpr",
+
"clang-sys",
+
"itertools",
+
"log",
+
"prettyplease",
+
"proc-macro2",
+
"quote",
+
"regex",
+
"rustc-hash",
+
"shlex",
+
"syn",
+
]
+
+
[[package]]
+
name = "bitfield"
+
version = "0.13.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
+
+
[[package]]
+
name = "bitflags"
+
version = "1.3.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+
[[package]]
+
name = "bitflags"
+
version = "2.10.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
+
+
[[package]]
+
name = "bt-hci"
+
version = "0.6.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "bb938a3b4c5cc6c2409275bad789c0346a0495fa071a0acc5d72b9bd3175a2f7"
+
dependencies = [
+
"btuuid",
+
"defmt 1.0.1",
+
"embassy-sync",
+
"embedded-io",
+
"embedded-io-async",
+
"futures-intrusive",
+
"heapless 0.8.0",
+
]
+
+
[[package]]
+
name = "btuuid"
+
version = "0.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b0acfef8a77a02866e04f7e2ad3f4c7b32d575696c49c4bbad742b4aecb8e4a3"
+
dependencies = [
+
"defmt 0.3.100",
+
"uuid",
+
]
+
+
[[package]]
+
name = "bumpalo"
+
version = "3.19.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
+
+
[[package]]
+
name = "bytemuck"
+
version = "1.24.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4"
+
+
[[package]]
+
name = "byteorder"
+
version = "1.5.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
+
+
[[package]]
+
name = "cexpr"
+
version = "0.6.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
+
dependencies = [
+
"nom",
+
]
+
+
[[package]]
+
name = "cfg-if"
+
version = "1.0.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+
+
[[package]]
+
name = "clang-sys"
+
version = "1.8.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
+
dependencies = [
+
"glob",
+
"libc",
+
"libloading",
+
]
+
+
[[package]]
+
name = "convert_case"
+
version = "0.8.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "baaaa0ecca5b51987b9423ccdc971514dd8b0bb7b4060b983d3664dad3f1f89f"
+
dependencies = [
+
"unicode-segmentation",
+
]
+
+
[[package]]
+
name = "cortex-m"
+
version = "0.7.7"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9"
+
dependencies = [
+
"bare-metal",
+
"bitfield",
+
"embedded-hal 0.2.7",
+
"volatile-register",
+
]
+
+
[[package]]
+
name = "cortex-m-rt"
+
version = "0.7.5"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "801d4dec46b34c299ccf6b036717ae0fce602faa4f4fe816d9013b9a7c9f5ba6"
+
dependencies = [
+
"cortex-m-rt-macros",
+
]
+
+
[[package]]
+
name = "cortex-m-rt-macros"
+
version = "0.7.5"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472"
+
dependencies = [
+
"proc-macro2",
+
"quote",
+
"syn",
+
]
+
+
[[package]]
+
name = "critical-section"
+
version = "1.2.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
+
+
[[package]]
+
name = "crunchy"
+
version = "0.2.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
+
+
[[package]]
+
name = "darling"
+
version = "0.20.11"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
+
dependencies = [
+
"darling_core",
+
"darling_macro",
+
]
+
+
[[package]]
+
name = "darling_core"
+
version = "0.20.11"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e"
+
dependencies = [
+
"fnv",
+
"ident_case",
+
"proc-macro2",
+
"quote",
+
"strsim",
+
"syn",
+
]
+
+
[[package]]
+
name = "darling_macro"
+
version = "0.20.11"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
+
dependencies = [
+
"darling_core",
+
"quote",
+
"syn",
+
]
+
+
[[package]]
+
name = "defmt"
+
version = "0.3.100"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad"
+
dependencies = [
+
"defmt 1.0.1",
+
]
+
+
[[package]]
+
name = "defmt"
+
version = "1.0.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "548d977b6da32fa1d1fda2876453da1e7df63ad0304c8b3dae4dbe7b96f39b78"
+
dependencies = [
+
"bitflags 1.3.2",
+
"defmt-macros",
+
]
+
+
[[package]]
+
name = "defmt-macros"
+
version = "1.0.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e"
+
dependencies = [
+
"defmt-parser",
+
"proc-macro-error2",
+
"proc-macro2",
+
"quote",
+
"syn",
+
]
+
+
[[package]]
+
name = "defmt-parser"
+
version = "1.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
+
dependencies = [
+
"thiserror",
+
]
+
+
[[package]]
+
name = "defmt-rtt"
+
version = "1.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "93d5a25c99d89c40f5676bec8cefe0614f17f0f40e916f98e345dae941807f9e"
+
dependencies = [
+
"critical-section",
+
"defmt 1.0.1",
+
]
+
+
[[package]]
+
name = "document-features"
+
version = "0.2.12"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61"
+
dependencies = [
+
"litrs",
+
]
+
+
[[package]]
+
name = "doxygen-rs"
+
version = "0.4.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "415b6ec780d34dcf624666747194393603d0373b7141eef01d12ee58881507d9"
+
dependencies = [
+
"phf",
+
]
+
+
[[package]]
+
name = "either"
+
version = "1.15.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
+
+
[[package]]
+
name = "embassy-embedded-hal"
+
version = "0.5.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8"
+
dependencies = [
+
"defmt 1.0.1",
+
"embassy-futures",
+
"embassy-hal-internal",
+
"embassy-sync",
+
"embassy-time",
+
"embedded-hal 0.2.7",
+
"embedded-hal 1.0.0",
+
"embedded-hal-async",
+
"embedded-storage",
+
"embedded-storage-async",
+
"nb 1.1.0",
+
]
+
+
[[package]]
+
name = "embassy-executor"
+
version = "0.9.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "06070468370195e0e86f241c8e5004356d696590a678d47d6676795b2e439c6b"
+
dependencies = [
+
"cortex-m",
+
"critical-section",
+
"defmt 1.0.1",
+
"document-features",
+
"embassy-executor-macros",
+
"embassy-executor-timer-queue",
+
]
+
+
[[package]]
+
name = "embassy-executor-macros"
+
version = "0.7.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "dfdddc3a04226828316bf31393b6903ee162238576b1584ee2669af215d55472"
+
dependencies = [
+
"darling",
+
"proc-macro2",
+
"quote",
+
"syn",
+
]
+
+
[[package]]
+
name = "embassy-executor-timer-queue"
+
version = "0.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2fc328bf943af66b80b98755db9106bf7e7471b0cf47dc8559cd9a6be504cc9c"
+
+
[[package]]
+
name = "embassy-futures"
+
version = "0.1.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "dc2d050bdc5c21e0862a89256ed8029ae6c290a93aecefc73084b3002cdebb01"
+
dependencies = [
+
"defmt 1.0.1",
+
]
+
+
[[package]]
+
name = "embassy-hal-internal"
+
version = "0.3.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a"
+
dependencies = [
+
"cortex-m",
+
"critical-section",
+
"defmt 1.0.1",
+
"num-traits",
+
]
+
+
[[package]]
+
name = "embassy-nrf"
+
version = "0.8.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a8d63429d74ab5786cde7c9dc9a0338ea162a4da95e204ac5345c5ae36831fdb"
+
dependencies = [
+
"bitflags 2.10.0",
+
"cfg-if",
+
"cortex-m",
+
"cortex-m-rt",
+
"critical-section",
+
"defmt 1.0.1",
+
"document-features",
+
"embassy-embedded-hal",
+
"embassy-hal-internal",
+
"embassy-sync",
+
"embassy-time-driver",
+
"embassy-time-queue-utils",
+
"embassy-usb-driver",
+
"embedded-hal 0.2.7",
+
"embedded-hal 1.0.0",
+
"embedded-hal-async",
+
"embedded-io",
+
"embedded-io-async",
+
"embedded-storage",
+
"embedded-storage-async",
+
"fixed",
+
"nrf-pac",
+
"rand_core 0.6.4",
+
"rand_core 0.9.3",
+
]
+
+
[[package]]
+
name = "embassy-sync"
+
version = "0.7.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b"
+
dependencies = [
+
"cfg-if",
+
"critical-section",
+
"defmt 1.0.1",
+
"embedded-io-async",
+
"futures-core",
+
"futures-sink",
+
"heapless 0.8.0",
+
]
+
+
[[package]]
+
name = "embassy-time"
+
version = "0.5.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f4fa65b9284d974dad7a23bb72835c4ec85c0b540d86af7fc4098c88cff51d65"
+
dependencies = [
+
"cfg-if",
+
"critical-section",
+
"defmt 1.0.1",
+
"document-features",
+
"embassy-time-driver",
+
"embedded-hal 0.2.7",
+
"embedded-hal 1.0.0",
+
"embedded-hal-async",
+
"futures-core",
+
]
+
+
[[package]]
+
name = "embassy-time-driver"
+
version = "0.2.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a0a244c7dc22c8d0289379c8d8830cae06bb93d8f990194d0de5efb3b5ae7ba6"
+
dependencies = [
+
"document-features",
+
]
+
+
[[package]]
+
name = "embassy-time-queue-utils"
+
version = "0.3.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "80e2ee86063bd028a420a5fb5898c18c87a8898026da1d4c852af2c443d0a454"
+
dependencies = [
+
"embassy-executor-timer-queue",
+
"heapless 0.8.0",
+
]
+
+
[[package]]
+
name = "embassy-usb-driver"
+
version = "0.2.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a"
+
dependencies = [
+
"defmt 1.0.1",
+
"embedded-io-async",
+
]
+
+
[[package]]
+
name = "embedded-hal"
+
version = "0.2.7"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff"
+
dependencies = [
+
"nb 0.1.3",
+
"void",
+
]
+
+
[[package]]
+
name = "embedded-hal"
+
version = "1.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89"
+
dependencies = [
+
"defmt 0.3.100",
+
]
+
+
[[package]]
+
name = "embedded-hal-async"
+
version = "1.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0c4c685bbef7fe13c3c6dd4da26841ed3980ef33e841cddfa15ce8a8fb3f1884"
+
dependencies = [
+
"embedded-hal 1.0.0",
+
]
+
+
[[package]]
+
name = "embedded-io"
+
version = "0.6.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
+
dependencies = [
+
"defmt 0.3.100",
+
]
+
+
[[package]]
+
name = "embedded-io-async"
+
version = "0.6.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f"
+
dependencies = [
+
"defmt 0.3.100",
+
"embedded-io",
+
]
+
+
[[package]]
+
name = "embedded-storage"
+
version = "0.3.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a21dea9854beb860f3062d10228ce9b976da520a73474aed3171ec276bc0c032"
+
+
[[package]]
+
name = "embedded-storage-async"
+
version = "0.4.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1763775e2323b7d5f0aa6090657f5e21cfa02ede71f5dc40eead06d64dcd15cc"
+
dependencies = [
+
"embedded-storage",
+
]
+
+
[[package]]
+
name = "fixed"
+
version = "1.29.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "707070ccf8c4173548210893a0186e29c266901b71ed20cd9e2ca0193dfe95c3"
+
dependencies = [
+
"az",
+
"bytemuck",
+
"half",
+
"typenum",
+
]
+
+
[[package]]
+
name = "fnv"
+
version = "1.0.7"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
+
[[package]]
+
name = "futures"
+
version = "0.3.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
+
dependencies = [
+
"futures-channel",
+
"futures-core",
+
"futures-io",
+
"futures-sink",
+
"futures-task",
+
"futures-util",
+
]
+
+
[[package]]
+
name = "futures-channel"
+
version = "0.3.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
+
dependencies = [
+
"futures-core",
+
"futures-sink",
+
]
+
+
[[package]]
+
name = "futures-core"
+
version = "0.3.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
+
+
[[package]]
+
name = "futures-intrusive"
+
version = "0.5.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f"
+
dependencies = [
+
"futures-core",
+
"lock_api",
+
]
+
+
[[package]]
+
name = "futures-io"
+
version = "0.3.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
+
+
[[package]]
+
name = "futures-sink"
+
version = "0.3.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
+
+
[[package]]
+
name = "futures-task"
+
version = "0.3.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
+
+
[[package]]
+
name = "futures-util"
+
version = "0.3.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
+
dependencies = [
+
"futures-core",
+
"futures-sink",
+
"futures-task",
+
"pin-project-lite",
+
"pin-utils",
+
]
+
+
[[package]]
+
name = "glob"
+
version = "0.3.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
+
+
[[package]]
+
name = "half"
+
version = "2.7.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
+
dependencies = [
+
"cfg-if",
+
"crunchy",
+
"zerocopy",
+
]
+
+
[[package]]
+
name = "hash32"
+
version = "0.3.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606"
+
dependencies = [
+
"byteorder",
+
]
+
+
[[package]]
+
name = "heapless"
+
version = "0.8.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
+
dependencies = [
+
"hash32",
+
"stable_deref_trait",
+
]
+
+
[[package]]
+
name = "heapless"
+
version = "0.9.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2af2455f757db2b292a9b1768c4b70186d443bcb3b316252d6b540aec1cd89ed"
+
dependencies = [
+
"defmt 1.0.1",
+
"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 = "itertools"
+
version = "0.13.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
+
dependencies = [
+
"either",
+
]
+
+
[[package]]
+
name = "js-sys"
+
version = "0.3.83"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8"
+
dependencies = [
+
"once_cell",
+
"wasm-bindgen",
+
]
+
+
[[package]]
+
name = "libc"
+
version = "0.2.178"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
+
+
[[package]]
+
name = "libloading"
+
version = "0.8.9"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
+
dependencies = [
+
"cfg-if",
+
"windows-link",
+
]
+
+
[[package]]
+
name = "litrs"
+
version = "1.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"
+
+
[[package]]
+
name = "lock_api"
+
version = "0.4.14"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
+
dependencies = [
+
"scopeguard",
+
]
+
+
[[package]]
+
name = "log"
+
version = "0.4.29"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
+
+
[[package]]
+
name = "memchr"
+
version = "2.7.6"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
+
+
[[package]]
+
name = "minimal-lexical"
+
version = "0.2.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
+
+
[[package]]
+
name = "nb"
+
version = "0.1.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f"
+
dependencies = [
+
"nb 1.1.0",
+
]
+
+
[[package]]
+
name = "nb"
+
version = "1.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
+
+
[[package]]
+
name = "nom"
+
version = "7.1.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
+
dependencies = [
+
"memchr",
+
"minimal-lexical",
+
]
+
+
[[package]]
+
name = "nrf-mpsl"
+
version = "0.3.0"
+
source = "git+https://github.com/alexmoon/nrf-sdc#5ce36312f7bf39ed73638ecbe1f2a5351da7f6f8"
+
dependencies = [
+
"cfg-if",
+
"cortex-m",
+
"critical-section",
+
"defmt 1.0.1",
+
"embassy-nrf",
+
"embassy-sync",
+
"embedded-io",
+
"embedded-storage",
+
"embedded-storage-async",
+
"nrf-mpsl-sys",
+
]
+
+
[[package]]
+
name = "nrf-mpsl-sys"
+
version = "0.2.1"
+
source = "git+https://github.com/alexmoon/nrf-sdc#5ce36312f7bf39ed73638ecbe1f2a5351da7f6f8"
+
dependencies = [
+
"bindgen",
+
"doxygen-rs",
+
]
+
+
[[package]]
+
name = "nrf-pac"
+
version = "0.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d334027d6703534f2a80de0794ae435c0e029358d28278533d3935e69b221b01"
+
dependencies = [
+
"cortex-m",
+
"cortex-m-rt",
+
]
+
+
[[package]]
+
name = "nrf-sdc"
+
version = "0.4.0"
+
source = "git+https://github.com/alexmoon/nrf-sdc#5ce36312f7bf39ed73638ecbe1f2a5351da7f6f8"
+
dependencies = [
+
"bt-hci",
+
"critical-section",
+
"defmt 1.0.1",
+
"embassy-hal-internal",
+
"embassy-nrf",
+
"embassy-sync",
+
"embedded-io",
+
"embedded-io-async",
+
"nrf-mpsl",
+
"nrf-sdc-sys",
+
"rand_core 0.9.3",
+
]
+
+
[[package]]
+
name = "nrf-sdc-sys"
+
version = "0.2.1"
+
source = "git+https://github.com/alexmoon/nrf-sdc#5ce36312f7bf39ed73638ecbe1f2a5351da7f6f8"
+
dependencies = [
+
"bindgen",
+
"doxygen-rs",
+
"nrf-mpsl-sys",
+
"winnow",
+
]
+
+
[[package]]
+
name = "num-traits"
+
version = "0.2.19"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+
dependencies = [
+
"autocfg",
+
]
+
+
[[package]]
+
name = "once_cell"
+
version = "1.21.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
+
+
[[package]]
+
name = "panic-halt"
+
version = "1.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11"
+
+
[[package]]
+
name = "panic-probe"
+
version = "1.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "fd402d00b0fb94c5aee000029204a46884b1262e0c443f166d86d2c0747e1a1a"
+
dependencies = [
+
"cortex-m",
+
"defmt 1.0.1",
+
]
+
+
[[package]]
+
name = "phf"
+
version = "0.11.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
+
dependencies = [
+
"phf_macros",
+
"phf_shared",
+
]
+
+
[[package]]
+
name = "phf_generator"
+
version = "0.11.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
+
dependencies = [
+
"phf_shared",
+
"rand",
+
]
+
+
[[package]]
+
name = "phf_macros"
+
version = "0.11.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
+
dependencies = [
+
"phf_generator",
+
"phf_shared",
+
"proc-macro2",
+
"quote",
+
"syn",
+
]
+
+
[[package]]
+
name = "phf_shared"
+
version = "0.11.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
+
dependencies = [
+
"siphasher",
+
]
+
+
[[package]]
+
name = "pin-project-lite"
+
version = "0.2.16"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
+
+
[[package]]
+
name = "pin-utils"
+
version = "0.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+
+
[[package]]
+
name = "portable-atomic"
+
version = "1.11.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
+
+
[[package]]
+
name = "prettyplease"
+
version = "0.2.37"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
+
dependencies = [
+
"proc-macro2",
+
"syn",
+
]
+
+
[[package]]
+
name = "proc-macro-error-attr2"
+
version = "2.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5"
+
dependencies = [
+
"proc-macro2",
+
"quote",
+
]
+
+
[[package]]
+
name = "proc-macro-error2"
+
version = "2.0.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802"
+
dependencies = [
+
"proc-macro-error-attr2",
+
"proc-macro2",
+
"quote",
+
"syn",
+
]
+
+
[[package]]
+
name = "proc-macro2"
+
version = "1.0.103"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
+
dependencies = [
+
"unicode-ident",
+
]
+
+
[[package]]
+
name = "quote"
+
version = "1.0.42"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
+
dependencies = [
+
"proc-macro2",
+
]
+
+
[[package]]
+
name = "rand"
+
version = "0.8.5"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
+
dependencies = [
+
"rand_core 0.6.4",
+
]
+
+
[[package]]
+
name = "rand_core"
+
version = "0.6.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+
+
[[package]]
+
name = "rand_core"
+
version = "0.9.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
+
+
[[package]]
+
name = "regex"
+
version = "1.12.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
+
dependencies = [
+
"aho-corasick",
+
"memchr",
+
"regex-automata",
+
"regex-syntax",
+
]
+
+
[[package]]
+
name = "regex-automata"
+
version = "0.4.13"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
+
dependencies = [
+
"aho-corasick",
+
"memchr",
+
"regex-syntax",
+
]
+
+
[[package]]
+
name = "regex-syntax"
+
version = "0.8.8"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
+
+
[[package]]
+
name = "rustc-hash"
+
version = "2.1.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
+
+
[[package]]
+
name = "rustc_version"
+
version = "0.2.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
+
dependencies = [
+
"semver",
+
]
+
+
[[package]]
+
name = "rustversion"
+
version = "1.0.22"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
+
+
[[package]]
+
name = "sachy-battery"
+
version = "0.1.0"
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
+
+
[[package]]
+
name = "sachy-bthome"
+
version = "0.1.0"
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
+
dependencies = [
+
"defmt 1.0.1",
+
"heapless 0.9.2",
+
"sachy-fmt",
+
]
+
+
[[package]]
+
name = "sachy-fmt"
+
version = "0.1.0"
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
+
dependencies = [
+
"defmt 1.0.1",
+
]
+
+
[[package]]
+
name = "sachy-parasite"
+
version = "0.1.0"
+
dependencies = [
+
"bt-hci",
+
"cortex-m",
+
"cortex-m-rt",
+
"defmt 1.0.1",
+
"defmt-rtt",
+
"embassy-executor",
+
"embassy-futures",
+
"embassy-nrf",
+
"embassy-sync",
+
"embassy-time",
+
"embedded-hal 1.0.0",
+
"embedded-io",
+
"nrf-mpsl",
+
"nrf-sdc",
+
"panic-halt",
+
"panic-probe",
+
"sachy-battery",
+
"sachy-bthome",
+
"sachy-fmt",
+
"sachy-shtc3",
+
"static_cell",
+
"trouble-host",
+
]
+
+
[[package]]
+
name = "sachy-shtc3"
+
version = "0.1.0"
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
+
dependencies = [
+
"defmt 1.0.1",
+
"embedded-hal 1.0.0",
+
"embedded-hal-async",
+
]
+
+
[[package]]
+
name = "scopeguard"
+
version = "1.2.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+
[[package]]
+
name = "semver"
+
version = "0.9.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
+
dependencies = [
+
"semver-parser",
+
]
+
+
[[package]]
+
name = "semver-parser"
+
version = "0.7.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
+
+
[[package]]
+
name = "shlex"
+
version = "1.3.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+
[[package]]
+
name = "siphasher"
+
version = "1.0.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
+
+
[[package]]
+
name = "stable_deref_trait"
+
version = "1.2.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
+
+
[[package]]
+
name = "static_cell"
+
version = "2.1.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0530892bb4fa575ee0da4b86f86c667132a94b74bb72160f58ee5a4afec74c23"
+
dependencies = [
+
"portable-atomic",
+
]
+
+
[[package]]
+
name = "strsim"
+
version = "0.11.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+
[[package]]
+
name = "syn"
+
version = "2.0.111"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
+
dependencies = [
+
"proc-macro2",
+
"quote",
+
"unicode-ident",
+
]
+
+
[[package]]
+
name = "thiserror"
+
version = "2.0.17"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
+
dependencies = [
+
"thiserror-impl",
+
]
+
+
[[package]]
+
name = "thiserror-impl"
+
version = "2.0.17"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
+
dependencies = [
+
"proc-macro2",
+
"quote",
+
"syn",
+
]
+
+
[[package]]
+
name = "trouble-host"
+
version = "0.5.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2881b4859001fe1f48445145cda5149deac9110b1d707ec0a251b7ff6d8bdfa4"
+
dependencies = [
+
"bt-hci",
+
"defmt 1.0.1",
+
"embassy-futures",
+
"embassy-sync",
+
"embassy-time",
+
"embedded-io",
+
"futures",
+
"heapless 0.9.2",
+
"rand_core 0.6.4",
+
"static_cell",
+
"trouble-host-macros",
+
"zerocopy",
+
]
+
+
[[package]]
+
name = "trouble-host-macros"
+
version = "0.3.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "bcb85bec3a8393c22ca1a7c25c82c2d33689ab412f3487c492fd01a033ede7c2"
+
dependencies = [
+
"convert_case",
+
"darling",
+
"proc-macro2",
+
"quote",
+
"syn",
+
"uuid",
+
]
+
+
[[package]]
+
name = "typenum"
+
version = "1.19.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
+
+
[[package]]
+
name = "unicode-ident"
+
version = "1.0.22"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
+
+
[[package]]
+
name = "unicode-segmentation"
+
version = "1.12.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
+
+
[[package]]
+
name = "uuid"
+
version = "1.19.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a"
+
dependencies = [
+
"js-sys",
+
"wasm-bindgen",
+
]
+
+
[[package]]
+
name = "vcell"
+
version = "0.1.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
+
+
[[package]]
+
name = "void"
+
version = "1.0.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
+
+
[[package]]
+
name = "volatile-register"
+
version = "0.2.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc"
+
dependencies = [
+
"vcell",
+
]
+
+
[[package]]
+
name = "wasm-bindgen"
+
version = "0.2.106"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd"
+
dependencies = [
+
"cfg-if",
+
"once_cell",
+
"rustversion",
+
"wasm-bindgen-macro",
+
"wasm-bindgen-shared",
+
]
+
+
[[package]]
+
name = "wasm-bindgen-macro"
+
version = "0.2.106"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3"
+
dependencies = [
+
"quote",
+
"wasm-bindgen-macro-support",
+
]
+
+
[[package]]
+
name = "wasm-bindgen-macro-support"
+
version = "0.2.106"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40"
+
dependencies = [
+
"bumpalo",
+
"proc-macro2",
+
"quote",
+
"syn",
+
"wasm-bindgen-shared",
+
]
+
+
[[package]]
+
name = "wasm-bindgen-shared"
+
version = "0.2.106"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4"
+
dependencies = [
+
"unicode-ident",
+
]
+
+
[[package]]
+
name = "windows-link"
+
version = "0.2.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+
[[package]]
+
name = "winnow"
+
version = "0.7.14"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
+
dependencies = [
+
"memchr",
+
]
+
+
[[package]]
+
name = "zerocopy"
+
version = "0.8.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3"
+
dependencies = [
+
"zerocopy-derive",
+
]
+
+
[[package]]
+
name = "zerocopy-derive"
+
version = "0.8.31"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a"
+
dependencies = [
+
"proc-macro2",
+
"quote",
+
"syn",
+
]
+96
Cargo.toml
···
+
[package]
+
name = "sachy-parasite"
+
description = "Firmware for the b-parasite board, but in Rust!"
+
authors = ["Sachy.dev <sachymetsu@tutamail.com>"]
+
repository = "https://tangled.org/sachy.dev/sachy-parasite"
+
license = "MIT OR Apache-2.0"
+
version = "0.1.0"
+
edition = "2024"
+
+
[[bin]]
+
name = "sachy-parasite"
+
test = false
+
bench = false
+
+
[profile.dev]
+
debug = true
+
lto = true
+
opt-level = "z"
+
incremental = true
+
codegen-units = 1
+
+
[profile.release]
+
debug = false
+
lto = true
+
opt-level = "z"
+
codegen-units = 1
+
+
[features]
+
defmt = ["dep:defmt"]
+
defmt-rtt = ["dep:defmt-rtt"]
+
panic-probe = ["dep:panic-probe"]
+
default = ["debug"]
+
debug = [
+
"defmt",
+
"defmt-rtt",
+
"panic-probe",
+
"embassy-executor/defmt",
+
"embassy-sync/defmt",
+
"embassy-futures/defmt",
+
"embassy-time/defmt",
+
"embassy-time/defmt-timestamp-uptime",
+
"embassy-nrf/defmt",
+
"nrf-sdc/defmt",
+
"nrf-mpsl/defmt",
+
"sachy-shtc3/defmt",
+
"sachy-bthome/defmt",
+
"trouble-host/defmt",
+
"bt-hci/defmt",
+
"embedded-hal/defmt-03",
+
"embedded-io/defmt-03",
+
"sachy-fmt/defmt",
+
]
+
+
[dependencies]
+
cortex-m = { version = "0.7.7", features = ["inline-asm"] }
+
cortex-m-rt = "0.7.5"
+
defmt = { version = "1.0.1", optional = true }
+
defmt-rtt = { version = "1.0.0", optional = true }
+
panic-halt = "1.0.0"
+
panic-probe = { version = "1.0.0", features = ["print-defmt"], optional = true }
+
static_cell = "2.1.0"
+
+
embassy-executor = { version = "0.9", features = [
+
"arch-cortex-m",
+
"executor-thread",
+
"executor-interrupt",
+
"nightly",
+
] }
+
embassy-futures = "0.1"
+
embassy-nrf = { version = "0.8", features = [
+
"nrf52840",
+
"gpiote",
+
"time-driver-rtc1",
+
] }
+
embassy-sync = "0.7"
+
embassy-time = { version = "0.5" }
+
embedded-hal = { version = "1.0.0" }
+
embedded-io = "0.6"
+
+
nrf-sdc = { git = "https://github.com/alexmoon/nrf-sdc", features = [
+
"peripheral",
+
"nrf52840",
+
] }
+
nrf-mpsl = { git = "https://github.com/alexmoon/nrf-sdc", features = [
+
"critical-section-impl",
+
] }
+
bt-hci = "0.6"
+
trouble-host = { version = "0.5", features = [
+
"derive",
+
"scan",
+
] }
+
+
sachy-fmt = { git = "https://tangled.org/sachy.dev/sachy-embed-core", package = "sachy-fmt" }
+
sachy-battery = { git = "https://tangled.org/sachy.dev/sachy-embed-core", package = "sachy-battery" }
+
sachy-bthome = { git = "https://tangled.org/sachy.dev/sachy-embed-core", package = "sachy-bthome" }
+
sachy-shtc3 = { git = "https://tangled.org/sachy.dev/sachy-embed-core", package = "sachy-shtc3" }
+4
Embed.toml
···
+
# This file was automatically generated.
+
+
[default.general]
+
chip = "nRF52840_xxAA"
+201
LICENSE-APACHE
···
+
Apache License
+
Version 2.0, January 2004
+
http://www.apache.org/licenses/
+
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+
1. Definitions.
+
+
"License" shall mean the terms and conditions for use, reproduction,
+
and distribution as defined by Sections 1 through 9 of this document.
+
+
"Licensor" shall mean the copyright owner or entity authorized by
+
the copyright owner that is granting the License.
+
+
"Legal Entity" shall mean the union of the acting entity and all
+
other entities that control, are controlled by, or are under common
+
control with that entity. For the purposes of this definition,
+
"control" means (i) the power, direct or indirect, to cause the
+
direction or management of such entity, whether by contract or
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
+
outstanding shares, or (iii) beneficial ownership of such entity.
+
+
"You" (or "Your") shall mean an individual or Legal Entity
+
exercising permissions granted by this License.
+
+
"Source" form shall mean the preferred form for making modifications,
+
including but not limited to software source code, documentation
+
source, and configuration files.
+
+
"Object" form shall mean any form resulting from mechanical
+
transformation or translation of a Source form, including but
+
not limited to compiled object code, generated documentation,
+
and conversions to other media types.
+
+
"Work" shall mean the work of authorship, whether in Source or
+
Object form, made available under the License, as indicated by a
+
copyright notice that is included in or attached to the work
+
(an example is provided in the Appendix below).
+
+
"Derivative Works" shall mean any work, whether in Source or Object
+
form, that is based on (or derived from) the Work and for which the
+
editorial revisions, annotations, elaborations, or other modifications
+
represent, as a whole, an original work of authorship. For the purposes
+
of this License, Derivative Works shall not include works that remain
+
separable from, or merely link (or bind by name) to the interfaces of,
+
the Work and Derivative Works thereof.
+
+
"Contribution" shall mean any work of authorship, including
+
the original version of the Work and any modifications or additions
+
to that Work or Derivative Works thereof, that is intentionally
+
submitted to Licensor for inclusion in the Work by the copyright owner
+
or by an individual or Legal Entity authorized to submit on behalf of
+
the copyright owner. For the purposes of this definition, "submitted"
+
means any form of electronic, verbal, or written communication sent
+
to the Licensor or its representatives, including but not limited to
+
communication on electronic mailing lists, source code control systems,
+
and issue tracking systems that are managed by, or on behalf of, the
+
Licensor for the purpose of discussing and improving the Work, but
+
excluding communication that is conspicuously marked or otherwise
+
designated in writing by the copyright owner as "Not a Contribution."
+
+
"Contributor" shall mean Licensor and any individual or Legal Entity
+
on behalf of whom a Contribution has been received by Licensor and
+
subsequently incorporated within the Work.
+
+
2. Grant of Copyright License. Subject to the terms and conditions of
+
this License, each Contributor hereby grants to You a perpetual,
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+
copyright license to reproduce, prepare Derivative Works of,
+
publicly display, publicly perform, sublicense, and distribute the
+
Work and such Derivative Works in Source or Object form.
+
+
3. Grant of Patent License. Subject to the terms and conditions of
+
this License, each Contributor hereby grants to You a perpetual,
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+
(except as stated in this section) patent license to make, have made,
+
use, offer to sell, sell, import, and otherwise transfer the Work,
+
where such license applies only to those patent claims licensable
+
by such Contributor that are necessarily infringed by their
+
Contribution(s) alone or by combination of their Contribution(s)
+
with the Work to which such Contribution(s) was submitted. If You
+
institute patent litigation against any entity (including a
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
+
or a Contribution incorporated within the Work constitutes direct
+
or contributory patent infringement, then any patent licenses
+
granted to You under this License for that Work shall terminate
+
as of the date such litigation is filed.
+
+
4. Redistribution. You may reproduce and distribute copies of the
+
Work or Derivative Works thereof in any medium, with or without
+
modifications, and in Source or Object form, provided that You
+
meet the following conditions:
+
+
(a) You must give any other recipients of the Work or
+
Derivative Works a copy of this License; and
+
+
(b) You must cause any modified files to carry prominent notices
+
stating that You changed the files; and
+
+
(c) You must retain, in the Source form of any Derivative Works
+
that You distribute, all copyright, patent, trademark, and
+
attribution notices from the Source form of the Work,
+
excluding those notices that do not pertain to any part of
+
the Derivative Works; and
+
+
(d) If the Work includes a "NOTICE" text file as part of its
+
distribution, then any Derivative Works that You distribute must
+
include a readable copy of the attribution notices contained
+
within such NOTICE file, excluding those notices that do not
+
pertain to any part of the Derivative Works, in at least one
+
of the following places: within a NOTICE text file distributed
+
as part of the Derivative Works; within the Source form or
+
documentation, if provided along with the Derivative Works; or,
+
within a display generated by the Derivative Works, if and
+
wherever such third-party notices normally appear. The contents
+
of the NOTICE file are for informational purposes only and
+
do not modify the License. You may add Your own attribution
+
notices within Derivative Works that You distribute, alongside
+
or as an addendum to the NOTICE text from the Work, provided
+
that such additional attribution notices cannot be construed
+
as modifying the License.
+
+
You may add Your own copyright statement to Your modifications and
+
may provide additional or different license terms and conditions
+
for use, reproduction, or distribution of Your modifications, or
+
for any such Derivative Works as a whole, provided Your use,
+
reproduction, and distribution of the Work otherwise complies with
+
the conditions stated in this License.
+
+
5. Submission of Contributions. Unless You explicitly state otherwise,
+
any Contribution intentionally submitted for inclusion in the Work
+
by You to the Licensor shall be under the terms and conditions of
+
this License, without any additional terms or conditions.
+
Notwithstanding the above, nothing herein shall supersede or modify
+
the terms of any separate license agreement you may have executed
+
with Licensor regarding such Contributions.
+
+
6. Trademarks. This License does not grant permission to use the trade
+
names, trademarks, service marks, or product names of the Licensor,
+
except as required for reasonable and customary use in describing the
+
origin of the Work and reproducing the content of the NOTICE file.
+
+
7. Disclaimer of Warranty. Unless required by applicable law or
+
agreed to in writing, Licensor provides the Work (and each
+
Contributor provides its Contributions) on an "AS IS" BASIS,
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+
implied, including, without limitation, any warranties or conditions
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+
PARTICULAR PURPOSE. You are solely responsible for determining the
+
appropriateness of using or redistributing the Work and assume any
+
risks associated with Your exercise of permissions under this License.
+
+
8. Limitation of Liability. In no event and under no legal theory,
+
whether in tort (including negligence), contract, or otherwise,
+
unless required by applicable law (such as deliberate and grossly
+
negligent acts) or agreed to in writing, shall any Contributor be
+
liable to You for damages, including any direct, indirect, special,
+
incidental, or consequential damages of any character arising as a
+
result of this License or out of the use or inability to use the
+
Work (including but not limited to damages for loss of goodwill,
+
work stoppage, computer failure or malfunction, or any and all
+
other commercial damages or losses), even if such Contributor
+
has been advised of the possibility of such damages.
+
+
9. Accepting Warranty or Additional Liability. While redistributing
+
the Work or Derivative Works thereof, You may choose to offer,
+
and charge a fee for, acceptance of support, warranty, indemnity,
+
or other liability obligations and/or rights consistent with this
+
License. However, in accepting such obligations, You may act only
+
on Your own behalf and on Your sole responsibility, not on behalf
+
of any other Contributor, and only if You agree to indemnify,
+
defend, and hold each Contributor harmless for any liability
+
incurred by, or claims asserted against, such Contributor by reason
+
of your accepting any such warranty or additional liability.
+
+
END OF TERMS AND CONDITIONS
+
+
APPENDIX: How to apply the Apache License to your work.
+
+
To apply the Apache License to your work, attach the following
+
boilerplate notice, with the fields enclosed by brackets "[]"
+
replaced with your own identifying information. (Don't include
+
the brackets!) The text should be enclosed in the appropriate
+
comment syntax for the file format. We also recommend that a
+
file or class name and description of purpose be included on the
+
same "printed page" as the copyright notice for easier
+
identification within third-party archives.
+
+
Copyright 2025 Sachy.dev
+
+
Licensed under the Apache License, Version 2.0 (the "License");
+
you may not use this file except in compliance with the License.
+
You may obtain a copy of the License at
+
+
http://www.apache.org/licenses/LICENSE-2.0
+
+
Unless required by applicable law or agreed to in writing, software
+
distributed under the License is distributed on an "AS IS" BASIS,
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
See the License for the specific language governing permissions and
+
limitations under the License.
+21
LICENSE-MIT
···
+
MIT License
+
+
Copyright (c) 2025 Sachy.dev
+
+
Permission is hereby granted, free of charge, to any person obtaining a copy
+
of this software and associated documentation files (the "Software"), to deal
+
in the Software without restriction, including without limitation the rights
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+
copies of the Software, and to permit persons to whom the Software is
+
furnished to do so, subject to the following conditions:
+
+
The above copyright notice and this permission notice shall be included in all
+
copies or substantial portions of the Software.
+
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+
SOFTWARE.
+57
README.md
···
+
# Sachy's Parasite
+
+
[`b-parasite`](https://github.com/rbaron/b-parasite), the open source soil moisture and ambient temperature/humidity/light sensor, but in Rust!
+
+
## Notes
+
+
Currently, this project has been tested only with the v2.0 of the sensor, making use of the NRF52840 chip. Other variations have not been used, though this could be added by others should they wish. Also, soil moisture calculations have been calibrated against boards that have had conformal coating applied to the capacitive sensor part of the board and further tweaking my still happen, so YMMV.
+
+
## How to install / Flash to the board
+
+
To compile, [you'll the latest rustc compiler](https://www.rust-lang.org/tools/install), `clang` 9.0 or later C compiler (due to C deps in the codebase), and a SWD debug probe to flash with (A Pico Debug Probe flashed with yapico firmware will work). Optional but highly recommended tool for flashing this board is a pogo pin clamp (6 pin version). These can be found cheap on AliExpress.
+
+
Once rust is installed, you'll need to use `rustup` to download the `nightly` toolchain with the `thumbv7em-none-eabihf` target:
+
+
```
+
rustup toolchain install nightly
+
rustup +nightly target install thumbv7em-none-eabihf
+
```
+
+
Additionally, there's also at least one utility needed for compilation, `flip-link`. To install, run:
+
+
```
+
cargo install flip-link
+
```
+
+
For flashing, you'll need `probe-rs`, so be sure to [follow the install instructions here](https://probe.rs/docs/getting-started/installation/). There will be [further setup required after installation](https://probe.rs/docs/getting-started/probe-setup/).
+
+
This should be enough to get you all the necessary tools in place for compiling and flashing your b-parasite board. To check everything compiles correctly, `cd` into the `para-firmware` folder and run the following:
+
+
```
+
cargo build
+
```
+
+
This should build the firmware in debug mode and with `defmt` logging in place. To flash and log the debug build, ensure your debug probe is connected to the machine and the board and simply run the command:
+
+
```
+
cargo run
+
```
+
+
This will run the compiler and then execute `probe-rs` to flash the chip with the compiled binary. All of the debug info/symbols are kept on the machine and are not flashed, only the actual executable will be flashed. This allows for very efficient debug logging via `defmt`, which decodes the format using the debug symbols.
+
+
To compile and flash without debugging/logging, run:
+
+
```
+
cargo run --release --no-default-features
+
```
+
+
This will ensure all debugging/logging code is not generated, nor any debug symbols. Once `probe-rs` flashes the device, you should see no logging output once the chip begins to run.
+
+
## Licenses
+
+
Licensed under either of
+
+
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
+
+
at your option and for maximum compatibility with the Rust Ecosystem.
+36
build.rs
···
+
//! This build script copies the `memory.x` file from the crate root into
+
//! a directory where the linker can always find it at build time.
+
//! For many projects this is optional, as the linker always searches the
+
//! project root directory -- wherever `Cargo.toml` is. However, if you
+
//! are using a workspace or have a more complicated build setup, this
+
//! build script becomes required. Additionally, by requesting that
+
//! Cargo re-run the build script whenever `memory.x` is changed,
+
//! updating `memory.x` ensures a rebuild of the application with the
+
//! new memory settings.
+
+
use std::env;
+
use std::fs::File;
+
use std::io::Write;
+
use std::path::PathBuf;
+
+
fn main() {
+
// Put `memory.x` in our output directory and ensure it's
+
// on the linker search path.
+
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
+
File::create(out.join("memory.x"))
+
.unwrap()
+
.write_all(include_bytes!("memory.x"))
+
.unwrap();
+
println!("cargo:rustc-link-search={}", out.display());
+
+
// By default, Cargo will re-run a build script whenever
+
// any file in the project changes. By specifying `memory.x`
+
// here, we ensure the build script is only re-run when
+
// `memory.x` is changed.
+
println!("cargo:rerun-if-changed=memory.x");
+
+
println!("cargo:rustc-link-arg-bins=--nmagic");
+
println!("cargo:rustc-link-arg-bins=-Tlink.x");
+
#[cfg(feature = "defmt")]
+
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
+
}
+7
memory.x
···
+
MEMORY
+
{
+
/* NOTE 1 K = 1 KiBi = 1024 bytes */
+
/* You must fill in these values for your application */
+
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
+
RAM : ORIGIN = 0x20000000, LENGTH = 256K
+
}
+6
rust-toolchain.toml
···
+
# This file was automatically generated.
+
+
[toolchain]
+
channel = "nightly"
+
components = ["rust-src", "rustfmt"]
+
targets = ["thumbv7em-none-eabihf"]
+152
src/adc.rs
···
+
use embassy_nrf::{
+
Peri,
+
gpio::Output,
+
peripherals,
+
pwm::{self, SimplePwm},
+
saadc::{self, ChannelConfig, Config, Resolution, Saadc},
+
};
+
use embassy_time::Timer;
+
use sachy_battery::BatteryDischargeProfile;
+
use sachy_fmt::{info, unwrap};
+
use static_cell::ConstStaticCell;
+
+
use crate::{
+
Irqs,
+
constants::{DISCARGE_PROFILES, DRY_COEFFS, WET_COEFFS},
+
state::{ADC_MEASUREMENT, AdcMeasurements, START_MEASUREMENTS},
+
};
+
+
const VREF: f32 = 3.6;
+
+
#[inline]
+
fn calculate_polynomial(coeffs: &[f32; 3], val: f32) -> f32 {
+
coeffs[0] + (coeffs[1] * val) + (coeffs[2] * (val * val))
+
}
+
+
#[inline]
+
fn calculate_soil_moisture(bat: f32, soil: i16) -> f32 {
+
let dry = calculate_polynomial(&DRY_COEFFS, bat);
+
let wet = calculate_polynomial(&WET_COEFFS, bat);
+
+
info!("WUH: dry {}, wet {}, soil {}", dry, wet, soil);
+
+
(((soil as f32) - dry) / (wet - dry)).clamp(0.0, 1.0)
+
}
+
+
#[inline]
+
fn calculate_lux(voltage: f32) -> f32 {
+
const LUX_SUN: f32 = 10000.0;
+
const CURRENT_SUN: f32 = 3.59e-3;
+
const PHOTO_RESISTOR: f32 = 470.0;
+
+
let current = voltage / PHOTO_RESISTOR;
+
+
LUX_SUN * current / CURRENT_SUN
+
}
+
+
#[inline]
+
fn to_volts(sample: i16, reference: f32) -> f32 {
+
((sample.max(0) as f32) * reference) / 1024.0
+
}
+
+
fn init_pwm<'scope>(
+
pwm: Peri<'scope, peripherals::PWM0>,
+
ch0: Peri<'scope, peripherals::P0_05>,
+
) -> SimplePwm<'scope> {
+
let pwm_ctrl = SimplePwm::new_1ch(pwm, ch0);
+
pwm_ctrl.set_prescaler(pwm::Prescaler::Div1);
+
pwm_ctrl.set_period(2_000_000);
+
+
pwm_ctrl
+
}
+
+
fn init_saadc<'scope>(
+
saadc: Peri<'scope, peripherals::SAADC>,
+
light_pin: Peri<'scope, peripherals::P0_02>,
+
soil_pin: Peri<'scope, peripherals::P0_03>,
+
) -> Saadc<'scope, 3> {
+
let light_config = ChannelConfig::single_ended(light_pin);
+
+
let mut soil_config = ChannelConfig::single_ended(soil_pin);
+
soil_config.reference = saadc::Reference::VDD1_4;
+
+
let bat_config = ChannelConfig::single_ended(saadc::VddInput);
+
+
let mut saadc_config = Config::default();
+
saadc_config.resolution = Resolution::_10BIT;
+
+
Saadc::new(
+
saadc,
+
Irqs,
+
saadc_config,
+
[soil_config, light_config, bat_config],
+
)
+
}
+
+
#[embassy_executor::task]
+
pub async fn task(
+
mut saadc: Peri<'static, peripherals::SAADC>,
+
mut light_pin: Peri<'static, peripherals::P0_02>,
+
mut soil_pin: Peri<'static, peripherals::P0_03>,
+
mut photo_ctrl: Output<'static>,
+
mut pwm: Peri<'static, peripherals::PWM0>,
+
mut pin5: Peri<'static, peripherals::P0_05>,
+
) {
+
static ADC_BUFFER: ConstStaticCell<[i16; 3]> = ConstStaticCell::new([0; 3]);
+
let adc_buf = ADC_BUFFER.take();
+
+
let mut measure = unwrap!(START_MEASUREMENTS.receiver());
+
+
loop {
+
measure.changed().await;
+
+
let mut pwm_ctrl = init_pwm(pwm.reborrow(), pin5.reborrow());
+
+
let mut saadc = init_saadc(saadc.reborrow(), light_pin.reborrow(), soil_pin.reborrow());
+
+
photo_ctrl.set_high();
+
pwm_ctrl.enable();
+
pwm_ctrl.set_duty(0, 4);
+
+
Timer::after_millis(30).await;
+
+
let mut acc_buf = [0; 3];
+
let divisor = 4;
+
+
for _ in 0..divisor {
+
saadc.sample(adc_buf).await;
+
acc_buf
+
.iter_mut()
+
.zip(adc_buf.iter())
+
.for_each(|(slot, &value)| *slot += value);
+
Timer::after_millis(5).await;
+
}
+
+
photo_ctrl.set_low();
+
pwm_ctrl.set_duty(0, 0);
+
+
acc_buf.iter_mut().for_each(|acc| *acc /= divisor);
+
+
let [soil, light, bat] = acc_buf;
+
+
let bat_volt = to_volts(bat, VREF);
+
+
let (soil, light, bat) = (
+
calculate_soil_moisture(bat_volt, soil),
+
calculate_lux(to_volts(light, VREF)).max(0.0),
+
BatteryDischargeProfile::calc_pct_from_profile_range(
+
bat_volt,
+
DISCARGE_PROFILES.iter(),
+
),
+
);
+
+
let measurements = AdcMeasurements::new(bat, bat_volt, soil, light);
+
+
info!("Soil {}, Light {}, Bat {}", soil, light, bat);
+
+
ADC_MEASUREMENT.signal(measurements);
+
pwm_ctrl.disable();
+
drop(pwm_ctrl);
+
drop(saadc);
+
}
+
}
+105
src/ble.rs
···
+
use bt_hci::cmd::SyncCmd;
+
use embassy_futures::join::join;
+
use embassy_nrf::{mode, pac, rng};
+
use embassy_time::{Duration, Timer};
+
use nrf_mpsl::MultiprotocolServiceLayer;
+
use nrf_sdc::vendor::ZephyrWriteBdAddr;
+
use sachy_bthome::BtHomeAd;
+
use sachy_fmt::{info, unwrap};
+
use trouble_host::prelude::*;
+
+
use crate::{
+
constants::{
+
PARA_ADV_DURATION_SECS, PARA_BLE_TX_POWER, PARA_MAX_ADV_INTERVAL_MS,
+
PARA_MIN_ADV_INTERVAL_MS, PARA_NAME,
+
},
+
state::{ADC_MEASUREMENT, SHTC3_MEASUREMENT, START_MEASUREMENTS},
+
};
+
+
#[embassy_executor::task]
+
pub async fn mpsl_task(mpsl: &'static MultiprotocolServiceLayer<'static>) -> ! {
+
mpsl.run().await
+
}
+
+
pub fn build_sdc<'d, const N: usize>(
+
p: nrf_sdc::Peripherals<'d>,
+
rng: &'d mut rng::Rng<mode::Async>,
+
mpsl: &'d MultiprotocolServiceLayer,
+
mem: &'d mut nrf_sdc::Mem<N>,
+
) -> Result<nrf_sdc::SoftdeviceController<'d>, nrf_sdc::Error> {
+
nrf_sdc::Builder::new()?
+
.support_adv()?
+
.build(p, rng, mpsl, mem)
+
}
+
+
fn build_addr() -> BdAddr {
+
let ficr = pac::FICR;
+
let high = u64::from(ficr.deviceid(1).read());
+
let addr = high << 32 | u64::from(ficr.deviceid(0).read());
+
let addr = addr | 0x0000_c000_0000_0000;
+
BdAddr::new(unwrap!(addr.to_le_bytes()[..6].try_into()))
+
}
+
+
#[embassy_executor::task]
+
pub async fn run(controller: nrf_sdc::SoftdeviceController<'static>) {
+
let addr = build_addr();
+
+
info!("Our address = {:?}", &addr);
+
+
// Set the bluetooth address
+
unwrap!(ZephyrWriteBdAddr::new(addr).exec(&controller).await);
+
+
let mut resources: HostResources<DefaultPacketPool, 0, 0> = HostResources::new();
+
let stack = trouble_host::new(controller, &mut resources);
+
let Host {
+
mut peripheral,
+
mut runner,
+
..
+
} = stack.build();
+
+
let _ = join(runner.run(), async {
+
let mut start_measurements = unwrap!(START_MEASUREMENTS.receiver());
+
+
let params: AdvertisementParameters = AdvertisementParameters {
+
interval_min: Duration::from_millis(PARA_MIN_ADV_INTERVAL_MS),
+
interval_max: Duration::from_millis(PARA_MAX_ADV_INTERVAL_MS),
+
tx_power: PARA_BLE_TX_POWER,
+
..Default::default()
+
};
+
+
loop {
+
start_measurements.changed().await;
+
+
let (adc, shtc3) = join(ADC_MEASUREMENT.wait(), SHTC3_MEASUREMENT.wait()).await;
+
+
let mut ad = BtHomeAd::default();
+
+
let adv_data = ad
+
.add_data(adc.battery)
+
.add_data(shtc3.temperature)
+
.add_data(adc.lux)
+
.add_data(adc.voltage)
+
.add_data(shtc3.humidity)
+
.add_data(adc.moisture)
+
.add_local_name(PARA_NAME)
+
.encode();
+
+
info!("Starting advertising");
+
let advertiser = unwrap!(
+
peripheral
+
.advertise(
+
&params,
+
Advertisement::NonconnectableScannableUndirected {
+
adv_data,
+
scan_data: &[],
+
},
+
)
+
.await
+
);
+
Timer::after_secs(PARA_ADV_DURATION_SECS).await;
+
drop(advertiser);
+
info!("Stopping advertising, sleeping...");
+
}
+
})
+
.await;
+
}
+15
src/button.rs
···
+
use embassy_nrf::gpio::Input;
+
use embassy_time::Timer;
+
+
use crate::state::START_MEASUREMENTS;
+
+
#[embassy_executor::task]
+
pub async fn task(mut btn: Input<'static>) {
+
let measure = START_MEASUREMENTS.sender();
+
+
loop {
+
btn.wait_for_rising_edge().await;
+
measure.send(());
+
Timer::after_secs(5).await;
+
}
+
}
+20
src/constants.rs
···
+
use sachy_battery::BatteryDischargeProfile;
+
use trouble_host::prelude::TxPower;
+
+
pub const PARA_SLEEP_SECS: u64 = 300;
+
pub const PARA_ADV_DURATION_SECS: u64 = 4;
+
pub const PARA_MIN_ADV_INTERVAL_MS: u64 = 30;
+
pub const PARA_MAX_ADV_INTERVAL_MS: u64 = 80;
+
pub const PARA_BLE_TX_POWER: TxPower = TxPower::Plus8dBm;
+
+
pub static PARA_NAME: &str = "rpara";
+
+
pub static DRY_COEFFS: [f32; 3] = [154.0, 110.0, -15.3];
+
pub static WET_COEFFS: [f32; 3] = [319.0, -63.1, 7.2];
+
+
pub static DISCARGE_PROFILES: [BatteryDischargeProfile; 4] = [
+
BatteryDischargeProfile::new(3.00, 2.90, 1.00, 0.42),
+
BatteryDischargeProfile::new(2.90, 2.74, 0.42, 0.18),
+
BatteryDischargeProfile::new(2.74, 2.44, 0.18, 0.06),
+
BatteryDischargeProfile::new(2.44, 2.01, 0.06, 0.00),
+
];
+20
src/led.rs
···
+
use embassy_nrf::gpio::Output;
+
use embassy_time::Timer;
+
use sachy_fmt::unwrap;
+
+
use crate::state::START_MEASUREMENTS;
+
+
#[embassy_executor::task]
+
pub async fn task(mut led: Output<'static>) {
+
let mut indication = unwrap!(START_MEASUREMENTS.receiver());
+
+
loop {
+
indication.changed().await;
+
for _ in 0..4 {
+
led.set_high();
+
Timer::after_millis(50).await;
+
led.set_low();
+
Timer::after_millis(450).await;
+
}
+
}
+
}
+98
src/main.rs
···
+
#![feature(impl_trait_in_assoc_type)]
+
#![no_std]
+
#![no_main]
+
+
mod adc;
+
mod ble;
+
mod button;
+
mod constants;
+
mod led;
+
mod shtc3;
+
mod state;
+
mod timer;
+
+
use embassy_executor::Executor;
+
use sachy_fmt::{info, unwrap};
+
+
use embassy_nrf::{
+
bind_interrupts,
+
gpio::{Input, Level, Output, OutputDrive},
+
peripherals,
+
rng::{self, Rng},
+
saadc, twim,
+
};
+
#[cfg(not(feature = "defmt"))]
+
use panic_halt as _;
+
use static_cell::StaticCell;
+
#[cfg(feature = "defmt")]
+
use {defmt_rtt as _, panic_probe as _};
+
+
use nrf_sdc::mpsl::MultiprotocolServiceLayer;
+
use nrf_sdc::{self as sdc, mpsl};
+
+
bind_interrupts!(struct Irqs {
+
RNG => rng::InterruptHandler<peripherals::RNG>;
+
EGU0_SWI0 => nrf_sdc::mpsl::LowPrioInterruptHandler;
+
CLOCK_POWER => nrf_sdc::mpsl::ClockInterruptHandler;
+
RADIO => nrf_sdc::mpsl::HighPrioInterruptHandler;
+
TIMER0 => nrf_sdc::mpsl::HighPrioInterruptHandler;
+
RTC0 => nrf_sdc::mpsl::HighPrioInterruptHandler;
+
TWISPI0 => twim::InterruptHandler<peripherals::TWISPI0>;
+
SAADC => saadc::InterruptHandler;
+
});
+
+
#[cortex_m_rt::entry]
+
fn main() -> ! {
+
let p = embassy_nrf::init(Default::default());
+
+
let photo_ctrl = Output::new(p.P0_29, Level::Low, OutputDrive::Standard);
+
+
let mpsl_p =
+
mpsl::Peripherals::new(p.RTC0, p.TIMER0, p.TEMP, p.PPI_CH19, p.PPI_CH30, p.PPI_CH31);
+
let lfclk_cfg = mpsl::raw::mpsl_clock_lfclk_cfg_t {
+
source: mpsl::raw::MPSL_CLOCK_LF_SRC_RC as u8,
+
rc_ctiv: mpsl::raw::MPSL_RECOMMENDED_RC_CTIV as u8,
+
rc_temp_ctiv: mpsl::raw::MPSL_RECOMMENDED_RC_TEMP_CTIV as u8,
+
accuracy_ppm: mpsl::raw::MPSL_DEFAULT_CLOCK_ACCURACY_PPM as u16,
+
skip_wait_lfclk_started: mpsl::raw::MPSL_DEFAULT_SKIP_WAIT_LFCLK_STARTED != 0,
+
};
+
static MPSL: StaticCell<MultiprotocolServiceLayer> = StaticCell::new();
+
let mpsl = MPSL.init(unwrap!(mpsl::MultiprotocolServiceLayer::new(
+
mpsl_p, Irqs, lfclk_cfg
+
)));
+
let sdc_p = sdc::Peripherals::new(
+
p.PPI_CH17, p.PPI_CH18, p.PPI_CH20, p.PPI_CH21, p.PPI_CH22, p.PPI_CH23, p.PPI_CH24,
+
p.PPI_CH25, p.PPI_CH26, p.PPI_CH27, p.PPI_CH28, p.PPI_CH29,
+
);
+
+
static DEVICE_RNG: StaticCell<Rng<'static, embassy_nrf::mode::Async>> = StaticCell::new();
+
let rng = DEVICE_RNG.init_with(|| rng::Rng::new(p.RNG, Irqs));
+
+
static SDC_MEM: StaticCell<sdc::Mem<792>> = StaticCell::new();
+
let sdc_mem = SDC_MEM.init_with(sdc::Mem::new);
+
+
let sdc = unwrap!(ble::build_sdc(sdc_p, rng, mpsl, sdc_mem));
+
+
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
+
+
EXECUTOR.init_with(Executor::new).run(|spawner| {
+
spawner.must_spawn(button::task(Input::new(
+
p.P0_30,
+
embassy_nrf::gpio::Pull::Up,
+
)));
+
spawner.must_spawn(led::task(Output::new(
+
p.P0_28,
+
Level::Low,
+
OutputDrive::Standard,
+
)));
+
spawner.must_spawn(shtc3::task(p.TWISPI0, p.P0_24, p.P0_13));
+
spawner.must_spawn(adc::task(
+
p.SAADC, p.P0_02, p.P0_03, photo_ctrl, p.PWM0, p.P0_05,
+
));
+
spawner.must_spawn(timer::task());
+
spawner.must_spawn(ble::mpsl_task(&*mpsl));
+
spawner.must_spawn(ble::run(sdc));
+
+
info!("Sachy's Parasite is go!");
+
})
+
}
+105
src/shtc3.rs
···
+
use embassy_nrf::{
+
Peri, peripherals,
+
twim::{self, Twim},
+
};
+
use embassy_time::Timer;
+
use embedded_hal::i2c::SevenBitAddress;
+
use sachy_fmt::{info, error, unwrap};
+
use sachy_shtc3::{Error as ShtError, Measurement, PowerMode, ShtC3};
+
use static_cell::ConstStaticCell;
+
+
use crate::{
+
Irqs,
+
state::{SHTC3_MEASUREMENT, START_MEASUREMENTS, Shtc3Measurement},
+
};
+
+
async fn measure<I>(sht: &mut ShtC3<I>) -> Result<Measurement, ShtError<I::Error>>
+
where
+
I: embedded_hal::i2c::I2c<SevenBitAddress>,
+
{
+
sht.start_wakeup()?;
+
+
Timer::after_micros(sht.wakeup_duration() as u64).await;
+
+
let divisor = 4;
+
let mut m = Measurement::default();
+
+
for _ in 0..divisor {
+
sht.start_measurement()?;
+
+
Timer::after_micros(sht.max_measurement_duration() as u64).await;
+
+
m += sht.get_measurement_result()?;
+
+
Timer::after_millis(5).await;
+
}
+
+
m /= divisor;
+
+
info!(
+
"Temp: {}C, Humi: {}%",
+
m.temperature.as_degrees_celsius(),
+
m.humidity.as_percent()
+
);
+
+
sht.sleep()?;
+
+
Ok(m)
+
}
+
+
async fn reset<I>(sht: &mut ShtC3<I>) -> Result<(), ShtError<I::Error>>
+
where
+
I: embedded_hal::i2c::I2c<SevenBitAddress>,
+
{
+
sht.start_reset()?;
+
+
Timer::after_micros(sht.reset_duration() as u64).await;
+
+
Ok(())
+
}
+
+
fn init_sht3<'scope>(
+
spio: Peri<'scope, peripherals::TWISPI0>,
+
sda: Peri<'scope, peripherals::P0_24>,
+
scl: Peri<'scope, peripherals::P0_13>,
+
ram: &'scope mut [u8; 16],
+
) -> ShtC3<Twim<'scope>> {
+
let config = twim::Config::default();
+
let twi = Twim::new(spio, Irqs, sda, scl, config, ram);
+
+
ShtC3::new(twi, PowerMode::LowPower)
+
}
+
+
#[embassy_executor::task]
+
pub async fn task(
+
mut spio: Peri<'static, peripherals::TWISPI0>,
+
mut sda: Peri<'static, peripherals::P0_24>,
+
mut scl: Peri<'static, peripherals::P0_13>,
+
) {
+
static RAM_BUFFER: ConstStaticCell<[u8; 16]> = ConstStaticCell::new([0; 16]);
+
let ram = RAM_BUFFER.take();
+
+
let mut watcher = unwrap!(START_MEASUREMENTS.receiver());
+
+
loop {
+
watcher.changed().await;
+
+
let mut sht = init_sht3(spio.reborrow(), sda.reborrow(), scl.reborrow(), ram);
+
+
match measure(&mut sht).await {
+
Ok(measurement) => {
+
SHTC3_MEASUREMENT.signal(Shtc3Measurement::new(measurement));
+
}
+
Err(e) => {
+
error!("SHTC3 error: {:?}", e);
+
+
// Attempt to reset the sensor
+
if let Err(e) = reset(&mut sht).await {
+
error!("SHTC3 reset error: {:?}", e);
+
}
+
}
+
}
+
+
drop(sht);
+
}
+
}
+52
src/state.rs
···
+
use embassy_sync::{blocking_mutex::raw::ThreadModeRawMutex, signal::Signal, watch::Watch};
+
use sachy_bthome::{
+
Battery1Per, Humidity1Per, Illuminance10mLux, Moisture1Per, Temperature10mK, Voltage1mV,
+
};
+
use sachy_shtc3::Measurement;
+
+
#[derive(Debug, Clone)]
+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
+
#[repr(align(8))]
+
pub struct AdcMeasurements {
+
pub battery: Battery1Per,
+
pub voltage: Voltage1mV,
+
pub moisture: Moisture1Per,
+
pub lux: Illuminance10mLux,
+
}
+
+
impl AdcMeasurements {
+
pub fn new(battery: f32, voltage: f32, moisture: f32, lux: f32) -> Self {
+
let battery = (battery * 100.0) as u8;
+
let voltage = (voltage * 1000.0) as u16;
+
let moisture = (moisture * 100.0) as u8;
+
let lux = (lux * 100.0) as u32;
+
+
Self {
+
battery: battery.into(),
+
voltage: voltage.into(),
+
moisture: moisture.into(),
+
lux: lux.into(),
+
}
+
}
+
}
+
+
#[derive(Debug, Clone)]
+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
+
#[repr(align(8))]
+
pub struct Shtc3Measurement {
+
pub temperature: Temperature10mK,
+
pub humidity: Humidity1Per,
+
}
+
+
impl Shtc3Measurement {
+
pub fn new(measurement: Measurement) -> Self {
+
Self {
+
temperature: measurement.temperature.as_10mk_celsius().into(),
+
humidity: measurement.humidity.as_1k_percent().into(),
+
}
+
}
+
}
+
+
pub static SHTC3_MEASUREMENT: Signal<ThreadModeRawMutex, Shtc3Measurement> = Signal::new();
+
pub static ADC_MEASUREMENT: Signal<ThreadModeRawMutex, AdcMeasurements> = Signal::new();
+
pub static START_MEASUREMENTS: Watch<ThreadModeRawMutex, (), 4> = Watch::new();
+16
src/timer.rs
···
+
use embassy_time::{Duration, Ticker, Timer};
+
+
use crate::{constants::PARA_SLEEP_SECS, state::START_MEASUREMENTS};
+
+
#[embassy_executor::task]
+
pub async fn task() {
+
let mut ticker = Ticker::every(Duration::from_secs(PARA_SLEEP_SECS));
+
let start_measurements = START_MEASUREMENTS.sender();
+
+
Timer::after_secs(1).await;
+
+
loop {
+
start_measurements.send(());
+
ticker.next().await;
+
}
+
}