mirror of
https://github.com/hubaldv/bioz-firmware-rs.git
synced 2026-03-09 22:30:32 +00:00
Updated toml crate versions, added electrodes to impedance structure.
This commit is contained in:
184
Cargo.lock
generated
184
Cargo.lock
generated
@@ -16,9 +16,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aligned"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923"
|
||||
checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685"
|
||||
dependencies = [
|
||||
"as-slice",
|
||||
]
|
||||
@@ -61,17 +61,17 @@ name = "bioz-firmware-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bioz-icd-rs",
|
||||
"bitflags 2.9.4",
|
||||
"bitflags 2.10.0",
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"defmt 1.0.1",
|
||||
"defmt-rtt",
|
||||
"embassy-embedded-hal 0.4.0",
|
||||
"embassy-embedded-hal",
|
||||
"embassy-executor",
|
||||
"embassy-futures",
|
||||
"embassy-stm32",
|
||||
"embassy-sync 0.6.2",
|
||||
"embassy-time",
|
||||
"embassy-sync",
|
||||
"embassy-time 0.4.0",
|
||||
"embassy-usb",
|
||||
"embedded-hal 1.0.0",
|
||||
"heapless 0.9.1",
|
||||
@@ -117,9 +117,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.4"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
|
||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
|
||||
[[package]]
|
||||
name = "block-device-driver"
|
||||
@@ -287,33 +287,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "embassy-embedded-hal"
|
||||
version = "0.3.2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c62a3bf127e03832fb97d8b01a058775e617653bc89e2a12c256485a7fb54c1"
|
||||
dependencies = [
|
||||
"defmt 0.3.100",
|
||||
"embassy-embedded-hal 0.4.0",
|
||||
"embassy-futures",
|
||||
"embassy-sync 0.6.2",
|
||||
"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-embedded-hal"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1611b7a7ab5d1fbed84c338df26d56fd9bded58006ebb029075112ed2c5e039"
|
||||
checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8"
|
||||
dependencies = [
|
||||
"defmt 1.0.1",
|
||||
"embassy-futures",
|
||||
"embassy-hal-internal 0.3.0",
|
||||
"embassy-sync 0.7.2",
|
||||
"embassy-hal-internal",
|
||||
"embassy-sync",
|
||||
"embassy-time 0.5.0",
|
||||
"embedded-hal 0.2.7",
|
||||
"embedded-hal 1.0.0",
|
||||
"embedded-hal-async",
|
||||
@@ -324,22 +306,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "embassy-executor"
|
||||
version = "0.7.0"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90327bcc66333a507f89ecc4e2d911b265c45f5c9bc241f98eee076752d35ac6"
|
||||
checksum = "06070468370195e0e86f241c8e5004356d696590a678d47d6676795b2e439c6b"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"critical-section",
|
||||
"defmt 0.3.100",
|
||||
"defmt 1.0.1",
|
||||
"document-features",
|
||||
"embassy-executor-macros",
|
||||
"embassy-executor-timer-queue",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embassy-executor-macros"
|
||||
version = "0.6.2"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3577b1e9446f61381179a330fc5324b01d511624c55f25e3c66c9e3c626dbecf"
|
||||
checksum = "dfdddc3a04226828316bf31393b6903ee162238576b1584ee2669af215d55472"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
@@ -347,30 +330,27 @@ dependencies = [
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[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"
|
||||
|
||||
[[package]]
|
||||
name = "embassy-hal-internal"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef3bac31ec146321248a169e9c7b5799f1e0b3829c7a9b324cb4600a7438f59"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"critical-section",
|
||||
"defmt 0.3.100",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[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",
|
||||
]
|
||||
|
||||
@@ -391,31 +371,31 @@ checksum = "b7b2739fbcf6cd206ae08779c7d709087b16577d255f2ea4a45bc4bbbf305b3f"
|
||||
dependencies = [
|
||||
"embassy-futures",
|
||||
"embassy-net-driver",
|
||||
"embassy-sync 0.7.2",
|
||||
"embassy-sync",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embassy-stm32"
|
||||
version = "0.2.0"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1e0bb733acdddbc7097765a47ce80bde2385647cf1d8427331931e06cff9a87"
|
||||
checksum = "0d972eab325cc96afee98f80a91ca6b00249b6356dc0fdbff68b70c200df9fae"
|
||||
dependencies = [
|
||||
"aligned",
|
||||
"bit_field",
|
||||
"bitflags 2.9.4",
|
||||
"bitflags 2.10.0",
|
||||
"block-device-driver",
|
||||
"cfg-if",
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"critical-section",
|
||||
"defmt 0.3.100",
|
||||
"defmt 1.0.1",
|
||||
"document-features",
|
||||
"embassy-embedded-hal 0.3.2",
|
||||
"embassy-embedded-hal",
|
||||
"embassy-futures",
|
||||
"embassy-hal-internal 0.2.0",
|
||||
"embassy-hal-internal",
|
||||
"embassy-net-driver",
|
||||
"embassy-sync 0.6.2",
|
||||
"embassy-time",
|
||||
"embassy-sync",
|
||||
"embassy-time 0.5.0",
|
||||
"embassy-time-driver",
|
||||
"embassy-time-queue-utils",
|
||||
"embassy-usb-driver",
|
||||
@@ -433,7 +413,8 @@ dependencies = [
|
||||
"nb 1.1.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rand_core",
|
||||
"rand_core 0.6.4",
|
||||
"rand_core 0.9.5",
|
||||
"sdio-host",
|
||||
"static_assertions",
|
||||
"stm32-fmc",
|
||||
@@ -442,21 +423,6 @@ dependencies = [
|
||||
"volatile-register",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embassy-sync"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d2c8cdff05a7a51ba0087489ea44b0b1d97a296ca6b1d6d1a33ea7423d34049"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"critical-section",
|
||||
"defmt 0.3.100",
|
||||
"embedded-io-async",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embassy-sync"
|
||||
version = "0.7.2"
|
||||
@@ -465,6 +431,7 @@ checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"critical-section",
|
||||
"defmt 1.0.1",
|
||||
"embedded-io-async",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@@ -488,6 +455,23 @@ dependencies = [
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[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"
|
||||
@@ -499,25 +483,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "embassy-time-queue-utils"
|
||||
version = "0.1.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc55c748d16908a65b166d09ce976575fb8852cf60ccd06174092b41064d8f83"
|
||||
checksum = "80e2ee86063bd028a420a5fb5898c18c87a8898026da1d4c852af2c443d0a454"
|
||||
dependencies = [
|
||||
"embassy-executor",
|
||||
"embassy-executor-timer-queue",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embassy-usb"
|
||||
version = "0.4.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e651b9b7b47b514e6e6d1940a6e2e300891a2c33641917130643602a0cb6386"
|
||||
checksum = "dc4462e48b19a4f401a11901bdd981aab80c6a826608016a0bdc73cbbab31954"
|
||||
dependencies = [
|
||||
"defmt 0.3.100",
|
||||
"defmt 1.0.1",
|
||||
"embassy-futures",
|
||||
"embassy-net-driver-channel",
|
||||
"embassy-sync 0.6.2",
|
||||
"embassy-sync",
|
||||
"embassy-usb-driver",
|
||||
"embedded-io-async",
|
||||
"heapless 0.8.0",
|
||||
"ssmarshal",
|
||||
"usbd-hid",
|
||||
@@ -525,9 +510,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "embassy-usb-driver"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "340c5ce591ef58c6449e43f51d2c53efe1bf0bb6a40cbf80afa0d259c7d52c76"
|
||||
checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a"
|
||||
dependencies = [
|
||||
"defmt 1.0.1",
|
||||
"embedded-io-async",
|
||||
@@ -535,13 +520,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "embassy-usb-synopsys-otg"
|
||||
version = "0.2.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08e753b23799329780c7ac434264026d0422044d6649ed70a73441b14a6436d7"
|
||||
checksum = "288751f8eaa44a5cf2613f13cee0ca8e06e6638cb96e897e6834702c79084b23"
|
||||
dependencies = [
|
||||
"critical-section",
|
||||
"defmt 0.3.100",
|
||||
"embassy-sync 0.6.2",
|
||||
"defmt 1.0.1",
|
||||
"embassy-sync",
|
||||
"embassy-usb-driver",
|
||||
]
|
||||
|
||||
@@ -896,18 +881,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "postcard-rpc"
|
||||
version = "0.11.15"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7e1944dfb9859e440511700c442edce3eacd5862f90f5a9997d004bd3553f3b"
|
||||
checksum = "d1b0f9cc8bd8f38f5893fb7f07626b1c8722b3166ead66cfb14b5c5d5352822c"
|
||||
dependencies = [
|
||||
"defmt 0.3.100",
|
||||
"defmt 1.0.1",
|
||||
"embassy-executor",
|
||||
"embassy-futures",
|
||||
"embassy-sync 0.6.2",
|
||||
"embassy-time",
|
||||
"embassy-sync",
|
||||
"embassy-time 0.5.0",
|
||||
"embassy-usb",
|
||||
"embassy-usb-driver",
|
||||
"heapless 0.8.0",
|
||||
"heapless 0.9.1",
|
||||
"portable-atomic",
|
||||
"postcard",
|
||||
"postcard-schema",
|
||||
@@ -973,6 +958,12 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.2.3"
|
||||
@@ -999,9 +990,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "sdio-host"
|
||||
version = "0.5.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f93c025f9cfe4c388c328ece47d11a54a823da3b5ad0370b22d95ad47137f85a"
|
||||
checksum = "b328e2cb950eeccd55b7f55c3a963691455dcd044cfb5354f0c5e68d2c2d6ee2"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
@@ -1105,12 +1096,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "stm32-metapac"
|
||||
version = "16.0.0"
|
||||
version = "18.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc520f60f6653a32479a95b9180b33908f0cbbdf106609465ee7dea98f4f5b37"
|
||||
checksum = "6fd8ec3a292a0d9fc4798416a61b21da5ae50341b2e7b8d12e662bf305366097"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"defmt 0.3.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
14
Cargo.toml
14
Cargo.toml
@@ -5,21 +5,21 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# Change stm32h563zi to your chip name, if necessary.
|
||||
embassy-stm32 = { version = "0.2.0", features = ["defmt", "stm32h533re", "memory-x", "time-driver-any", "exti", "unstable-pac"] }
|
||||
embassy-sync = { version = "0.6.0", features = ["defmt"] }
|
||||
embassy-executor = { version = "0.7.0", features = ["arch-cortex-m", "executor-thread", "task-arena-size-32768", "defmt"] }
|
||||
embassy-stm32 = { version = "0.4.0", features = ["defmt", "stm32h533re", "memory-x", "time-driver-any", "exti", "unstable-pac"] }
|
||||
embassy-sync = { version = "0.7.2", features = ["defmt"] }
|
||||
embassy-executor = { version = "0.9.1", features = ["arch-cortex-m", "executor-thread", "defmt"] }
|
||||
embassy-time = { version = "0.4.0", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
|
||||
embassy-embedded-hal = { version = "0.4.0", features = ["defmt"]}
|
||||
embassy-embedded-hal = { version = "0.5.0", features = ["defmt"]}
|
||||
# embassy-net = { version = "0.7.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] }
|
||||
embassy-usb = { version = "0.4.0", features = ["defmt"] }
|
||||
embassy-usb = { version = "0.5.1", features = ["defmt"] }
|
||||
embassy-futures = { version = "0.1.0"}
|
||||
|
||||
defmt = "1.0.1"
|
||||
defmt-rtt = "1.1.0"
|
||||
|
||||
bitflags = "2.9.4"
|
||||
bitflags = "2.10.0"
|
||||
|
||||
postcard-rpc = {version = "0.11.15", features = ["embassy-usb-0_4-server", "defmt"]}
|
||||
postcard-rpc = {version = "0.12.1", features = ["embassy-usb-0_5-server", "defmt"]}
|
||||
bioz-icd-rs = {path = "../bioz-icd-rs"}
|
||||
|
||||
# libm = { version = "0.2.15" }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use embassy_embedded_hal::shared_bus::blocking::i2c::I2cDevice;
|
||||
use embassy_stm32::{i2c::I2c, mode::Blocking};
|
||||
use embassy_stm32::{i2c::I2c, mode::Blocking, i2c::Master};
|
||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||
|
||||
use embedded_hal_1::i2c::I2c as _;
|
||||
@@ -99,13 +99,13 @@ enum LDSW {
|
||||
}
|
||||
|
||||
pub struct ADG2128 {
|
||||
i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Blocking>>,
|
||||
i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Blocking, Master>>,
|
||||
address: u8,
|
||||
states_xy: [u8; 12]
|
||||
}
|
||||
|
||||
impl ADG2128 {
|
||||
pub fn new(i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Blocking>>, address: u8) -> Self {
|
||||
pub fn new(i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Blocking, Master>>, address: u8) -> Self {
|
||||
ADG2128 { i2c, address, states_xy: [0u8; 12]}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ use postcard_rpc::{
|
||||
define_dispatch,
|
||||
header::VarHeader,
|
||||
server::{
|
||||
impls::embassy_usb_v0_4::{
|
||||
impls::embassy_usb_v0_5::{
|
||||
dispatch_impl::{spawn_fn, WireRxBuf, WireRxImpl, WireSpawnImpl, WireStorage, WireTxImpl},
|
||||
PacketBuffers,
|
||||
PacketBuffers, USB_FS_MAX_PACKET_SIZE,
|
||||
},
|
||||
Dispatch, Server, Sender, SpawnContext,
|
||||
},
|
||||
@@ -127,7 +127,7 @@ pub fn init_communication(usb_driver: Driver<'static, peripherals::USB>, impedan
|
||||
impedance_setup: impedance_setup,
|
||||
};
|
||||
|
||||
let (device, tx_impl, rx_impl) = STORAGE.init(usb_driver, config, pbufs.tx_buf.as_mut_slice());
|
||||
let (device, tx_impl, rx_impl) = STORAGE.init(usb_driver, config, pbufs.tx_buf.as_mut_slice(), USB_FS_MAX_PACKET_SIZE);
|
||||
let dispatcher = MyApp::new(context, spawner.into());
|
||||
let vkk = dispatcher.min_key_len();
|
||||
let server: AppServer = Server::new(
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use embassy_embedded_hal::shared_bus::blocking::i2c::I2cDevice;
|
||||
use embassy_stm32::{i2c, mode::Blocking};
|
||||
use embassy_stm32::{i2c, mode::Blocking, i2c::Master};
|
||||
use embassy_sync::blocking_mutex::NoopMutex;
|
||||
use static_cell::StaticCell;
|
||||
use core::cell::RefCell;
|
||||
|
||||
use crate::{ad5940, adg2128::{GetX, SetX, SetY, State, ADG2128}};
|
||||
|
||||
static I2C_BUS: StaticCell<NoopMutex<RefCell<i2c::I2c<'static, Blocking>>>> = StaticCell::new();
|
||||
static I2C_BUS: StaticCell<NoopMutex<RefCell<i2c::I2c<'static, Blocking, Master>>>> = StaticCell::new();
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[allow(dead_code)]
|
||||
@@ -43,15 +43,21 @@ pub struct Electrodes {
|
||||
mux_2: ADG2128,
|
||||
}
|
||||
|
||||
const MUX_1_ADDRESS: u8 = 0b1110_000;
|
||||
const MUX_2_ADDRESS: u8 = 0b1110_001;
|
||||
|
||||
impl Electrodes {
|
||||
pub fn new(i2c: i2c::I2c<'static, Blocking>) -> Self {
|
||||
pub fn new(mut i2c: i2c::I2c<'static, Blocking, Master>) -> Result<Self, &'static str> {
|
||||
if i2c.blocking_write(MUX_1_ADDRESS, &[0x00]).is_err() { return Err("Failed to communicate with MUX 1"); }
|
||||
if i2c.blocking_write(MUX_2_ADDRESS, &[0x00]).is_err() { return Err("Failed to communicate with MUX 2"); }
|
||||
|
||||
let i2c_bus = NoopMutex::new(RefCell::new(i2c));
|
||||
let i2c_bus = I2C_BUS.init(i2c_bus);
|
||||
|
||||
Electrodes {
|
||||
mux_1: ADG2128::new(I2cDevice::new(i2c_bus), 0b1110_000),
|
||||
mux_2: ADG2128::new(I2cDevice::new(i2c_bus), 0b1110_001),
|
||||
}
|
||||
Ok(Electrodes {
|
||||
mux_1: ADG2128::new(I2cDevice::new(i2c_bus), MUX_1_ADDRESS),
|
||||
mux_2: ADG2128::new(I2cDevice::new(i2c_bus), MUX_2_ADDRESS),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set(&mut self, electrode: Electrode, ad5940_pin: AD5940Pin, state: State) {
|
||||
|
||||
@@ -17,6 +17,8 @@ use core::f32::consts::PI;
|
||||
use crate::ad5940::*;
|
||||
use crate::ad5940_registers::*;
|
||||
|
||||
use crate::electrodes::Electrodes;
|
||||
|
||||
use bioz_icd_rs::{SingleImpedanceOutput, IcdDftNum, ImpedanceInitError, MeasurementPointSet, SweepImpedanceOutput};
|
||||
use crate::icd_mapping::IntoDftnum;
|
||||
|
||||
@@ -55,11 +57,12 @@ pub struct ImpedanceSetup {
|
||||
dsp_config: Option<DspConfig>,
|
||||
pub running_mode: RunningMode,
|
||||
pub rtia_calibrated: RtiaCalibrated,
|
||||
pub electrodes: Option<Electrodes>,
|
||||
}
|
||||
|
||||
impl ImpedanceSetup {
|
||||
pub fn new(ad5940: AD5940) -> Self {
|
||||
ImpedanceSetup { ad5940, dsp_config: None, running_mode: RunningMode::None, rtia_calibrated: RtiaCalibrated::None }
|
||||
ImpedanceSetup { ad5940, dsp_config: None, running_mode: RunningMode::None, rtia_calibrated: RtiaCalibrated::None, electrodes: None }
|
||||
}
|
||||
|
||||
pub async fn init(&mut self) -> Result<(), Error> {
|
||||
@@ -120,6 +123,11 @@ impl ImpedanceSetup {
|
||||
let config_wgcon = WGCON::TYPESEL_SIN.bits();
|
||||
self.ad5940.write_reg(Register::WGCON, config_wgcon).await.unwrap();
|
||||
|
||||
// Configure GPIOs
|
||||
// Make sure that GP0 (INT), GP1 (MULTIPLEXER CONTROL) and GP2 (LED) are set as output and are high
|
||||
self.ad5940.write_reg(Register::GP0CON, 0b10 << 4 | 0b10 << 2 | 0b10).await.unwrap();
|
||||
self.ad5940.write_reg(Register::SYNCEXTDEVICE, 0b111).await.unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
46
src/main.rs
46
src/main.rs
@@ -8,7 +8,7 @@ use embassy_sync::mutex::Mutex;
|
||||
use embassy_time::{Timer, Duration};
|
||||
use embassy_futures::{select::select, select::Either};
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::{spi, Config};
|
||||
use embassy_stm32::{i2c, spi, Config};
|
||||
use embassy_stm32::time::Hertz;
|
||||
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
@@ -19,11 +19,11 @@ use {defmt_rtt as _, panic_probe as _};
|
||||
mod ad5940;
|
||||
use ad5940::AD5940;
|
||||
|
||||
// mod adg2128;
|
||||
// use adg2128::State;
|
||||
mod adg2128;
|
||||
use adg2128::State;
|
||||
|
||||
// mod electrodes;
|
||||
// use electrodes::{Electrodes, Electrode, AD5940Pin};
|
||||
mod electrodes;
|
||||
use electrodes::{Electrodes, Electrode, AD5940Pin};
|
||||
|
||||
mod ad5940_registers;
|
||||
|
||||
@@ -100,21 +100,29 @@ async fn main(spawner: Spawner) {
|
||||
|
||||
// impedance_setup.lock().await.init_single_frequency_measurement().await;
|
||||
|
||||
// // Set up I2C for ADG2128
|
||||
// let i2c = i2c::I2c::new_blocking(
|
||||
// p.I2C1,
|
||||
// p.PB6,
|
||||
// p.PB7,
|
||||
// Hertz(400_000),
|
||||
// i2c::Config::default()
|
||||
// );
|
||||
// Set up I2C for ADG2128
|
||||
let mut i2c_config = i2c::Config::default();
|
||||
i2c_config.frequency = Hertz(400_000);
|
||||
let i2c = i2c::I2c::new_blocking(
|
||||
p.I2C1,
|
||||
p.PB6,
|
||||
p.PB7,
|
||||
i2c_config
|
||||
);
|
||||
|
||||
// // Initialize electrodes
|
||||
// let mut electrodes = Electrodes::new(i2c);
|
||||
// electrodes.reset_all();
|
||||
// electrodes.set(Electrode::E1, AD5940Pin::CE0, State::ENABLED);
|
||||
// electrodes.set(Electrode::E3, AD5940Pin::AIN1, State::ENABLED);
|
||||
// // electrodes.set(Electrode::E12, AD5940Pin::RE0, State::ENABLED);
|
||||
// Initialize electrodes
|
||||
match Electrodes::new(i2c) {
|
||||
Ok(mut e) => {
|
||||
e.reset_all();
|
||||
e.set(Electrode::E1, AD5940Pin::CE0, State::ENABLED);
|
||||
e.set(Electrode::E23, AD5940Pin::AIN1, State::ENABLED);
|
||||
impedance_setup.lock().await.electrodes = Some(e);
|
||||
},
|
||||
Err(e) => {
|
||||
info!("Error initializing electrodes: {}", e);
|
||||
impedance_setup.lock().await.electrodes = None;
|
||||
}
|
||||
};
|
||||
|
||||
// Turn on the green LED
|
||||
// ad5940.write_reg_raw(0x0000_0004, 1 << 1).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user