From cdaa4754b2bfb4dac03a303ed3113ebc835bcaaa Mon Sep 17 00:00:00 2001 From: shimun Date: Sun, 14 Apr 2024 14:37:40 +0200 Subject: [PATCH] wip --- Cargo.lock | 596 +++++++++++++++++++++++++++++----------------------- Cargo.toml | 13 +- flake.lock | 42 ++-- flake.nix | 2 +- src/main.rs | 131 +++++++----- 5 files changed, 447 insertions(+), 337 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1e84ec..cf9c4a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "atomic-polyfill" version = "0.1.11" @@ -22,9 +13,9 @@ dependencies = [ [[package]] name = "atomic-polyfill" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d299f547288d6db8d5c3a2916f7b2f66134b15b8c1ac1c4357dd3b8752af7bb2" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" dependencies = [ "critical-section", ] @@ -36,22 +27,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "bare-metal" -version = "1.0.0" +name = "basic-toml" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" +checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" +dependencies = [ + "serde", +] [[package]] name = "bit_field" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitfield" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bytemuck" -version = "1.12.3" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" [[package]] name = "byteorder" @@ -67,125 +73,83 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "critical-section" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" [[package]] name = "darling" -version = "0.13.4" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ - "darling_core 0.13.4", - "darling_macro 0.13.4", -] - -[[package]] -name = "darling" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" -dependencies = [ - "darling_core 0.14.2", - "darling_macro 0.14.2", + "darling_core", + "darling_macro", ] [[package]] name = "darling_core" -version = "0.13.4" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn", -] - -[[package]] -name = "darling_core" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", + "syn 2.0.30", ] [[package]] name = "darling_macro" -version = "0.13.4" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ - "darling_core 0.13.4", + "darling_core", "quote", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" -dependencies = [ - "darling_core 0.14.2", - "quote", - "syn", + "syn 2.0.30", ] [[package]] name = "embassy-executor" -version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=eed34f9#eed34f945ccd5c4ef2af77230042dd4954e981ac" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acebf176f4622fd87c7200b568ee32d5b435e3a4d58e39355ce0837b45139eca" dependencies = [ - "atomic-polyfill 1.0.1", - "cfg-if", + "atomic-polyfill 1.0.3", "critical-section", "embassy-macros", - "embassy-time 0.1.0 (git+https://github.com/embassy-rs/embassy/?rev=eed34f9)", + "embassy-time", "futures-util", "static_cell", ] [[package]] -name = "embassy-macros" -version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=eed34f9#eed34f945ccd5c4ef2af77230042dd4954e981ac" -dependencies = [ - "darling 0.13.4", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "embassy-sync" +name = "embassy-futures" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6ea38e6ea5d0361d087680f786c19a1454becb06174790280534a3be05ed839" +checksum = "47e5367165d347c039360f784812f493b001583ab6a3dd8622f4ce9c30374ec3" + +[[package]] +name = "embassy-macros" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d3eef431adfc517df1601e367f72b1c28a51c6eb91def7dc297be7fc8789a4" dependencies = [ - "atomic-polyfill 1.0.1", - "cfg-if", - "critical-section", - "embedded-io", - "futures-util", - "heapless", + "darling", + "proc-macro2", + "quote", + "syn 2.0.30", ] [[package]] name = "embassy-sync" -version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=eed34f9#eed34f945ccd5c4ef2af77230042dd4954e981ac" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0dad296a6f70bfdc32ef52442a31f98c28e1608893c1cecc9b6f419bab005a0" dependencies = [ - "atomic-polyfill 1.0.1", "cfg-if", "critical-section", "embedded-io", @@ -195,14 +159,13 @@ dependencies = [ [[package]] name = "embassy-time" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81c0c57d163dba8ff55a874966d9a1ae755859028308833923a1edeec1a6c215" +checksum = "7a0461fa8de2cf03c4363a38f439a5d7e4cc16cd41947b51663ff4b2f155b902" dependencies = [ - "atomic-polyfill 1.0.1", + "atomic-polyfill 1.0.3", "cfg-if", "critical-section", - "embassy-sync 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "embedded-hal 0.2.7", "embedded-hal-async", "futures-util", @@ -210,17 +173,12 @@ dependencies = [ ] [[package]] -name = "embassy-time" -version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=eed34f9#eed34f945ccd5c4ef2af77230042dd4954e981ac" +name = "embedded-can" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" dependencies = [ - "atomic-polyfill 1.0.1", - "cfg-if", - "critical-section", - "embassy-sync 0.1.0 (git+https://github.com/embassy-rs/embassy/?rev=eed34f9)", - "embedded-hal 0.2.7", - "futures-util", - "heapless", + "nb 1.1.0", ] [[package]] @@ -244,34 +202,50 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "1.0.0-alpha.9" +version = "1.0.0-alpha.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129b101ddfee640565f7c07b301a31d95aa21e5acef21a491c307139f5fa4c91" +checksum = "f7724ebabcadfeb15920571dd727bc8ccde8586e52f2890bdb8182fdf42c3ff2" [[package]] name = "embedded-hal-async" -version = "0.1.0-alpha.3" +version = "0.2.0-alpha.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c913f631bd08c253b85fdf0077061c64763d70e27803b04da5a49c5fb2a65057" +checksum = "918285ec7b18edb024d4adc64f6f16cdc7c4d72eadfc85c3313d1e0ff40e0229" dependencies = [ - "embedded-hal 1.0.0-alpha.9", + "embedded-hal 1.0.0-alpha.11", ] [[package]] name = "embedded-hal-nb" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0760ec0a3bf76859d5e33f39542af103f157d5b2ecfb00ace56dd461472e3a" +checksum = "a09e4c3f8a54e60803405e1cc17e36c963ab32e654f8d6bb49d48cd8116360d7" dependencies = [ - "embedded-hal 1.0.0-alpha.9", - "nb 1.0.0", + "embedded-hal 1.0.0-alpha.11", + "nb 1.1.0", ] [[package]] name = "embedded-io" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33dfba9e6c113f2fd8537c943780a7345945e66c86972e356b1152e19481bcf5" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "esp-alloc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83792eb7261a375bb838679fea2b45654b8f4a48da6bef10a96da5054aa81c7d" +dependencies = [ + "critical-section", + "linked_list_allocator", +] [[package]] name = "esp-backtrace" @@ -280,46 +254,65 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1834d20d58dc6baaf063924cb3ffa0b7f6388a593bae310c9f228c4bd47f0dde" dependencies = [ "esp-println", - "riscv 0.10.0", + "riscv", ] [[package]] name = "esp-hal-common" -version = "0.4.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007db8d84050d19fec367bece124cccbdf6837ff0ea8e1a4fc04599148ab5ea1" +checksum = "b9bb3220d63ba0ec4e9b1846edd47e8da3a884c6557b3ba7398494c56a93de35" dependencies = [ + "basic-toml", + "bitfield", + "bitflags", "cfg-if", "critical-section", - "embassy-sync 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "embassy-time 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "embassy-futures", + "embassy-sync", + "embassy-time", + "embedded-can", "embedded-dma", "embedded-hal 0.2.7", - "embedded-hal 1.0.0-alpha.9", + "embedded-hal 1.0.0-alpha.11", "embedded-hal-async", "embedded-hal-nb", "esp-hal-procmacros", - "esp32c3 0.8.1", + "esp-riscv-rt", + "esp32c3 0.16.0", "fugit", - "nb 1.0.0", + "log", + "nb 1.1.0", "paste", - "riscv 0.10.0", "riscv-atomic-emulation-trap", - "smart-leds-trait", + "serde", + "strum", "void", ] [[package]] name = "esp-hal-procmacros" -version = "0.1.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd1fb5018ef2c57daadf84e9bbff1c9e48c04958d32bc1469f781a96ec82e8e" +checksum = "042d5a1ef0e01d6de045972779e4aced3a10e6170169a5cb2de7bef31802e28a" dependencies = [ - "darling 0.14.2", + "darling", + "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.30", +] + +[[package]] +name = "esp-hal-smartled" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd1c4e28c17b0b6f7aac56a5e27c71b5e5ece3e81b49fbcfa81be2ccb9cc2f82" +dependencies = [ + "esp-hal-common", + "fugit", + "smart-leds-trait", ] [[package]] @@ -328,49 +321,55 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adcfe5d532cf2029b11996cab6b4af948f41c24b131c76422115634711549aaa" +[[package]] +name = "esp-riscv-rt" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1008d28898f6dc8bab1c01f14826399b93f7e5f910c83062fc1d19eb5b5f28" +dependencies = [ + "riscv", + "riscv-rt-macros", +] + [[package]] name = "esp32c3" version = "0.1.0" dependencies = [ - "critical-section", "embassy-executor", - "embassy-time 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "embassy-time", "embedded-hal 0.2.7", + "esp-alloc", "esp-backtrace", "esp-hal-common", + "esp-hal-smartled", "esp-println", "esp32c3-hal", - "riscv 0.10.0", - "riscv-rt", + "smart-leds", + "smart-leds-trait", "static_cell", ] [[package]] name = "esp32c3" -version = "0.8.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677b6cc003e2f7384c5bd02286e5ee04d9ac0adc875abff6c3316175af20eaa8" +checksum = "1e3775bd92a673d2c96e40ada5ad5f93448c02ce77a3f7a635b386d59e9b2880" dependencies = [ "critical-section", - "riscv 0.10.0", - "riscv-rt", "vcell", ] [[package]] name = "esp32c3-hal" -version = "0.4.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dccecada61692e6d3fb8349a630c1fc8cfac144cb3cb52763624db8ec1373111" +checksum = "8cccbc1d35013f062ae0330651d000736200692d4fdc9e1146eff540af907240" dependencies = [ "cfg-if", - "embassy-time 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "embassy-time", "embedded-hal 0.2.7", "embedded-hal-async", "esp-hal-common", - "r0", - "riscv 0.10.0", - "riscv-rt", ] [[package]] @@ -381,30 +380,30 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fugit" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab17bb279def6720d058cb6c052249938e7f99260ab534879281a95367a87e5" +checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7" dependencies = [ "gcd", ] [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", "futures-task", @@ -414,9 +413,9 @@ dependencies = [ [[package]] name = "gcd" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1b088ad0a967aa29540456b82fc8903f854775d33f71e9709c4efb3dfbfd2" +checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" [[package]] name = "hash32" @@ -427,6 +426,12 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heapless" version = "0.7.16" @@ -440,6 +445,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "ident_case" version = "1.0.1" @@ -447,26 +458,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] -name = "lazy_static" -version = "1.4.0" +name = "indexmap" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "linked_list_allocator" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", ] [[package]] -name = "memchr" -version = "2.5.0" +name = "log" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" + +[[package]] +name = "memchr" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "nb" @@ -474,26 +501,32 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" dependencies = [ - "nb 1.0.0", + "nb 1.1.0", ] [[package]] name = "nb" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "paste" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -501,6 +534,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -510,7 +553,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -527,70 +570,36 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] -[[package]] -name = "r0" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211" - -[[package]] -name = "regex" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - [[package]] name = "rgb" -version = "0.8.34" +version = "0.8.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3603b7d71ca82644f79b5a06d1220e9a58ede60bd32255f698cb1af8838b8db3" +checksum = "20ec2d3e3fc7a92ced357df9cebd5a10b6fb2aa1ee797bf7e9ce2f17dffc8f59" dependencies = [ "bytemuck", ] [[package]] name = "riscv" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fc4bc7113424814738fe79755a5764e392b3d4d1bc757e6aa6f61cede32095" -dependencies = [ - "bare-metal", - "bit_field", - "embedded-hal 0.2.7", -] - -[[package]] -name = "riscv" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "169fa82a2be03db484b13863f6a88f7f154a027a332c471cc164775671e81a5a" +checksum = "aa3145d2fae3778b1e31ec2e827b228bdc6abd9b74bb5705ba46dcb82069bc4f" dependencies = [ "bit_field", "critical-section", @@ -599,26 +608,9 @@ dependencies = [ [[package]] name = "riscv-atomic-emulation-trap" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8149334f67011146f603c58b63f5b370ae71eb9700988fde89a6d5a6cd5987ea" -dependencies = [ - "riscv 0.10.0", - "riscv-rt", - "riscv-target", -] - -[[package]] -name = "riscv-rt" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7818495e5392d1ebb158a6f65da26c23d7f0fe93f7d6affa6395bf5b77035eae" -dependencies = [ - "r0", - "riscv 0.9.0", - "riscv-rt-macros", - "riscv-target", -] +checksum = "da39f4a5642a62e8e16bb438c37e6f90ea388ca0b7960fe875ea39887155d6ba" [[package]] name = "riscv-rt-macros" @@ -628,17 +620,7 @@ checksum = "f38509d7b17c2f604ceab3e5ff8ac97bb8cd2f544688c512be75c715edaf4daf" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "riscv-target" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" -dependencies = [ - "lazy_static", - "regex", + "syn 1.0.109", ] [[package]] @@ -651,16 +633,51 @@ dependencies = [ ] [[package]] -name = "scopeguard" -version = "1.1.0" +name = "rustversion" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" + +[[package]] +name = "serde" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.30", +] + +[[package]] +name = "smart-leds" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38dd45fa275f70b4110eac5f5182611ad384f88bb22b68b9a9c3cafd7015290b" +dependencies = [ + "smart-leds-trait", +] [[package]] name = "smart-leds-trait" @@ -673,9 +690,9 @@ dependencies = [ [[package]] name = "spin" -version = "0.9.4" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ "lock_api", ] @@ -688,11 +705,11 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "static_cell" -version = "1.0.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c37c250d21f53fa7165e76e5401d7e6539c211a8d2cf449e3962956a5cc2ce" +checksum = "49cd323fc21eb534f903ee78d781d622099f9716c5b408ed23bcf39f8f1651c0" dependencies = [ - "atomic-polyfill 1.0.1", + "atomic-polyfill 1.0.3", ] [[package]] @@ -702,10 +719,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] -name = "syn" -version = "1.0.107" +name = "strum" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.30", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -713,10 +752,38 @@ dependencies = [ ] [[package]] -name = "unicode-ident" -version = "1.0.6" +name = "syn" +version = "2.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "0ddc1f908d32ec46858c2d3b3daa00cc35bf4b6841ce4355c7bb3eedf2283a68" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "unicode-ident" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "vcell" @@ -735,3 +802,12 @@ name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "winnow" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +dependencies = [ + "memchr", +] diff --git a/Cargo.toml b/Cargo.toml index 4b1c36b..47a115c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,14 +7,15 @@ authors = [ "Marvin Drescher " ] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -critical-section = "1.1.1" -embassy-executor = { package = "embassy-executor", git = "https://github.com/embassy-rs/embassy/", rev = "eed34f9", features = ["nightly", "integrated-timers"] } +embassy-executor = { version = "0.2.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } embassy-time = { version = "0.1.0", features = ["nightly"] } embedded-hal = "0.2.7" +esp-alloc = "0.3.0" esp-backtrace = { version = "0.4.0", features = ["esp32c3", "exception-handler", "panic-handler"] } -esp-hal-common = { version = "0.4.0", features = ["esp32c3"] } +esp-hal-common = { version = "0.11.0", features = ["esp32c3"] } +esp-hal-smartled = { version = "0.4.0", features = ["esp32c3"] } esp-println = { version = "0.3.1", features = ["esp32c3"] } -esp32c3-hal = { version = "0.4.0", features = ["embassy", "embassy-time", "embassy-time-timg0", "smartled", "embedded-hal-async", "async", "direct-boot"] } -riscv = "0.10.0" -riscv-rt = "0.10.0" +esp32c3-hal = { version = "0.11.0", features = ["embassy", "embassy-time", "embassy-time-systick", "embedded-hal-async", "async", "direct-boot"] } +smart-leds = "0.3.0" +smart-leds-trait = "0.2.1" static_cell = "1.0.0" diff --git a/flake.lock b/flake.lock index 1f45ea1..2edba5c 100644 --- a/flake.lock +++ b/flake.lock @@ -6,11 +6,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1685341338, - "narHash": "sha256-krAvPYZ8B1xF+90OaYcEyFw1W7L4bPskjcRFKA+NaQE=", + "lastModified": 1693722000, + "narHash": "sha256-NUBsuofTS09Qd+l/piz5vkvcU4/46smXKhh08/++nBk=", "owner": "nix-community", "repo": "fenix", - "rev": "9a32630ddfa5bf4e31c94b360cb29cdcd15960e6", + "rev": "300aaff54ea9338e07294dc55655501a52e0691d", "type": "github" }, "original": { @@ -24,11 +24,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { @@ -42,11 +42,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1679567394, - "narHash": "sha256-ZvLuzPeARDLiQUt6zSZFGOs+HZmE+3g4QURc8mkBsfM=", + "lastModified": 1692351612, + "narHash": "sha256-KTGonidcdaLadRnv9KFgwSMh1ZbXoR/OBmPjeNMhFwU=", "owner": "nix-community", "repo": "naersk", - "rev": "88cd22380154a2c36799fe8098888f0f59861a15", + "rev": "78789c30d64dea2396c9da516bbcc8db3a475207", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1685168767, - "narHash": "sha256-wQgnxz0PdqbyKKpsWl/RU8T8QhJQcHfeC6lh1xRUTfk=", + "lastModified": 1693565476, + "narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e10802309bf9ae351eb27002c85cfdeb1be3b262", + "rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b", "type": "github" }, "original": { @@ -73,11 +73,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1684570954, - "narHash": "sha256-FX5y4Sm87RWwfu9PI71XFvuRpZLowh00FQpIJ1WfXqE=", + "lastModified": 1693565476, + "narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3005f20ce0aaa58169cdee57c8aa12e5f1b6e1b3", + "rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b", "type": "github" }, "original": { @@ -87,11 +87,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1685347552, - "narHash": "sha256-9woSppRyUFo26yUffORTzttJ+apOt8MmCv6RxpPNTU4=", + "lastModified": 1693654884, + "narHash": "sha256-EqKKEl+IOS8TSjkt+xn1qGpsjnx5/ag33YNQ1+c7OuM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f2f1ec390714d303cf84ba086e34e45b450dd8c4", + "rev": "e7f35e03abd06a2faef6684d0de813370e13bda8", "type": "github" }, "original": { @@ -112,11 +112,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1685280411, - "narHash": "sha256-8fOFw6B9lDUt4slKAGHj6Bipi5or7nNQvOB9vvN2R9U=", + "lastModified": 1693668487, + "narHash": "sha256-8mBK0p4p4FVcRY8MFN0SBxzKoGKr+qMV/h3swoEk9II=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "505fd09f9e020b096d014e68b667268e743c2dd6", + "rev": "99686d56a803cac7f6b30e02268b527492555961", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 9fda7e0..cebec0e 100644 --- a/flake.nix +++ b/flake.nix @@ -43,7 +43,7 @@ # CARGO_UNSTABLE_BUILD_STD = "true"; "CARGO_TARGET_${pkgs.lib.toUpper CARGO_BUILD_TARGET}_LINKER" = "riscv32-none-elf-gcc"; "CARGO_TARGET_${pkgs.lib.toUpper CARGO_BUILD_TARGET}_RUNNER" = "espflash --monitor"; - CARGO_BUILD_TARGET = "riscv32imc-unknown-none-elf"; + CARGO_BUILD_TARGET = "riscv32imac-unknown-none-elf"; shellHook = '' ''; diff --git a/src/main.rs b/src/main.rs index 3fb5ff8..fa7d9f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,66 +1,91 @@ +//! embassy hello world +//! +//! This is an example of running the embassy executor with multiple tasks +//! concurrently. + #![no_std] #![no_main] #![feature(type_alias_impl_trait)] - +#![feature(trait_alias)] +extern crate alloc; +use alloc::boxed::Box; use embassy_executor::Executor; use embassy_time::{Duration, Timer}; -use esp32c3_hal::{clock::ClockControl, prelude::*, timer::TimerGroup, Rtc, embassy}; +use esp32c3_hal::{ + clock::ClockControl, embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, IO, +}; +use esp_alloc::EspHeap; use esp_backtrace as _; -use esp_hal_common::{Bank0GpioRegisterAccess, GpioPin, InputOutputAnalogPinType, Unknown, IO, pac::Peripherals}; +use esp_hal_common::Rmt; +use esp_hal_common::{dma::TxChannel, gdma::Channel0}; +use esp_hal_smartled::smartLedAdapter; +use esp_hal_smartled::*; +use smart_leds::SmartLedsWrite; +use smart_leds_trait::{RGB, RGBW, RGB8, White, RGBA}; use static_cell::StaticCell; -#[embassy_executor::task] -async fn run1() { - loop { - esp_println::println!("Hello world from embassy using esp-hal-async!"); - Timer::after(Duration::from_millis(1_000)).await; - esp_println::println!("Just woke up"); +#[global_allocator] +static ALLOCATOR: EspHeap = EspHeap::empty(); + +trait MySmartLed { + fn set_color(&mut self, color: RGB8); +} + +impl, const CH: u8, const BUFFER_SIZE: usize> MySmartLed + for SmartLedsAdapter +{ + fn set_color(&mut self, color: RGB8) { + if let Err(err) = self.write([color].into_iter()) { + esp_println::println!("{err:?}"); + } } } #[embassy_executor::task] -async fn run2() { +async fn blink(mut led: Box) { loop { esp_println::println!("Bing!"); - Timer::after(Duration::from_millis(5_000)).await; - } -} - -#[embassy_executor::task] -async fn run_io(io: IO) { - let led = io.pins.gpio1; - blink_led(led).await; -} - -async fn blink_led( - pin: GpioPin, -) { - let mut led = pin.into_push_pull_output(); - let mut on = true; - loop { - if on { - esp_println::println!("On!"); - } else { - esp_println::println!("Off!"); + for r in 0u8..255 { + Timer::after(Duration::from_millis(500)).await; + esp_println::println!("Bing! {r}"); + let color = RGB8::new(r, r, r); + led.set_color(color); } - Timer::after(Duration::from_millis(5_00)).await; - on = !on; } } static EXECUTOR: StaticCell = StaticCell::new(); - -#[riscv_rt::entry] +#[entry] fn main() -> ! { esp_println::println!("Init!"); - let peripherals = Peripherals::take().unwrap(); - let system = peripherals.SYSTEM.split(); + const HEAP_SIZE: usize = 2 * 1024; + + extern "C" { + static _sheap: u8; + static _heap_size: u8; + } + unsafe { + let heap_bottom = &_sheap as *const u8 as usize; + let heap_size = &_heap_size as *const u8 as usize; + ALLOCATOR.init(heap_bottom as *mut u8, 1024); + } + + let peripherals = Peripherals::take(); + let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks); + let timer_group0 = TimerGroup::new( + peripherals.TIMG0, + &clocks, + &mut system.peripheral_clock_control, + ); let mut wdt0 = timer_group0.wdt; - let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks); + let timer_group1 = TimerGroup::new( + peripherals.TIMG1, + &clocks, + &mut system.peripheral_clock_control, + ); let mut wdt1 = timer_group1.wdt; // Disable watchdog timers @@ -69,20 +94,28 @@ fn main() -> ! { wdt0.disable(); wdt1.disable(); - // embassy::init( - // &clocks, - // esp32c3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER), - // ); - - embassy::init(&clocks, timer_group0.timer0); + embassy::init( + &clocks, + esp32c3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER), + ); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let rmt = Rmt::new( + peripherals.RMT, + 80u32.MHz(), + &mut system.peripheral_clock_control, + &clocks, + ) + .unwrap(); + + let mut led = ::new(rmt.channel0, io.pins.gpio7); + + led.set_color(RGB8::new(0, 255, 255)); + + let led: Box = Box::new(led); let executor = EXECUTOR.init(Executor::new()); executor.run(move |spawner| { - spawner.spawn(run1()).ok(); - spawner.spawn(run2()).ok(); - let res = spawner.spawn(run_io(io)); - esp_println::println!("{res:?}"); - }); + spawner.spawn(blink(led)).ok(); + }) }