diff options
| author | Nathan Perry <np@nathanperry.dev> | 2024-09-22 09:14:21 -0400 |
|---|---|---|
| committer | Nathan Perry <np@nathanperry.dev> | 2024-09-22 09:14:31 -0400 |
| commit | 945052f34bb1f01f0ba0cb861350a885d8d82f43 (patch) | |
| tree | 1d818cd9dd13875df4043a8270331364e71f32fb | |
| parent | ff3606c0d2d3f510ee6bca040e77de92ca5be529 (diff) | |
theoretically working firmware
| -rw-r--r-- | Cargo.lock | 278 | ||||
| -rw-r--r-- | Cargo.toml | 49 | ||||
| -rw-r--r-- | src/bringup/mod.rs | 118 | ||||
| -rw-r--r-- | src/lib.rs | 14 | ||||
| -rw-r--r-- | src/main.rs | 102 | ||||
| -rw-r--r-- | src/usb.rs | 2 |
6 files changed, 464 insertions, 99 deletions
@@ -152,10 +152,16 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" dependencies = [ - "rustc_version", + "rustc_version 0.2.3", ] [[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] name = "basic-toml" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -249,6 +255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "num-traits", + "serde", ] [[package]] @@ -268,6 +275,12 @@ dependencies = [ ] [[package]] +name = "const-default" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa" + +[[package]] name = "cortex-m" version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -275,7 +288,6 @@ checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ "bare-metal", "bitfield 0.13.2", - "critical-section", "embedded-hal 0.2.7", "volatile-register", ] @@ -493,11 +505,11 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "embassy-embedded-hal" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "defmt", - "embassy-futures 0.1.1 (git+https://github.com/embassy-rs/embassy)", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-futures 0.1.1 (git+https://github.com/mammothbane/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-time", "embedded-hal 0.2.7", "embedded-hal 1.0.0", @@ -510,7 +522,7 @@ dependencies = [ [[package]] name = "embassy-executor" version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "cortex-m", "critical-section", @@ -524,7 +536,7 @@ dependencies = [ [[package]] name = "embassy-executor-macros" version = "0.5.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "darling 0.20.10", "proc-macro2", @@ -541,7 +553,7 @@ checksum = "1f878075b9794c1e4ac788c95b728f26aa6366d32eeb10c7051389f898f7d067" [[package]] name = "embassy-futures" version = "0.1.1" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "defmt", ] @@ -549,7 +561,7 @@ dependencies = [ [[package]] name = "embassy-hal-internal" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "cortex-m", "critical-section", @@ -560,16 +572,16 @@ dependencies = [ [[package]] name = "embassy-net" version = "0.4.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "defmt", "document-features", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-time", "embedded-io-async", "embedded-nal-async", - "heapless", + "heapless 0.8.0", "managed", "smoltcp", ] @@ -577,7 +589,7 @@ dependencies = [ [[package]] name = "embassy-net-driver" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "defmt", ] @@ -585,17 +597,17 @@ dependencies = [ [[package]] name = "embassy-net-driver-channel" version = "0.3.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ - "embassy-futures 0.1.1 (git+https://github.com/embassy-rs/embassy)", + "embassy-futures 0.1.1 (git+https://github.com/mammothbane/embassy)", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", ] [[package]] name = "embassy-nrf" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -606,7 +618,7 @@ dependencies = [ "document-features", "embassy-embedded-hal", "embassy-hal-internal", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-usb-driver", "embedded-hal 0.2.7", "embedded-hal 1.0.0", @@ -634,7 +646,7 @@ dependencies = [ [[package]] name = "embassy-rp" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "atomic-polyfill", "cfg-if", @@ -645,9 +657,9 @@ dependencies = [ "defmt", "document-features", "embassy-embedded-hal", - "embassy-futures 0.1.1 (git+https://github.com/embassy-rs/embassy)", + "embassy-futures 0.1.1 (git+https://github.com/mammothbane/embassy)", "embassy-hal-internal", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-time", "embassy-time-driver", "embassy-usb-driver", @@ -672,7 +684,7 @@ dependencies = [ [[package]] name = "embassy-stm32" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "aligned", "bit_field", @@ -686,10 +698,10 @@ dependencies = [ "defmt", "document-features", "embassy-embedded-hal", - "embassy-futures 0.1.1 (git+https://github.com/embassy-rs/embassy)", + "embassy-futures 0.1.1 (git+https://github.com/mammothbane/embassy)", "embassy-hal-internal", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-time", "embassy-usb-driver", "embassy-usb-synopsys-otg", @@ -725,26 +737,27 @@ dependencies = [ "critical-section", "embedded-io-async", "futures-util", - "heapless", + "heapless 0.8.0", ] [[package]] name = "embassy-sync" version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy#3d6a270f30c45eaf394c8eb8bf182dd1a7ec2d7b" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "cfg-if", "critical-section", "defmt", "embedded-io-async", + "futures-sink", "futures-util", - "heapless", + "heapless 0.8.0", ] [[package]] name = "embassy-time" version = "0.3.2" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "cfg-if", "critical-section", @@ -756,13 +769,13 @@ dependencies = [ "embedded-hal 1.0.0", "embedded-hal-async", "futures-util", - "heapless", + "heapless 0.8.0", ] [[package]] name = "embassy-time-driver" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "document-features", ] @@ -770,19 +783,19 @@ dependencies = [ [[package]] name = "embassy-time-queue-driver" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" [[package]] name = "embassy-usb" version = "0.3.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "defmt", - "embassy-futures 0.1.1 (git+https://github.com/embassy-rs/embassy)", + "embassy-futures 0.1.1 (git+https://github.com/mammothbane/embassy)", "embassy-net-driver-channel", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-usb-driver", - "heapless", + "heapless 0.8.0", "ssmarshal", "usbd-hid", ] @@ -790,7 +803,7 @@ dependencies = [ [[package]] name = "embassy-usb-driver" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "defmt", ] @@ -798,21 +811,23 @@ dependencies = [ [[package]] name = "embassy-usb-synopsys-otg" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#32cff6530fdb81066451cc1d3f1fbbb420e985da" +source = "git+https://github.com/mammothbane/embassy#89bad07e817dec482d385f765da5be3b6d2d0e4c" dependencies = [ "critical-section", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-usb-driver", ] [[package]] name = "embedded-alloc" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddae17915accbac2cfbc64ea0ae6e3b330e6ea124ba108dada63646fd3c6f815" +checksum = "8f2de9133f68db0d4627ad69db767726c99ff8585272716708227008d3f1bddd" dependencies = [ + "const-default", "critical-section", "linked_list_allocator", + "rlsf", ] [[package]] @@ -947,11 +962,11 @@ source = "git+https://pub.npry.dev/embedded_sdmmc_async#0c5910fd0eac1fc7b0beb0bd dependencies = [ "byteorder", "cfg-if", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "defmt", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embedded-hal-async", "embedded-io-async", - "heapless", - "log", + "heapless 0.8.0", ] [[package]] @@ -976,16 +991,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "esp-alloc" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44c0b0c0416865313f3fcb6c00f7bc8ecebef30459bec74dc272eb12e465e3f" -dependencies = [ - "critical-section", - "linked_list_allocator", -] - -[[package]] name = "eyre" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1005,6 +1010,7 @@ dependencies = [ "bytemuck", "half", "num-traits", + "serde", "typenum", ] @@ -1095,7 +1101,7 @@ dependencies = [ [[package]] name = "genlog" -version = "0.1.0" +version = "0.1.0-alpha0" dependencies = [ "cfg-if", "defmt", @@ -1124,6 +1130,15 @@ dependencies = [ [[package]] name = "hash32" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hash32" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" @@ -1148,12 +1163,27 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heapless" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" +dependencies = [ + "atomic-polyfill", + "hash32 0.2.1", + "rustc_version 0.4.1", + "serde", + "spin", + "stable_deref_trait", +] + +[[package]] +name = "heapless" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" dependencies = [ "defmt", - "hash32", + "hash32 0.3.1", + "serde", "stable_deref_trait", ] @@ -1372,25 +1402,40 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "molybdos" -version = "0.1.0" +version = "0.1.0-alpha0" +dependencies = [ + "defmt-rtt", + "embassy-executor", + "molybdos_lib", + "molybdos_pal", + "molybdos_rt", + "panic-probe", +] + +[[package]] +name = "molybdos_build" +version = "0.1.0-alpha0" +source = "git+https://pub.npry.dev/molybdos#e675a6c83fe0af5dd0f9c9f0e944437e8c7ba43f" +dependencies = [ + "anyhow", + "askama", + "eyre", +] + +[[package]] +name = "molybdos_lib" +version = "0.1.0-alpha0" dependencies = [ "anyhow", "cfg-if", "chrono", - "cortex-m", - "cortex-m-rt", - "defmt-rtt", "embassy-embedded-hal", "embassy-executor", - "embassy-futures 0.1.1 (git+https://github.com/embassy-rs/embassy)", + "embassy-futures 0.1.1 (git+https://github.com/mammothbane/embassy)", "embassy-net", - "embassy-nrf", - "embassy-rp", - "embassy-stm32", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync 0.6.0 (git+https://github.com/mammothbane/embassy)", "embassy-time", "embassy-usb", - "embedded-alloc", "embedded-hal 1.0.0", "embedded-hal-async", "embedded-hal-bus", @@ -1398,35 +1443,54 @@ dependencies = [ "embedded-io-async", "embedded-storage", "embedded-storage-async", - "esp-alloc", + "embedded_sdmmc_async", "fixed", "futures", "genlog", - "heapless", + "heapless 0.8.0", "hex", "lazy_static 1.5.0 (git+https://github.com/rust-lang-nursery/lazy-static.rs?branch=master)", "nalgebra", - "nrf-softdevice", "num-traits", - "panic-probe", - "pio", - "pio-proc", "portable-atomic", "postcard", "rand", "rand_core", + "serde", "spin", + "ssmarshal", "static_cell", "tap", ] [[package]] -name = "molybdos_build" -version = "0.1.0" +name = "molybdos_pal" +version = "0.1.0-alpha0" dependencies = [ - "anyhow", - "askama", - "eyre", + "cfg-if", + "cortex-m", + "cortex-m-rt", + "embassy-executor", + "embassy-nrf", + "embassy-rp", + "embassy-stm32", + "embedded-alloc", + "molybdos_lib", + "nrf-softdevice", + "pio", + "pio-proc", +] + +[[package]] +name = "molybdos_rt" +version = "0.1.0-alpha0" +dependencies = [ + "cfg-if", + "embassy-executor", + "genlog", + "molybdos_lib", + "molybdos_pal", + "static_cell", ] [[package]] @@ -1439,6 +1503,7 @@ dependencies = [ "num-complex 0.4.6", "num-rational 0.4.2", "num-traits", + "serde", "simba", "typenum", ] @@ -1495,7 +1560,7 @@ dependencies = [ "embedded-storage-async", "fixed", "futures", - "heapless", + "heapless 0.8.0", "nrf-softdevice-macro", "num_enum 0.7.3", ] @@ -1674,6 +1739,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", + "serde", ] [[package]] @@ -1781,12 +1847,13 @@ dependencies = [ name = "ocularium" version = "0.1.0-alpha0" dependencies = [ + "cortex-m-rt", "drogue_bme680_async", "embassy-executor", - "embedded_sdmmc_async", "lsm6dsm", "molybdos", "molybdos_build", + "serde", "veml7700_async", ] @@ -1803,7 +1870,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4047d9235d1423d66cc97da7d07eddb54d4f154d6c13805c6d0793956f4f25b0" dependencies = [ "cortex-m", - "defmt", ] [[package]] @@ -1919,6 +1985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" dependencies = [ "critical-section", + "serde", ] [[package]] @@ -1931,6 +1998,7 @@ dependencies = [ "defmt", "embedded-io 0.4.0", "embedded-io 0.6.1", + "heapless 0.7.17", "serde", ] @@ -2053,6 +2121,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] +name = "rlsf" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222fb240c3286247ecdee6fa5341e7cdad0ffdf8e7e401d9937f2d58482a20bf" +dependencies = [ + "cfg-if", + "const-default", + "libc", + "svgbobdoc", +] + +[[package]] name = "rp-pac" version = "6.0.0" source = "git+https://github.com/embassy-rs/rp-pac.git?rev=a7f42d25517f7124ad3b4ed492dec8b0f50a0e6c#a7f42d25517f7124ad3b4ed492dec8b0f50a0e6c" @@ -2076,7 +2156,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver", + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver 1.0.23", ] [[package]] @@ -2107,6 +2196,12 @@ dependencies = [ ] [[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2165,14 +2260,13 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smoltcp" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a1a996951e50b5971a2c8c0fa05a381480d70a933064245c4a223ddc87ccc97" +source = "git+https://github.com/smoltcp-rs/smoltcp?rev=dd43c8f189178b0ab3bda798ed8578b5b0a6f094#dd43c8f189178b0ab3bda798ed8578b5b0a6f094" dependencies = [ "bitflags 1.3.2", "byteorder", "cfg-if", "defmt", - "heapless", + "heapless 0.8.0", "managed", ] @@ -2182,6 +2276,7 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ + "lock_api", "portable-atomic", ] @@ -2228,7 +2323,7 @@ dependencies = [ [[package]] name = "stm32-metapac" version = "15.0.0" -source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-5ef354f3e49f790e47f5c818f243459742c9b83b#d94c7ea2bd05428ba9fd2b5a39edb8ed99f65daa" +source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-ad00827345b4b758b2453082809d6e3b634b5364#e442835159a7a311410cd4a2879da52c6f57af52" dependencies = [ "cortex-m", "cortex-m-rt", @@ -2260,6 +2355,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] +name = "svgbobdoc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c04b93fc15d79b39c63218f15e3fdffaa4c227830686e3b7c5f41244eb3e50" +dependencies = [ + "base64", + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-width", +] + +[[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2375,7 +2483,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6" dependencies = [ - "heapless", + "heapless 0.8.0", "portable-atomic", ] @@ -11,21 +11,60 @@ homepage = "https://blog.npry.dev/resenv/ocularium" repository = "https://pub.npry.dev/ocularium" include = ["build.rs", "/src/", "Cargo.toml", "README.md", "LICENSE"] +[features] +disable_sd = [] + [dependencies] -molybdos = { git = "https://pub.npry.dev/molybdos", features = ["rp", "defmt", "rtt"] } veml7700_async = { git = "https://pub.npry.dev/veml7700_async" } drogue_bme680_async = { git = "https://pub.npry.dev/drogue_bme680_async" } lsm6dsm = { git = "https://pub.npry.dev/lsm6dsm" } -embedded_sdmmc_async = { git = "https://pub.npry.dev/embedded_sdmmc_async" } -embassy-executor.git = "https://github.com/embassy-rs/embassy" +embassy-executor = { git = "https://github.com/embassy-rs/embassy", features = ["executor-interrupt", "executor-thread", "arch-cortex-m", "nightly"] } +serde = { version = "1.0", default-features = false } +cortex-m-rt = { version = "0.7", default-features = false } + +[dependencies.molybdos] +git = "https://pub.npry.dev/molybdos" +features = [ + "rp", + "defmt", + "rtt", + "sd", + "runtime", + "postcard", + "serde", + "chrono", + "impl_alloc", +] [build-dependencies] -molybdos_build.git = "https://pub.npry.dev/molybdos" +molybdos_build = { git = "https://pub.npry.dev/molybdos" } [patch] "https://pub.npry.dev/molybdos".molybdos = { path = "../molybdos" } -"https://pub.npry.dev/molybdos".molybdos_build = { path = "../molybdos/molybdos_build" } "https://pub.npry.dev/veml7700_async".veml7700_async = { path = "../../fork/veml7700" } "https://pub.npry.dev/drogue_bme680_async".drogue_bme680_async = { path = "../../fork/drogue_bme680_async" } "https://pub.npry.dev/lsm6dsm".lsm6dsm = { path = "../lsm6dsm" } + +[patch."https://github.com/embassy-rs/embassy"] +embassy-sync = { git = "https://github.com/mammothbane/embassy" } +embassy-executor = { git = "https://github.com/mammothbane/embassy" } +embassy-time = { git = "https://github.com/mammothbane/embassy" } +embassy-time-driver = { git = "https://github.com/mammothbane/embassy" } +embassy-usb = { git = "https://github.com/mammothbane/embassy" } + +[profile.dev] +codegen-units = 1 +debug = true +debug-assertions = true +incremental = false +opt-level = 'z' +overflow-checks = true + +[profile.release] +codegen-units = 1 +debug = 2 +debug-assertions = false +lto = 'fat' +opt-level = 3 +overflow-checks = false diff --git a/src/bringup/mod.rs b/src/bringup/mod.rs new file mode 100644 index 0000000..71c2d4b --- /dev/null +++ b/src/bringup/mod.rs @@ -0,0 +1,118 @@ +use molybdos::reexport::*; + +use embassy_rp::{ + adc, + adc::Adc, + gpio::{ + Level, + Output, + Pin, + }, + peripherals::{ + SPI0, + SPI1, + USB, + }, + spi, + spi::{ + Async, + Spi, + }, + watchdog::Watchdog, +}; +use embassy_sync::{ + blocking_mutex::raw::{ + CriticalSectionRawMutex, + RawMutex, + }, + mutex::Mutex, +}; +use static_cell::StaticCell; +use tap::Pipe; + +use molybdos::pal::StaticOutput; + +embassy_rp::bind_interrupts! { + struct Irqs { + USBCTRL_IRQ => embassy_rp::usb::InterruptHandler<USB>; + ADC_IRQ_FIFO => adc::InterruptHandler; + } +} + +static BME_SPI: StaticCell<Mutex<CriticalSectionRawMutex, Spi<SPI1, Async>>> = StaticCell::new(); +static SD_SPI: StaticCell<Mutex<CriticalSectionRawMutex, Spi<SPI0, Async>>> = StaticCell::new(); +static ADC: StaticCell<Mutex<CriticalSectionRawMutex, Adc<adc::Async>>> = StaticCell::new(); + +pub struct Split<BmeSpi, BmeSpiMutex, SdSpi, SdSpiMutex> +where + SdSpiMutex: RawMutex + 'static, + SdSpi: 'static, + BmeSpiMutex: RawMutex + 'static, + BmeSpi: 'static, +{ + pub sd_spi: &'static Mutex<SdSpiMutex, SdSpi>, + pub sd_cs: StaticOutput, + pub bme_spi: &'static Mutex<BmeSpiMutex, BmeSpi>, + pub bme_cs: StaticOutput, + pub wdt: Watchdog, + pub usb: molybdos::pal::UsbDriver, + + pub adc: &'static Mutex<CriticalSectionRawMutex, Adc<'static, adc::Async>>, + // pub leds: [StaticOutput; crate::N_LED], +} + +pub fn split( + config: embassy_rp::config::Config, +) -> Split<crate::BMESpi, CriticalSectionRawMutex, crate::SdSpi, CriticalSectionRawMutex> { + let periphs = embassy_rp::init(config); + + let wdt = Watchdog::new(periphs.WATCHDOG); + + let bme_cs = periphs.PIN_5.degrade().pipe(|cs| Output::new(cs, Level::High)); + let bme_spi = { + let sck = periphs.PIN_10; + let mosi = periphs.PIN_11; + let miso = periphs.PIN_8; + + let mut conf = spi::Config::default(); + conf.frequency = 1_000_000; + + let bme_spi = + Spi::new(periphs.SPI1, sck, mosi, miso, periphs.DMA_CH0, periphs.DMA_CH1, conf) + .pipe(Mutex::<CriticalSectionRawMutex, _>::new); + BME_SPI.init(bme_spi) + }; + + let sd_cs = periphs.PIN_9.degrade().pipe(|cs| Output::new(cs, Level::High)); + let sd_spi = { + let mosi = periphs.PIN_19; + let sck = periphs.PIN_18; + let miso = periphs.PIN_20; + + let mut conf = spi::Config::default(); + conf.frequency = 16_000_000; + + let sd_spi = + Spi::new(periphs.SPI0, sck, mosi, miso, periphs.DMA_CH3, periphs.DMA_CH4, conf) + .pipe(Mutex::new); + + SD_SPI.init(sd_spi) + }; + + let usb_driver = embassy_rp::usb::Driver::new(periphs.USB, Irqs); + + let adc = Adc::new(periphs.ADC, Irqs, adc::Config::default()); + + let adc = ADC.init(Mutex::new(adc)); + + Split { + sd_spi, + sd_cs, + bme_spi, + bme_cs, + wdt, + usb: usb_driver, + + adc, + } +} @@ -1 +1,15 @@ #![no_std] + +#[derive( + Debug, Clone, PartialEq, PartialOrd, molybdos::serde::Serialize, molybdos::serde::Deserialize, +)] +pub enum Uplink { + Ping, +} + +#[derive( + Debug, Clone, PartialEq, PartialOrd, molybdos::serde::Serialize, molybdos::serde::Deserialize, +)] +pub enum Downlink { + Pong, +} diff --git a/src/main.rs b/src/main.rs index ead8e00..3811101 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,16 +2,100 @@ #![no_main] #![feature(impl_trait_in_assoc_type)] -use molybdos::genlog::defmt; -use molybdos::reexports::*; +use molybdos::{ + embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice, + embassy_rp::{ + i2c::{ + self, + I2c, + }, + peripherals::{ + I2C0, + SPI0, + SPI1, + }, + spi::{ + self, + Spi, + }, + }, + embassy_sync::{ + blocking_mutex::raw::CriticalSectionRawMutex, + pubsub, + }, + embedded_sdmmc_async::{ + VolumeIdx, + VolumeManager, + }, + genlog, + genlog::defmt, + pal::StaticOutput, +}; -#[defmt::panic_handler] -fn panic() -> ! { - panic_probe::hard_fault(); -} +mod bringup; +mod usb; + +pub type BMESpi = Spi<'static, SPI1, spi::Async>; +pub type BMESpiDev = SpiDevice<'static, CriticalSectionRawMutex, BMESpi, StaticOutput>; +pub type SdSpi = Spi<'static, SPI0, spi::Async>; +pub type SdSpiDev = SpiDevice<'static, CriticalSectionRawMutex, SdSpi, StaticOutput>; + +pub type SensorI2c = I2c<'static, I2C0, i2c::Async>; #[embassy_executor::main] -async fn main(_spawner: embassy_executor::Spawner) { - genlog::info!("hello"); - molybdos::heap::init(); +async fn main(spawner: embassy_executor::Spawner) { + molybdos::pal::heap::init(); + + genlog::info!("boot"); + + let bringup::Split { + sd_spi, + sd_cs, + bme_spi, + bme_cs, + wdt, + usb, + .. + } = bringup::split(Default::default()); + + // spawner.must_spawn(molybdos::pal::watchdog(wdt)); + + let (acm,) = molybdos::lib::usb::bringup!( + spawn, + usb, + molybdos::pal::UsbDriver, + molybdos::lib::usb::config("npry", "ocularium", 0x8888, 0x0011), + endpoints = { + acm => |builder| molybdos::lib::usb::acm!(builder), + } + ); + + molybdos::lib::usb::start!(molybdos::pal::UsbDriver, acm, &usb::UPLINK, &usb::DOWNLINK); + + molybdos::lib::util::cobs::start!( + ocularium::Uplink, + &usb::UPLINK, + &usb::COBS_UPLINK, + ocularium::Downlink, + &usb::DOWNLINK, + &usb::COBS_DOWNLINK + ); + + #[cfg(not(feature = "disable_sd"))] + { + let vm = molybdos::rt::sd::bringup!(sd_spi, SdSpi, sd_cs); + + { + let vol = VolumeManager::open_volume(vm, VolumeIdx(0)).await.expect("opening volume"); + } + + // spawner.must_spawn(sd::run_sd(vm, pubsub::LED.sender().into())); + } + + panic!() +} + +#[defmt::panic_handler] +fn panic() -> ! { + molybdos::panic_probe::hard_fault(); } diff --git a/src/usb.rs b/src/usb.rs new file mode 100644 index 0000000..7ec1aae --- /dev/null +++ b/src/usb.rs @@ -0,0 +1,2 @@ +molybdos::lib::usb_pipes!(pub); +molybdos::lib::cobs_pubsub!(pub, ocularium::Uplink => COBS_UPLINK, ocularium::Downlink => COBS_DOWNLINK); |
