From 03f17d5cd682da99f3d9326d8ca4eff9a59d9614 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Mon, 29 Dec 2025 23:22:18 +0100 Subject: [PATCH 1/3] initial reoder of folders and library crate creation --- .cargo/config.toml | 12 - Cargo.lock | 181 +++--- Cargo.toml | 39 +- firmware/.cargo/config.toml | 14 + firmware/Cargo.lock | 937 ++++++++++++++++++++++++++++ firmware/Cargo.toml | 44 ++ build.rs => firmware/build.rs | 0 memory.x => firmware/memory.x | 0 {src => firmware/src}/main.rs | 0 lib-bms-protocol/.cargo/config.toml | 5 + lib-bms-protocol/Cargo.toml | 17 + lib-bms-protocol/src/lib.rs | 27 + src/i2c_slave.rs | 23 - 13 files changed, 1119 insertions(+), 180 deletions(-) create mode 100644 firmware/.cargo/config.toml create mode 100644 firmware/Cargo.lock create mode 100644 firmware/Cargo.toml rename build.rs => firmware/build.rs (100%) rename memory.x => firmware/memory.x (100%) rename {src => firmware/src}/main.rs (100%) create mode 100644 lib-bms-protocol/.cargo/config.toml create mode 100644 lib-bms-protocol/Cargo.toml create mode 100644 lib-bms-protocol/src/lib.rs delete mode 100644 src/i2c_slave.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index c0b2201..5b46eb4 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,14 +1,2 @@ [build] target = "riscv32imc-unknown-none-elf" - -[target."riscv32imc-unknown-none-elf"] -rustflags = [ -# "-C", "link-arg=-Tlink.x", -] -# runner = "riscv64-unknown-elf-gdb -q -x openocd.gdb" -# runner = "riscv-none-embed-gdb -q -x openocd.gdb" -# runner = "gdb -q -x openocd.gdb" -# runner = "wlink -v flash" - -runner = "wlink -v flash --enable-sdi-print --watch-serial --erase" -# runner = "wlink -v flash" diff --git a/Cargo.lock b/Cargo.lock index ec35180..427934a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,15 +16,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bit_field" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" [[package]] name = "bitfield" @@ -52,8 +52,8 @@ dependencies = [ "heapless", "micromath", "panic-halt", - "qingke 0.5.0", - "qingke-rt 0.5.0", + "qingke", + "qingke-rt", ] [[package]] @@ -64,9 +64,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "ch32-hal" @@ -91,8 +91,8 @@ dependencies = [ "futures", "nb 1.1.0", "proc-macro2", - "qingke 0.6.1", - "qingke-rt 0.6.1", + "qingke", + "qingke-rt", "quote", "rand_core", "sdio-host", @@ -144,7 +144,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.101", + "syn 2.0.111", ] [[package]] @@ -155,14 +155,14 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.101", + "syn 2.0.111", ] [[package]] name = "document-features" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" dependencies = [ "litrs", ] @@ -187,7 +187,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.111", ] [[package]] @@ -198,9 +198,9 @@ checksum = "2fc328bf943af66b80b98755db9106bf7e7471b0cf47dc8559cd9a6be504cc9c" [[package]] name = "embassy-futures" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f878075b9794c1e4ac788c95b728f26aa6366d32eeb10c7051389f898f7d067" +checksum = "dc2d050bdc5c21e0862a89256ed8029ae6c290a93aecefc73084b3002cdebb01" [[package]] name = "embassy-hal-internal" @@ -219,13 +219,13 @@ checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" [[package]] name = "embassy-net-driver-channel" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4818c32afec43e3cae234f324bad9a976c9aa7501022d26ff60a4017a1a006b7" +checksum = "b7b2739fbcf6cd206ae08779c7d709087b16577d255f2ea4a45bc4bbbf305b3f" dependencies = [ "embassy-futures", "embassy-net-driver", - "embassy-sync 0.6.2", + "embassy-sync 0.7.2", ] [[package]] @@ -316,7 +316,7 @@ dependencies = [ "embassy-futures", "embassy-net-driver-channel", "embassy-sync 0.6.2", - "embassy-usb-driver 0.1.0", + "embassy-usb-driver 0.1.1", "heapless", "ssmarshal", "usbd-hid", @@ -324,9 +324,12 @@ dependencies = [ [[package]] name = "embassy-usb-driver" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc247028eae04174b6635104a35b1ed336aabef4654f5e87a8f32327d231970" +checksum = "340c5ce591ef58c6449e43f51d2c53efe1bf0bb6a40cbf80afa0d259c7d52c76" +dependencies = [ + "embedded-io-async", +] [[package]] name = "embassy-usb-driver" @@ -452,7 +455,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.111", ] [[package]] @@ -515,17 +518,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "lib-bms-protocol" +version = "0.1.0" + [[package]] name = "litrs" -version = "0.4.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" [[package]] name = "log" -version = "0.4.27" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "micromath" @@ -592,9 +599,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "portable-atomic" -version = "1.11.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" +checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950" [[package]] name = "proc-macro-error" @@ -622,24 +629,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0" dependencies = [ "unicode-ident", ] -[[package]] -name = "qingke" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0230c5310b68c08a3cf8b59fbeec3e9d8e352bc6500f62cbaf9c677f42c8dfc" -dependencies = [ - "bit_field", - "critical-section", - "riscv 0.12.1", -] - [[package]] name = "qingke" version = "0.6.1" @@ -652,36 +648,14 @@ dependencies = [ "riscv 0.15.0", ] -[[package]] -name = "qingke-rt" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b955c60adac70c6d40205b1dbe9f57e1151d06aa842069cdbaef7bc07ad283fd" -dependencies = [ - "qingke 0.5.0", - "qingke-rt-macros 0.5.0", -] - [[package]] name = "qingke-rt" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8ba56c91dd9a044bd519778bcf70644d1d936fee4ea20fdc2d0e3bac8f75fb9" dependencies = [ - "qingke 0.6.1", - "qingke-rt-macros 0.6.1", -] - -[[package]] -name = "qingke-rt-macros" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f2ed46d18953ea5765ab26a07d1f092dffac2da1b4830c4397e02c3cec08501" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", + "qingke", + "qingke-rt-macros", ] [[package]] @@ -698,9 +672,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] @@ -721,19 +695,6 @@ dependencies = [ "embedded-hal 1.0.0", ] -[[package]] -name = "riscv" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea8ff73d3720bdd0a97925f0bf79ad2744b6da8ff36be3840c48ac81191d7a7" -dependencies = [ - "critical-section", - "embedded-hal 1.0.0", - "paste", - "riscv-macros 0.1.0", - "riscv-pac", -] - [[package]] name = "riscv" version = "0.15.0" @@ -743,21 +704,10 @@ dependencies = [ "critical-section", "embedded-hal 1.0.0", "paste", - "riscv-macros 0.3.0", + "riscv-macros", "riscv-pac", ] -[[package]] -name = "riscv-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f265be5d634272320a7de94cea15c22a3bfdd4eb42eb43edc528415f066a1f25" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", -] - [[package]] name = "riscv-macros" version = "0.3.0" @@ -766,7 +716,7 @@ checksum = "7d323d13972c1b104aa036bc692cd08b822c8bbf23d79a27c526095856499799" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.111", ] [[package]] @@ -783,22 +733,31 @@ checksum = "f93c025f9cfe4c388c328ece47d11a54a823da3b5ad0370b22d95ad47137f85a" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.111", ] [[package]] @@ -813,9 +772,9 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "strsim" @@ -836,9 +795,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.101" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -847,9 +806,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "usb-device" @@ -918,20 +877,20 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "zerocopy" -version = "0.8.25" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.25" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.111", ] diff --git a/Cargo.toml b/Cargo.toml index 2804a16..d0a9846 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,37 +1,6 @@ -[package] -name = "bms" -version = "0.1.0" -edition = "2021" - -[dependencies] -#ch32-hal = { git = "https://github.com/ch32-rs/ch32-hal", features = [ -ch32-hal = { git = "https://github.com/ju6ge/ch32-hal", branch = "feature/i2c-slave-api", features = [ - "ch32v203c8t6", - "memory-x", - "embassy", - "rt", - "time-driver-tim2", -], default-features = false } - -embassy-executor = { version = "0.7.0", features = [ - "arch-riscv32", - "executor-thread", -] } - -embassy-time = { version = "0.4.0" } -embassy-usb = { version = "0.3.0" } -embassy-futures = { version = "0.1.0" } - -# This is okay because we should automatically use whatever ch32-hal uses -qingke-rt = "*" -qingke = "*" - -panic-halt = "1.0" - -embedded-hal = "1.0.0" -heapless = "0.8.0" -micromath = { version = "2.1.0", features = ["num-traits"] } -ch32-metapac = { version = "0.0.6", features = ["ch32v203c8t6"] } +[workspace] +resolver = "3" +members = [ "firmware", "lib-bms-protocol" ] [profile.dev] #lto = true @@ -42,3 +11,5 @@ strip = false # symbols are not flashed to the microcontroller, so don't strip #lto = true debug = true opt-level = "z" # Optimize for size. + + diff --git a/firmware/.cargo/config.toml b/firmware/.cargo/config.toml new file mode 100644 index 0000000..c0b2201 --- /dev/null +++ b/firmware/.cargo/config.toml @@ -0,0 +1,14 @@ +[build] +target = "riscv32imc-unknown-none-elf" + +[target."riscv32imc-unknown-none-elf"] +rustflags = [ +# "-C", "link-arg=-Tlink.x", +] +# runner = "riscv64-unknown-elf-gdb -q -x openocd.gdb" +# runner = "riscv-none-embed-gdb -q -x openocd.gdb" +# runner = "gdb -q -x openocd.gdb" +# runner = "wlink -v flash" + +runner = "wlink -v flash --enable-sdi-print --watch-serial --erase" +# runner = "wlink -v flash" diff --git a/firmware/Cargo.lock b/firmware/Cargo.lock new file mode 100644 index 0000000..ec35180 --- /dev/null +++ b/firmware/Cargo.lock @@ -0,0 +1,937 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitfield" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" + +[[package]] +name = "bitmaps" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d084b0137aaa901caf9f1e8b21daa6aa24d41cd806e111335541eff9683bd6" + +[[package]] +name = "bms" +version = "0.1.0" +dependencies = [ + "ch32-hal", + "ch32-metapac 0.0.6", + "embassy-executor", + "embassy-futures", + "embassy-time 0.4.0", + "embassy-usb", + "embedded-hal 1.0.0", + "heapless", + "micromath", + "panic-halt", + "qingke 0.5.0", + "qingke-rt 0.5.0", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "ch32-hal" +version = "0.1.0" +source = "git+https://github.com/ju6ge/ch32-hal?branch=feature%2Fi2c-slave-api#9b1df89f5e8de21c7daad0f22fa7186dcfcbecdf" +dependencies = [ + "bitmaps", + "ch32-metapac 0.1.0", + "critical-section", + "embassy-futures", + "embassy-hal-internal", + "embassy-sync 0.7.2", + "embassy-time 0.5.0", + "embassy-time-driver", + "embassy-time-queue-utils", + "embassy-usb-driver 0.2.0", + "embedded-can", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-hal-nb", + "futures", + "nb 1.1.0", + "proc-macro2", + "qingke 0.6.1", + "qingke-rt 0.6.1", + "quote", + "rand_core", + "sdio-host", +] + +[[package]] +name = "ch32-metapac" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edc8e84ea6d10960c6018df65845a5dfa87dfefbc3bb9f058b6ed2a24fec1db6" +dependencies = [ + "riscv 0.11.1", + "vcell", +] + +[[package]] +name = "ch32-metapac" +version = "0.1.0" +source = "git+https://github.com/ch32-rs/ch32-metapac?rev=b1cbc7a98e43af3fd3170821654784e2c01cb26b#b1cbc7a98e43af3fd3170821654784e2c01cb26b" +dependencies = [ + "riscv 0.11.1", + "vcell", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[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 2.0.101", +] + +[[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 2.0.101", +] + +[[package]] +name = "document-features" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +dependencies = [ + "litrs", +] + +[[package]] +name = "embassy-executor" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90327bcc66333a507f89ecc4e2d911b265c45f5c9bc241f98eee076752d35ac6" +dependencies = [ + "critical-section", + "document-features", + "embassy-executor-macros", +] + +[[package]] +name = "embassy-executor-macros" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3577b1e9446f61381179a330fc5324b01d511624c55f25e3c66c9e3c626dbecf" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f878075b9794c1e4ac788c95b728f26aa6366d32eeb10c7051389f898f7d067" + +[[package]] +name = "embassy-hal-internal" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a" +dependencies = [ + "num-traits", +] + +[[package]] +name = "embassy-net-driver" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" + +[[package]] +name = "embassy-net-driver-channel" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4818c32afec43e3cae234f324bad9a976c9aa7501022d26ff60a4017a1a006b7" +dependencies = [ + "embassy-futures", + "embassy-net-driver", + "embassy-sync 0.6.2", +] + +[[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", + "embedded-io-async", + "futures-sink", + "futures-util", + "heapless", +] + +[[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", + "embedded-io-async", + "futures-core", + "futures-sink", + "heapless", +] + +[[package]] +name = "embassy-time" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f820157f198ada183ad62e0a66f554c610cdcd1a9f27d4b316358103ced7a1f8" +dependencies = [ + "cfg-if", + "critical-section", + "document-features", + "embassy-time-driver", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "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", + "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", +] + +[[package]] +name = "embassy-usb" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d0b882133fa684b9d4652351cd7aac5afe8a2c2bf4a7da59f442ff61087cda2" +dependencies = [ + "embassy-futures", + "embassy-net-driver-channel", + "embassy-sync 0.6.2", + "embassy-usb-driver 0.1.0", + "heapless", + "ssmarshal", + "usbd-hid", +] + +[[package]] +name = "embassy-usb-driver" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fc247028eae04174b6635104a35b1ed336aabef4654f5e87a8f32327d231970" + +[[package]] +name = "embassy-usb-driver" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a" +dependencies = [ + "embedded-io-async", +] + +[[package]] +name = "embedded-can" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" +dependencies = [ + "nb 1.1.0", +] + +[[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" + +[[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-hal-nb" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba4268c14288c828995299e59b12babdbe170f6c6d73731af1b4648142e8605" +dependencies = [ + "embedded-hal 1.0.0", + "nb 1.1.0", +] + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "embedded-io-async" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" +dependencies = [ + "embedded-io", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[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-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[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-macro", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[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 = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "micromath" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" +dependencies = [ + "num-traits", +] + +[[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 = "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 = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[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 = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "qingke" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0230c5310b68c08a3cf8b59fbeec3e9d8e352bc6500f62cbaf9c677f42c8dfc" +dependencies = [ + "bit_field", + "critical-section", + "riscv 0.12.1", +] + +[[package]] +name = "qingke" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10318bf64fc0befbcd09d7a9a62d8b99972ba3dfdd4a94695f63fd892f47e14e" +dependencies = [ + "bit_field", + "cfg-if", + "critical-section", + "riscv 0.15.0", +] + +[[package]] +name = "qingke-rt" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b955c60adac70c6d40205b1dbe9f57e1151d06aa842069cdbaef7bc07ad283fd" +dependencies = [ + "qingke 0.5.0", + "qingke-rt-macros 0.5.0", +] + +[[package]] +name = "qingke-rt" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8ba56c91dd9a044bd519778bcf70644d1d936fee4ea20fdc2d0e3bac8f75fb9" +dependencies = [ + "qingke 0.6.1", + "qingke-rt-macros 0.6.1", +] + +[[package]] +name = "qingke-rt-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f2ed46d18953ea5765ab26a07d1f092dffac2da1b4830c4397e02c3cec08501" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "qingke-rt-macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54edcd0e9b8b5c3c83d313c93869325bfcd969d30d9cef1a1015b0970b21be81" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "riscv" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f5c1b8bf41ea746266cdee443d1d1e9125c86ce1447e1a2615abd34330d33a9" +dependencies = [ + "critical-section", + "embedded-hal 1.0.0", +] + +[[package]] +name = "riscv" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea8ff73d3720bdd0a97925f0bf79ad2744b6da8ff36be3840c48ac81191d7a7" +dependencies = [ + "critical-section", + "embedded-hal 1.0.0", + "paste", + "riscv-macros 0.1.0", + "riscv-pac", +] + +[[package]] +name = "riscv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05cfa3f7b30c84536a9025150d44d26b8e1cc20ddf436448d74cd9591eefb25" +dependencies = [ + "critical-section", + "embedded-hal 1.0.0", + "paste", + "riscv-macros 0.3.0", + "riscv-pac", +] + +[[package]] +name = "riscv-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f265be5d634272320a7de94cea15c22a3bfdd4eb42eb43edc528415f066a1f25" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "riscv-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d323d13972c1b104aa036bc692cd08b822c8bbf23d79a27c526095856499799" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "riscv-pac" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8188909339ccc0c68cfb5a04648313f09621e8b87dc03095454f1a11f6c5d436" + +[[package]] +name = "sdio-host" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93c025f9cfe4c388c328ece47d11a54a823da3b5ad0370b22d95ad47137f85a" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "ssmarshal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" +dependencies = [ + "encode_unicode", + "serde", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "usb-device" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6" +dependencies = [ + "heapless", + "portable-atomic", +] + +[[package]] +name = "usbd-hid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f291ab53d428685cc780f08a2eb9d5d6ff58622db2b36e239a4f715f1e184c" +dependencies = [ + "serde", + "ssmarshal", + "usb-device", + "usbd-hid-macros", +] + +[[package]] +name = "usbd-hid-descriptors" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee54712c5d778d2fb2da43b1ce5a7b5060886ef7b09891baeb4bf36910a3ed" +dependencies = [ + "bitfield", +] + +[[package]] +name = "usbd-hid-macros" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb573c76e7884035ac5e1ab4a81234c187a82b6100140af0ab45757650ccda38" +dependencies = [ + "byteorder", + "hashbrown", + "log", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "usbd-hid-descriptors", +] + +[[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "zerocopy" +version = "0.8.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] diff --git a/firmware/Cargo.toml b/firmware/Cargo.toml new file mode 100644 index 0000000..57faf63 --- /dev/null +++ b/firmware/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "bms" +version = "0.1.0" +edition = "2021" + +[dependencies] +#ch32-hal = { git = "https://github.com/ch32-rs/ch32-hal", features = [ +ch32-hal = { git = "https://github.com/ju6ge/ch32-hal", branch = "feature/i2c-slave-api", features = [ + "ch32v203c8t6", + "memory-x", + "embassy", + "rt", + "time-driver-tim2", +], default-features = false } + +embassy-executor = { version = "0.7.0", features = [ + "arch-riscv32", + "executor-thread", +] } + +embassy-time = { version = "0.4.0" } +embassy-usb = { version = "0.3.0" } +embassy-futures = { version = "0.1.0" } + +# This is okay because we should automatically use whatever ch32-hal uses +qingke-rt = "*" +qingke = "*" + +panic-halt = "1.0" + +embedded-hal = "1.0.0" +heapless = "0.8.0" +micromath = { version = "2.1.0", features = ["num-traits"] } +ch32-metapac = { version = "0.0.6", features = ["ch32v203c8t6"] } + +[profile.dev] +#lto = true +opt-level = "s" + +[profile.release] +strip = false # symbols are not flashed to the microcontroller, so don't strip them. +#lto = true +debug = true +opt-level = "z" # Optimize for size. diff --git a/build.rs b/firmware/build.rs similarity index 100% rename from build.rs rename to firmware/build.rs diff --git a/memory.x b/firmware/memory.x similarity index 100% rename from memory.x rename to firmware/memory.x diff --git a/src/main.rs b/firmware/src/main.rs similarity index 100% rename from src/main.rs rename to firmware/src/main.rs diff --git a/lib-bms-protocol/.cargo/config.toml b/lib-bms-protocol/.cargo/config.toml new file mode 100644 index 0000000..3b7f992 --- /dev/null +++ b/lib-bms-protocol/.cargo/config.toml @@ -0,0 +1,5 @@ + +[target."riscv32imc-unknown-none-elf"] +rustflags = [ +# "-C", "link-arg=-Tlink.x", +] diff --git a/lib-bms-protocol/Cargo.toml b/lib-bms-protocol/Cargo.toml new file mode 100644 index 0000000..62ddd04 --- /dev/null +++ b/lib-bms-protocol/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "lib-bms-protocol" +version = "0.1.0" +edition = "2024" + +[dependencies] + + +[profile.dev] +#lto = true +opt-level = 1 + +[profile.release] +strip = false # symbols are not flashed to the microcontroller, so don't strip them. +#lto = true +debug = true +opt-level = "z" # Optimize for size. diff --git a/lib-bms-protocol/src/lib.rs b/lib-bms-protocol/src/lib.rs new file mode 100644 index 0000000..24659b4 --- /dev/null +++ b/lib-bms-protocol/src/lib.rs @@ -0,0 +1,27 @@ +#![no_std] + + +#[derive(Debug)] +pub struct Version(u32); + + +#[derive(Debug)] +pub struct Config { + capacity_mah: u32, + v_full_mv: u32, + v_empty_mv: u32, +} + +pub struct BatteryState { + lifetime_capacity_mAh: u32, + remaining_capacity_mAh: u32, + current_milli_volts: u16, + temperature_celcius: i32, + health_percent: u8 +} + +pub enum BmsCommand { + GetVersion, + GetConfig, + GetBatteryState, +} diff --git a/src/i2c_slave.rs b/src/i2c_slave.rs deleted file mode 100644 index 63b31b0..0000000 --- a/src/i2c_slave.rs +++ /dev/null @@ -1,23 +0,0 @@ -use ch32_hal::{ - self as hal, - i2c::{SclPin, SdaPin}, - Peripheral, - }; -use panic_halt as _; - -use core::marker::PhantomData; -use hal::i2c::Instance; - -pub struct I2cSlave<'d, T: Instance> { - _phantom: PhantomData<&'d mut T>, -} - -impl<'d, T: Instance> I2cSlave<'d, T> { - pub fn new( - peri: impl Peripheral

+ 'd, - scl: impl Peripheral

> + 'd, - sda: impl Peripheral

> + 'd, - ) -> Self { - todo!() - } -} From df6d9bf03d2d366b242eaa4dc9fbfa9a5a0ff3ba Mon Sep 17 00:00:00 2001 From: ju6ge Date: Thu, 1 Jan 2026 21:20:55 +0100 Subject: [PATCH 2/3] starting with library and measurment implementation --- Cargo.lock | 34 +++++++++++++++++++++++++++ firmware/Cargo.toml | 4 ++++ firmware/src/main.rs | 24 +++++++++++++++++-- firmware/src/measurement.rs | 47 +++++++++++++++++++++++++++++++++++++ lib-bms-protocol/src/lib.rs | 18 +++++++------- 5 files changed, 117 insertions(+), 10 deletions(-) create mode 100644 firmware/src/measurement.rs diff --git a/Cargo.lock b/Cargo.lock index 427934a..2db1753 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,14 +46,18 @@ dependencies = [ "ch32-metapac 0.0.6", "embassy-executor", "embassy-futures", + "embassy-sync 0.7.2", "embassy-time 0.4.0", "embassy-usb", "embedded-hal 1.0.0", "heapless", + "ina219", + "lib-bms-protocol", "micromath", "panic-halt", "qingke", "qingke-rt", + "thiserror", ] [[package]] @@ -518,6 +522,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "ina219" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "457a68120d2d0f0ca1b5c7f8e0ff3f77db9e34b1076a4e82f7097cbde7d2aaa4" +dependencies = [ + "embedded-hal 1.0.0", + "embedded-hal-async", +] + [[package]] name = "lib-bms-protocol" version = "0.1.0" @@ -804,6 +818,26 @@ dependencies = [ "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 2.0.111", +] + [[package]] name = "unicode-ident" version = "1.0.22" diff --git a/firmware/Cargo.toml b/firmware/Cargo.toml index 57faf63..fa74169 100644 --- a/firmware/Cargo.toml +++ b/firmware/Cargo.toml @@ -21,6 +21,7 @@ embassy-executor = { version = "0.7.0", features = [ embassy-time = { version = "0.4.0" } embassy-usb = { version = "0.3.0" } embassy-futures = { version = "0.1.0" } +embassy-sync = { version = "0.7.2" } # This is okay because we should automatically use whatever ch32-hal uses qingke-rt = "*" @@ -32,6 +33,9 @@ embedded-hal = "1.0.0" heapless = "0.8.0" micromath = { version = "2.1.0", features = ["num-traits"] } ch32-metapac = { version = "0.0.6", features = ["ch32v203c8t6"] } +ina219 = "0.2.0" +lib-bms-protocol = { path = "../lib-bms-protocol" } +thiserror = { version = "2.0.17", default-features = false } [profile.dev] #lto = true diff --git a/firmware/src/main.rs b/firmware/src/main.rs index c699b99..3361c5d 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -3,20 +3,40 @@ #![feature(type_alias_impl_trait)] #![feature(impl_trait_in_assoc_type)] +mod measurement; + +use ch32_hal::i2c::mode::OperatingMode; +use ch32_hal::mode::Mode; use ch32_hal::println; use ch32_hal::time::Hertz; use embassy_executor::Spawner; +use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; +use embassy_sync::lazy_lock::LazyLock; +use embassy_sync::mutex::Mutex; +use embassy_sync::rwlock::RwLock; //use embassy_time::{Duration, Timer}; use hal::bind_interrupts; use hal::i2c::{Config, I2c, SlaveAddress, SlaveConfig}; use {ch32_hal as hal, panic_halt as _}; - bind_interrupts!(struct Irqs { I2C1_EV => ch32_hal::i2c::EventInterruptHandler; I2C1_ER => ch32_hal::i2c::ErrorInterruptHandler; }); +const MEASUREMENT_SAMPLES_CAPACITY: usize = 1024; +static MEASUREMENTS: LazyLock< + embassy_sync::mutex::Mutex< + CriticalSectionRawMutex, + heapless::Deque, + >, +> = LazyLock::new(|| Mutex::new(heapless::Deque::new())); + +async fn measurement_task<'m, M: Mode, O: OperatingMode>( + i2c_dev: I2c<'m, ch32_hal::peripherals::I2C2, M, O>, +) { +} + #[embassy_executor::main(entry = "qingke_rt::entry")] async fn main(_spawner: Spawner) -> ! { let p = hal::init(Default::default()); @@ -44,7 +64,7 @@ async fn main(_spawner: Spawner) -> ! { println!("received byte 0x{buf:x?}"); } } - }, + } Err(err) => { println!("{:?}", err) } diff --git a/firmware/src/measurement.rs b/firmware/src/measurement.rs new file mode 100644 index 0000000..cfc03fc --- /dev/null +++ b/firmware/src/measurement.rs @@ -0,0 +1,47 @@ + +use embassy_usb::msos::ConfigurationSubsetHeader; +use lib_bms_protocol::BatteryState; + +use ina219::{address::Address, calibration::{IntCalibration, MicroAmpere, MicroWatt, UnCalibrated}, configuration::Configuration, errors::{ConfigurationReadError, InitializationError}, measurements::{CurrentRegister, Measurements, PowerRegister}, SyncIna219}; +use thiserror::Error; + +pub(crate) const INA219_DEVICE_ADDR: u8 = 0b100_1011; + +#[derive(Debug, Error)] +pub(crate) enum MeasurementError { + #[error("ina219 sensor initialization failed")] + Ina219InitError, + #[error("ina219 configuration read error")] + Ina219ConfigReadErr, + #[error("ina219 measurement read error")] + Ina219MeasurementReadError, +} + +impl From> for MeasurementError { + fn from(value: ina219::errors::MeasurementError) -> Self { + MeasurementError::Ina219MeasurementReadError + } +} + +impl From> for MeasurementError { + fn from(value: ConfigurationReadError) -> Self { + MeasurementError::Ina219InitError + } +} + +impl From> for MeasurementError { + fn from(value: InitializationError) -> Self { + MeasurementError::Ina219InitError + } +} + +pub(crate) fn read_ina219(i2c_dev: &mut T) -> Result, MeasurementError> { + let mut dev: SyncIna219<&mut T, _> = SyncIna219::new_calibrated(i2c_dev, Address::from_byte(INA219_DEVICE_ADDR).unwrap(), IntCalibration::default())?; + let config: Configuration = dev.configuration()?; + + if let Some(ina_measurement) = dev.next_measurement()? { + let ina_measurement: Measurements = ina_measurement; + } + let measurement = todo!(); + Ok(measurement) +} diff --git a/lib-bms-protocol/src/lib.rs b/lib-bms-protocol/src/lib.rs index 24659b4..842be77 100644 --- a/lib-bms-protocol/src/lib.rs +++ b/lib-bms-protocol/src/lib.rs @@ -2,22 +2,24 @@ #[derive(Debug)] +#[repr(transparent)] pub struct Version(u32); #[derive(Debug)] pub struct Config { - capacity_mah: u32, - v_full_mv: u32, - v_empty_mv: u32, + pub capacity_mah: u32, + pub v_full_mv: u32, + pub v_empty_mv: u32, } +#[derive(Debug, Clone, Copy)] pub struct BatteryState { - lifetime_capacity_mAh: u32, - remaining_capacity_mAh: u32, - current_milli_volts: u16, - temperature_celcius: i32, - health_percent: u8 + pub lifetime_capacity_mah: u32, + pub remaining_capacity_mah: u32, + pub current_mv: u16, + pub temperature_celcius: i32, + pub health_percent: u8 } pub enum BmsCommand { From 95c5045a0062a7530f432b63ca3d1a1fc2cd2ede Mon Sep 17 00:00:00 2001 From: ju6ge Date: Sun, 4 Jan 2026 14:00:25 +0100 Subject: [PATCH 3/3] inital structure for bms communication protocol implemented --- Cargo.lock | 3 + lib-bms-protocol/Cargo.toml | 1 + lib-bms-protocol/src/lib.rs | 177 ++++++++++++++++++++++++++++++++++-- 3 files changed, 173 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2db1753..7b380ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -535,6 +535,9 @@ dependencies = [ [[package]] name = "lib-bms-protocol" version = "0.1.0" +dependencies = [ + "embedded-hal 1.0.0", +] [[package]] name = "litrs" diff --git a/lib-bms-protocol/Cargo.toml b/lib-bms-protocol/Cargo.toml index 62ddd04..2964329 100644 --- a/lib-bms-protocol/Cargo.toml +++ b/lib-bms-protocol/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] +embedded-hal = "1.0.0" [profile.dev] diff --git a/lib-bms-protocol/src/lib.rs b/lib-bms-protocol/src/lib.rs index 842be77..0b61641 100644 --- a/lib-bms-protocol/src/lib.rs +++ b/lib-bms-protocol/src/lib.rs @@ -1,29 +1,190 @@ #![no_std] +use embedded_hal::i2c::{I2c, Operation, SevenBitAddress}; + +pub const BMS_I2C_ADDRESS: u8 = 0x55; + +pub trait BmsReadable { + fn read_from_i2c(i2c_dev: &mut I) -> Result + where + Self: Sized, + I: I2c; +} + +pub trait BmsWriteable { + fn write_to_device(&self, i2c_dev: &mut I) -> Result<(), BmsProtocolError> + where + I: I2c; +} + +pub enum BmsProtocolError { + I2cCommunicationError, +} + +impl From for BmsProtocolError +where + E: embedded_hal::i2c::Error, +{ + fn from(_value: E) -> Self { + Self::I2cCommunicationError + } +} + +#[derive(Debug)] +pub struct BmsSoftwareReset; + +impl BmsWriteable for BmsSoftwareReset { + fn write_to_device(&self, i2c_dev: &mut I) -> Result<(), BmsProtocolError> + where + I: I2c, + { + i2c_dev.write( + BMS_I2C_ADDRESS, + &(BmsRegisterMap::Reset as u32).to_be_bytes(), + )?; + Ok(()) + } +} #[derive(Debug)] #[repr(transparent)] -pub struct Version(u32); +pub struct ProtocolVersion(u32); +impl BmsReadable for ProtocolVersion { + fn read_from_i2c(i2c_dev: &mut I) -> Result + where + Self: Sized, + I: I2c, + { + let cmd = BmsRegisterMap::ProtocolVersion; + let mut version: [u8; 4] = [0x00; 4]; + i2c_dev.transaction( + BMS_I2C_ADDRESS, + &mut [ + Operation::Write(&(cmd as u32).to_be_bytes()), + Operation::Read(&mut version), + ], + )?; + Ok(ProtocolVersion(u32::from_be_bytes(version))) + } +} + +#[derive(Debug)] +#[repr(transparent)] +pub struct FirmwareVersion(u32); + +impl BmsReadable for FirmwareVersion { + fn read_from_i2c(i2c_dev: &mut I) -> Result + where + Self: Sized, + I: I2c, + { + let cmd = BmsRegisterMap::FirmwareVersion; + let mut version: [u8; 4] = [0x00; 4]; + i2c_dev.transaction( + BMS_I2C_ADDRESS, + &mut [ + Operation::Write(&(cmd as u32).to_be_bytes()), + Operation::Read(&mut version), + ], + )?; + Ok(FirmwareVersion(u32::from_be_bytes(version))) + } +} #[derive(Debug)] pub struct Config { pub capacity_mah: u32, - pub v_full_mv: u32, + pub v_full_mv: u32, pub v_empty_mv: u32, } +impl BmsReadable for Config { + fn read_from_i2c(i2c_dev: &mut I) -> Result + where + Self: Sized, + I: I2c, + { + let cmd = BmsRegisterMap::ConfigCapacityMilliAmpereHours; + let mut capacity_mah: [u8; 4] = [0x00; 4]; + let mut v_full_mv: [u8; 4] = [0x00; 4]; + let mut v_empty_mv: [u8; 4] = [0x00; 4]; + i2c_dev.transaction( + BMS_I2C_ADDRESS, + &mut [ + Operation::Write(&(cmd as u32).to_be_bytes()), + Operation::Read(&mut capacity_mah), + Operation::Read(&mut v_full_mv), + Operation::Read(&mut v_empty_mv), + ], + )?; + Ok(Config { + capacity_mah: u32::from_be_bytes(capacity_mah), + v_full_mv: u32::from_be_bytes(v_full_mv), + v_empty_mv: u32::from_be_bytes(v_empty_mv), + }) + } +} + #[derive(Debug, Clone, Copy)] pub struct BatteryState { pub lifetime_capacity_mah: u32, pub remaining_capacity_mah: u32, - pub current_mv: u16, + pub current_mv: u32, pub temperature_celcius: i32, - pub health_percent: u8 + pub health_percent: u32, } -pub enum BmsCommand { - GetVersion, - GetConfig, - GetBatteryState, +impl BmsReadable for BatteryState { + fn read_from_i2c(i2c_dev: &mut I) -> Result + where + Self: Sized, + I: I2c, + { + let cmd = BmsRegisterMap::BatteryLifetimeCapacityMilliAmpereHours; + let mut lifetime_capacity_mah: [u8; 4] = [0x00; 4]; + let mut remaining_capacity_mah: [u8; 4] = [0x00; 4]; + let mut current_mv: [u8; 4] = [0x00; 4]; + let mut temperature_celcius: [u8; 4] = [0x00; 4]; + let mut health_percent: [u8; 4] = [0x00; 4]; + i2c_dev.transaction( + BMS_I2C_ADDRESS, + &mut [ + Operation::Write(&(cmd as u32).to_be_bytes()), + Operation::Read(&mut lifetime_capacity_mah), + Operation::Read(&mut remaining_capacity_mah), + Operation::Read(&mut current_mv), + Operation::Read(&mut temperature_celcius), + Operation::Read(&mut health_percent), + ], + )?; + Ok(BatteryState { + lifetime_capacity_mah: u32::from_be_bytes(lifetime_capacity_mah), + remaining_capacity_mah: u32::from_be_bytes(remaining_capacity_mah), + current_mv: u32::from_be_bytes(current_mv), + temperature_celcius: i32::from_be_bytes(temperature_celcius), + health_percent: u32::from_be_bytes(health_percent), + }) + } +} + +#[repr(u32)] +#[non_exhaustive] +pub enum BmsRegisterMap { + // software reset register + Reset = 0x00000000, + // bms protocol revesion as u32 value + ProtocolVersion = 0x00000001, + // bms firmware revesion as u32 value + FirmwareVersion = 0x00000002, + // Configuration Values Start Here + ConfigCapacityMilliAmpereHours = 0x00010000, + ConfigFullMilliVolt = 0x00010004, + ConfigEmptyMilliVolt = 0x00010008, + // Battery State Values Start Here + BatteryLifetimeCapacityMilliAmpereHours = 0x00020000, + BatteryRemainingCapacityMilliAmpereHours = 0x00020004, + BatteryCurrentVoltageMilliVolt = 0x00020008, + BatteryTemperatureCelcius = 0x0002000c, + BatteryHealthPercent = 0x00020010, }