From 81f993a75240a4874af105b2baf5dd24f88adcf0 Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 1 Jan 2025 14:46:31 +1300 Subject: [PATCH 1/6] wip --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- resources/pinmap.md | 15 +++++++++++++++ src/bin/rx.rs | 12 ++++++------ src/bin/tx.rs | 28 ++++++++++++++-------------- src/lora.rs | 13 +++++++++---- src/spi.rs | 2 +- 7 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 resources/pinmap.md diff --git a/Cargo.lock b/Cargo.lock index 702266f..5df7657 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -846,9 +846,9 @@ checksum = "fe94d1a6dac71b9d54e7a76eb093fdb8e622601c3515f15e8cdca197d663b41c" [[package]] name = "lora-phy" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "592e30f03dd6ce6fc756fbe409cf705de3ecac60c669e2f0fe43de135f178812" +checksum = "61471c3b2909789e3332083577f6cf6c41a4fcf37674ef15156bcbb20504ac65" dependencies = [ "defmt", "embedded-hal 1.0.0", diff --git a/Cargo.toml b/Cargo.toml index 3574a1e..f457b1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ defmt = "0.3.6" nmea0183 = "0.4.0" micromath = "2.1.0" -lora-phy = "3.0.0" +lora-phy = "3.0.1" fugit = "0.3.7" diff --git a/resources/pinmap.md b/resources/pinmap.md new file mode 100644 index 0000000..1d2a989 --- /dev/null +++ b/resources/pinmap.md @@ -0,0 +1,15 @@ +# rx v0.0.1 +LORA NSS -> Pin 1 +LORA MOSI -> Pin 2 +LORA MISO -> Pin 3 +LORA CLK -> Pin 4 +LORA RST -> Pin 6 +LORA IRQ -> Pin 5 + +# tx/rx breadboard +LORA NSS -> Pin 7 +LORA MOSI -> Pin 10 +LORA MISO -> Pin 20 +LORA CLK -> Pin 21 +LORA RST -> Pin 5 +LORA IRQ -> Pin 6 \ No newline at end of file diff --git a/src/bin/rx.rs b/src/bin/rx.rs index df505b5..ee9a550 100644 --- a/src/bin/rx.rs +++ b/src/bin/rx.rs @@ -44,9 +44,9 @@ async fn main(_spawner: Spawner) -> () { info!("Initializing compete"); // Set SPI bus - let spi_clock = AnyPin::new(io.pins.gpio4); - let spi_miso = AnyPin::new(io.pins.gpio3); - let spi_mosi = AnyPin::new(io.pins.gpio2); + let spi_clock = AnyPin::new(io.pins.gpio21); + let spi_miso = AnyPin::new(io.pins.gpio20); + let spi_mosi = AnyPin::new(io.pins.gpio10); let spi_bus = spi::init( peripherals.DMA, @@ -57,11 +57,11 @@ async fn main(_spawner: Spawner) -> () { spi_miso, ); - let lora_spi_csb = AnyOutput::new(io.pins.gpio1, Level::High); + let lora_spi_csb = AnyOutput::new(io.pins.gpio7, Level::High); let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); - let lora_rst = AnyOutput::new(io.pins.gpio6, Level::High); - let lora_irq = AnyInput::new(io.pins.gpio5, Pull::Up); + let lora_rst = AnyOutput::new(io.pins.gpio5, Level::High); + let lora_irq = AnyInput::new(io.pins.gpio6, Pull::Up); _spawner .spawn(lora::receive(lora_spi, lora_irq.into(), lora_rst.into())) diff --git a/src/bin/tx.rs b/src/bin/tx.rs index 14e7f95..51494f4 100644 --- a/src/bin/tx.rs +++ b/src/bin/tx.rs @@ -45,20 +45,20 @@ async fn main(_spawner: Spawner) -> () { info!("Initializing compete"); // Setup UART for GPS - let uart_pins = Some(TxRxPins::new_tx_rx(io.pins.gpio21, io.pins.gpio20)); - let uart_config = Config::default().baudrate(9200); - let uart = Uart::new_async_with_config(peripherals.UART0, uart_config, uart_pins, &clocks); + // let uart_pins = Some(TxRxPins::new_tx_rx(io.pins.gpio21, io.pins.gpio20)); + // let uart_config = Config::default().baudrate(9200); + // let uart = Uart::new_async_with_config(peripherals.UART0, uart_config, uart_pins, &clocks); - let (_, rx) = uart.split(); + // let (_, rx) = uart.split(); // Note that this task now owns the UART RX line completely // UART is a 1:1 interface, so this is fine - _spawner.spawn(gps::sample_uart(rx)).unwrap(); + // _spawner.spawn(gps::sample_uart(rx)).unwrap(); // Setup SPI bus - let spi_clock = AnyPin::new(io.pins.gpio0); - let spi_miso = AnyPin::new(io.pins.gpio1); - let spi_mosi = AnyPin::new(io.pins.gpio2); + let spi_clock = AnyPin::new(io.pins.gpio21); + let spi_miso = AnyPin::new(io.pins.gpio20); + let spi_mosi = AnyPin::new(io.pins.gpio10); let spi_bus = spi::init( peripherals.DMA, @@ -69,16 +69,16 @@ async fn main(_spawner: Spawner) -> () { spi_miso, ); - let lora_spi_csb = AnyOutput::new(io.pins.gpio3, Level::Low); - let lora_spi_device = SpiDevice::new(spi_bus, lora_spi_csb); + let lora_spi_csb = AnyOutput::new(io.pins.gpio7, Level::High); + let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); - let lora_rst = AnyOutput::new(io.pins.gpio9, Level::High); - let lora_irq = AnyInput::new(io.pins.gpio10, Pull::Up); + let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio5, Level::High); + let lora_irq = AnyInput::new(io.pins.gpio6, Pull::Up); _spawner - .spawn(lora::transmit(lora_spi_device, lora_irq, lora_rst)) + .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) .ok(); // Finally set up the task to print state - _spawner.spawn(print_state()).ok(); + // _spawner.spawn(print_state()).ok(); } diff --git a/src/lora.rs b/src/lora.rs index 1c633ae..c3427ff 100644 --- a/src/lora.rs +++ b/src/lora.rs @@ -173,7 +173,7 @@ pub async fn transmit( info!("Transmitting {:?} bytes over LoRA", output.len()); let prepare_tx_timeout_result = with_timeout( - Duration::from_nanos(30), + Duration::from_millis(100), lora.prepare_for_tx( &modulation_parameters, &mut tx_packet_parameters, @@ -183,7 +183,9 @@ pub async fn transmit( ); match prepare_tx_timeout_result.await { - Ok(Ok(_)) => {} + Ok(Ok(_)) => { + info!("Prepare TX succeeded") + } Ok(Err(_)) => { error!("Prepare TX failed"); continue; @@ -197,13 +199,16 @@ pub async fn transmit( let tx_timeout_result = with_timeout(Duration::from_secs(30), lora.tx()); match tx_timeout_result.await { - Ok(Ok(r)) => r, + Ok(Ok(r)) => { + info!("TX succeeded"); + r + }, Ok(Err(_)) => { error!("TX failed"); continue; } Err(_) => { - error!("TX timed out after 10 seconds"); + error!("TX timed out after 30 seconds"); continue; } }; diff --git a/src/spi.rs b/src/spi.rs index 27a8a77..74b9ee6 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -35,7 +35,7 @@ pub fn init( let dma_descriptors = DMA_DESCRIPTORS.init(dma_descriptors!(32000)); // Max bitrate of the SX1278 is 300kbps vs. 2.2mbps for the NEO-M8. We have to pick the lower of the two. - let spi = Spi::new(spi, 300.kHz(), SpiMode::Mode0, &clocks) + let spi = Spi::new(spi, 22.kHz(), SpiMode::Mode0, &clocks) .with_sck(sck) .with_mosi(mosi) .with_miso(miso) From f675b06ba6e75c912274602d810cff729341843c Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 1 Jan 2025 16:13:26 +1300 Subject: [PATCH 2/6] rx pins correct --- src/bin/rx.rs | 12 ++++++------ src/bin/tx.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bin/rx.rs b/src/bin/rx.rs index ee9a550..c170a8f 100644 --- a/src/bin/rx.rs +++ b/src/bin/rx.rs @@ -44,9 +44,9 @@ async fn main(_spawner: Spawner) -> () { info!("Initializing compete"); // Set SPI bus - let spi_clock = AnyPin::new(io.pins.gpio21); - let spi_miso = AnyPin::new(io.pins.gpio20); - let spi_mosi = AnyPin::new(io.pins.gpio10); + let spi_clock = AnyPin::new(io.pins.gpio4); + let spi_miso = AnyPin::new(io.pins.gpio3); + let spi_mosi = AnyPin::new(io.pins.gpio2); let spi_bus = spi::init( peripherals.DMA, @@ -57,11 +57,11 @@ async fn main(_spawner: Spawner) -> () { spi_miso, ); - let lora_spi_csb = AnyOutput::new(io.pins.gpio7, Level::High); + let lora_spi_csb = AnyOutput::new(io.pins.gpio1, Level::High); let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); - let lora_rst = AnyOutput::new(io.pins.gpio5, Level::High); - let lora_irq = AnyInput::new(io.pins.gpio6, Pull::Up); + let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio6, Level::High); + let lora_irq = AnyInput::new(io.pins.gpio5, Pull::Up); _spawner .spawn(lora::receive(lora_spi, lora_irq.into(), lora_rst.into())) diff --git a/src/bin/tx.rs b/src/bin/tx.rs index 51494f4..db0c414 100644 --- a/src/bin/tx.rs +++ b/src/bin/tx.rs @@ -56,9 +56,9 @@ async fn main(_spawner: Spawner) -> () { // _spawner.spawn(gps::sample_uart(rx)).unwrap(); // Setup SPI bus - let spi_clock = AnyPin::new(io.pins.gpio21); - let spi_miso = AnyPin::new(io.pins.gpio20); - let spi_mosi = AnyPin::new(io.pins.gpio10); + let spi_clock = AnyPin::new(io.pins.gpio20); + let spi_miso = AnyPin::new(io.pins.gpio21); + let spi_mosi = AnyPin::new(io.pins.gpio1); let spi_bus = spi::init( peripherals.DMA, @@ -69,11 +69,11 @@ async fn main(_spawner: Spawner) -> () { spi_miso, ); - let lora_spi_csb = AnyOutput::new(io.pins.gpio7, Level::High); + let lora_spi_csb = AnyOutput::new(io.pins.gpio0, Level::High); let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); - let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio5, Level::High); - let lora_irq = AnyInput::new(io.pins.gpio6, Pull::Up); + let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio10, Level::High); + let lora_irq = AnyInput::new(io.pins.gpio2, Pull::Up); _spawner .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) From d2d0153ac0eddbf0bdc42b01d542f7a134f00768 Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 1 Jan 2025 18:32:27 +1300 Subject: [PATCH 3/6] bruh - I think i updated something here? --- Cargo.lock | 464 +++++++++++++++++++++++--------------------- Cargo.toml | 6 +- resources/pinmap.md | 15 +- src/alt.rs | 66 +++---- src/bin/av.rs | 34 ++-- src/bin/rx.rs | 45 ++--- src/bin/tx.rs | 76 ++++---- src/gps.rs | 20 +- src/i2c.rs | 30 +-- src/imu.rs | 82 ++++---- src/lib.rs | 6 +- src/lora.rs | 22 +-- src/spi.rs | 50 +++-- 13 files changed, 461 insertions(+), 455 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5df7657..3a375f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,20 +2,11 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "atomic-polyfill" @@ -49,9 +40,9 @@ dependencies = [ [[package]] name = "bitfield" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c821a6e124197eb56d907ccc2188eab1038fb919c914f47976e64dd8dbc855d1" +checksum = "f798d2d157e547aa99aab0967df39edd0b70307312b6f8bd2848e6abe40896e0" [[package]] name = "bitflags" @@ -61,16 +52,16 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bno055" version = "0.4.0" source = "git+https://github.com/odrusso/bno055#ae0e25a1134273cb3320b88cec9ab1e7e270995a" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "byteorder", "embedded-hal 1.0.0", "embedded-hal-async", @@ -79,6 +70,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "bytemuck" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" + [[package]] name = "byteorder" version = "1.5.0" @@ -92,35 +89,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "cobs" -version = "0.2.3" +name = "chrono" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +dependencies = [ + "num-traits", +] [[package]] -name = "core-isa-parser" -version = "0.2.0" +name = "cobs" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ec98e54b735872e54b2335c2e5a5c7fa7d9c3bfd45500f75280f84089a0083" -dependencies = [ - "anyhow", - "enum-as-inner", - "regex", - "strum 0.24.1", - "strum_macros 0.24.3", -] +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "critical-section" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64009896348fc5af4222e9cf7d7d82a95a256c634ebcf61c53e4ea461422242" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -128,27 +121,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] @@ -171,7 +164,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] @@ -185,20 +178,20 @@ dependencies = [ [[package]] name = "delegate" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e018fccbeeb50ff26562ece792ed06659b9c2dae79ece77c4456bb10d9bf79b" +checksum = "bc2323e10c92e1cf4d86e11538512e6dc03ceb586842970b6332af3d4046a046" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] name = "document-features" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" dependencies = [ "litrs", ] @@ -220,11 +213,28 @@ dependencies = [ "nb 1.1.0", ] +[[package]] +name = "embassy-embedded-hal" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5794414bc20e0d750f145bc0e82366b19dd078e9e075e8331fb8dd069a1cb6a2" +dependencies = [ + "embassy-futures", + "embassy-sync 0.6.0", + "embassy-time", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-storage", + "embedded-storage-async", + "nb 1.1.0", +] + [[package]] name = "embassy-executor" -version = "0.5.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec648daedd2143466eff4b3e8002024f9f6c1de4ab7666bb679688752624c925" +checksum = "f64f84599b0f4296b92a4b6ac2109bc02340094bda47b9766c5f9ec6a318ebf8" dependencies = [ "critical-section", "defmt", @@ -236,14 +246,14 @@ dependencies = [ [[package]] name = "embassy-executor-macros" -version = "0.4.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad454accf80050e9cf7a51e994132ba0e56286b31f9317b68703897c328c59b5" +checksum = "3577b1e9446f61381179a330fc5324b01d511624c55f25e3c66c9e3c626dbecf" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] @@ -284,9 +294,9 @@ dependencies = [ [[package]] name = "embassy-time" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "274c019608a9004aed3cafc871e2a3c87ce9351d537dcaab4cc5db184d4a04b1" +checksum = "158080d48f824fad101d7b2fae2d83ac39e3f7a6fa01811034f7ab8ffc6e7309" dependencies = [ "cfg-if", "critical-section", @@ -316,23 +326,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1177859559ebf42cd24ae7ba8fe6ee707489b01d0bf471f8827b7b12dcb0bc0" -[[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-synopsys-otg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d46be92e72bcf39e623ff74d739a8ab29b02f4909a9b05986ca81c2157ac254a" -dependencies = [ - "critical-section", - "embassy-sync 0.5.0", - "embassy-usb-driver", -] - [[package]] name = "embedded-can" version = "0.4.1" @@ -342,15 +335,6 @@ dependencies = [ "nb 1.1.0", ] -[[package]] -name = "embedded-dma" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446" -dependencies = [ - "stable_deref_trait", -] - [[package]] name = "embedded-hal" version = "0.2.7" @@ -436,35 +420,35 @@ dependencies = [ [[package]] name = "enum-as-inner" -version = "0.4.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" dependencies = [ "heck", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.93", ] [[package]] name = "enumset" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" +checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" +checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] @@ -490,30 +474,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b94a4b8d74e7cc7baabcca5b2277b41877e039ad9cd49959d48ef94dac7eab4b" dependencies = [ "quote", - "syn 2.0.66", + "syn 2.0.93", "termcolor", ] +[[package]] +name = "esp-config" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7584e4cd1dac06201fd92fff1c84b396be5458ac4d93e9457e7a89b1b42c60e" +dependencies = [ + "document-features", +] + [[package]] name = "esp-hal" -version = "0.18.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f1bf3b1b34bbeb59e24e630f26e21b95f9c2bb7c0a53361ae5a97c67936566" +checksum = "1a5605e1518d63f7bf9fbd9885e61d2896060d2e4f28954736bdd74da911b676" dependencies = [ "basic-toml", "bitfield", - "bitflags 2.5.0", + "bitflags 2.6.0", + "bytemuck", "cfg-if", + "chrono", "critical-section", "defmt", "delegate", "document-features", + "embassy-embedded-hal 0.2.0", "embassy-futures", "embassy-sync 0.6.0", - "embassy-usb-driver", - "embassy-usb-synopsys-otg", "embedded-can", - "embedded-dma", + "embedded-hal 0.2.7", "embedded-hal 1.0.0", "embedded-hal-async", "embedded-hal-nb", @@ -521,6 +515,7 @@ dependencies = [ "embedded-io-async", "enumset", "esp-build", + "esp-config", "esp-hal-procmacros", "esp-metadata", "esp-riscv-rt", @@ -538,55 +533,58 @@ dependencies = [ "rand_core", "riscv", "serde", - "strum 0.26.2", + "strum", + "ufmt-write", "void", "xtensa-lx-rt", ] [[package]] name = "esp-hal-embassy" -version = "0.1.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a892b9fe96cdfddab252ffa0ea90de66ccb078ff42d037b14ca9dfa3608b688a" +checksum = "c7d0f2537ea2ff9bea26a1c8bfe43ad580d4c89febf27189653a9cf95f1f7961" dependencies = [ - "cfg-if", "critical-section", "defmt", "document-features", "embassy-executor", "embassy-time-driver", "esp-build", + "esp-config", "esp-hal", + "esp-hal-procmacros", "esp-metadata", "portable-atomic", + "static_cell", ] [[package]] name = "esp-hal-procmacros" -version = "0.11.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "788b535b8127a8f0d1f40a8d8e300e57a8c361c492d660dd08fe8e9a1b96ee3c" +checksum = "69a9a8706b7d1182b56335d196e70eeb04e2b70f4b8db96432898bd3c2bdb91e" dependencies = [ "darling", "document-features", "litrs", "proc-macro-crate", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] name = "esp-metadata" -version = "0.1.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "654b8f14bf076fe5995fe94fabbe41a98041e1f2f801e5b3404dcae87e476db6" +checksum = "f9972bbb21dcafe430b87f92efc7a788978a2d17cf8f572d104beeb48602482a" dependencies = [ + "anyhow", "basic-toml", - "lazy_static", "serde", - "strum 0.26.2", + "strum", ] [[package]] @@ -603,9 +601,9 @@ dependencies = [ [[package]] name = "esp-riscv-rt" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "404129c79e9dc34f8b468ec44e71ce36a0bd443cb88be0feffa4b9f3856c97a6" +checksum = "94aca65db6157aa5f42d9df6595b21462f28207ca4230b799aa3620352ef6a72" dependencies = [ "document-features", "riscv", @@ -614,21 +612,20 @@ dependencies = [ [[package]] name = "esp32" -version = "0.31.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da8c87b309b29f0effa613444cf3bd6d54c533627f3e5f8e244994d6726aa78f" +checksum = "af7d3208ef4ffd96c3105b3fb6fd19e8512bc128b24cb866dc26a734b09f454c" dependencies = [ "critical-section", "defmt", "vcell", - "xtensa-lx", ] [[package]] name = "esp32c2" -version = "0.20.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511b3be0c9dc427476e1cffbb68945ee8f83d7059f1035d8a3fb1896c7f6ec64" +checksum = "e74f8ceff5249a39f6ffeaea7a9c048b36fd1ba67d365330e0970927c57759ab" dependencies = [ "critical-section", "defmt", @@ -637,9 +634,9 @@ dependencies = [ [[package]] name = "esp32c3" -version = "0.23.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f117ffaf6cb5873e8ba4f78b969491fac3db459c08bf464af1e3b3fc5394692d" +checksum = "5d1750382dc49fa333ee6b1ba96f8c540038b9666f5a233dc1221c98e3236118" dependencies = [ "critical-section", "defmt", @@ -648,9 +645,9 @@ dependencies = [ [[package]] name = "esp32c6" -version = "0.14.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0882eca9c324ed2fef978ca9dc8e705114fb9fdcd5039be2075f4ae08d3246" +checksum = "8b98fcf7ae90ee4d55f06170dfeaaebbf2a1619bb38b4e14b9009b4d636b87e7" dependencies = [ "critical-section", "defmt", @@ -659,9 +656,9 @@ dependencies = [ [[package]] name = "esp32h2" -version = "0.10.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b246d5ebea2d4dbfb4df2867109ad06abb5c9e113a96da97ddfb722a2a93fb1" +checksum = "b1530274ade78283655a6810dd5d1840404945f4a5bf3d74729c35946beb8304" dependencies = [ "critical-section", "defmt", @@ -670,26 +667,24 @@ dependencies = [ [[package]] name = "esp32s2" -version = "0.22.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff6342357772b5197b18102d1a1d3c9b7db3fc2910d61643ab56e873d3b6fc" +checksum = "2f77ec7a694eb60741f53236e625456abf672ba5b0b73c4a2d708a343c6f3495" dependencies = [ "critical-section", "defmt", "vcell", - "xtensa-lx", ] [[package]] name = "esp32s3" -version = "0.26.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53ac7bb447c239be8a6a9eba9aaf4099c3aab4b7aefca5871be8bf7d8c8893cf" +checksum = "fe69dca8db0ed37d222555f12dfaf99232592e84f54e56dd81e450a4769718bf" dependencies = [ "critical-section", "defmt", "vcell", - "xtensa-lx", ] [[package]] @@ -704,6 +699,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7" dependencies = [ + "defmt", "gcd", ] @@ -757,9 +753,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heapless" @@ -787,9 +783,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "ident_case" @@ -799,20 +795,14 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libm" version = "0.2.8" @@ -871,9 +861,9 @@ checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" [[package]] name = "minijinja" -version = "1.0.21" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e877d961d4f96ce13615862322df7c0b6d169d40cab71a7ef3f9b9e594451e" +checksum = "2c37e1b517d1dcd0e51dc36c4567b9d5a29262b3ec8da6cb5d35e27a8fb529b5" dependencies = [ "serde", ] @@ -919,7 +909,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] @@ -969,9 +959,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] @@ -1000,20 +990,42 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.93", +] + [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1031,53 +1043,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] -name = "regex" -version = "1.10.4" +name = "riscv" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "5ea8ff73d3720bdd0a97925f0bf79ad2744b6da8ff36be3840c48ac81191d7a7" dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", + "critical-section", + "embedded-hal 1.0.0", + "paste", + "riscv-macros", + "riscv-pac", ] [[package]] -name = "regex-automata" -version = "0.4.6" +name = "riscv-macros" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "f265be5d634272320a7de94cea15c22a3bfdd4eb42eb43edc528415f066a1f25" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "proc-macro2", + "quote", + "syn 2.0.93", ] [[package]] -name = "regex-syntax" -version = "0.8.3" +name = "riscv-pac" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" - -[[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", -] +checksum = "8188909339ccc0c68cfb5a04648313f09621e8b87dc03095454f1a11f6c5d436" [[package]] name = "riscv-rt-macros" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d100d466dbb76681ef6a9386f3da9abc570d57394e86da0ba5af8c4408486d" +checksum = "30f19a85fe107b65031e0ba8ec60c34c2494069fe910d6c297f5e7cb5a6f76d0" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.93", ] [[package]] @@ -1109,22 +1112,31 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", +] + +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", ] [[package]] @@ -1150,7 +1162,7 @@ dependencies = [ "cfg-if", "critical-section", "defmt", - "embassy-embedded-hal", + "embassy-embedded-hal 0.1.0", "embassy-executor", "embassy-sync 0.5.0", "embassy-time", @@ -1191,43 +1203,24 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" - -[[package]] -name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ - "strum_macros 0.26.2", + "strum_macros", ] [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 1.0.109", -] - -[[package]] -name = "strum_macros" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.66", + "syn 2.0.93", ] [[package]] @@ -1237,15 +1230,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.66" +version = "2.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058" dependencies = [ "proc-macro2", "quote", @@ -1278,26 +1270,49 @@ checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", +] + +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] +[[package]] +name = "ufmt-write" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" + [[package]] name = "unicode-ident" version = "1.0.12" @@ -1406,9 +1421,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.5.40" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68" dependencies = [ "memchr", ] @@ -1421,30 +1436,35 @@ checksum = "e758f94e1a1f71758f94052a2766dcb12604998eb372b8b2e30576e3ab1ba1e6" dependencies = [ "bare-metal", "mutex-trait", - "spin", ] [[package]] name = "xtensa-lx-rt" -version = "0.16.0" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904102108b780c9a5e3275c5f3c63dc348ec43ae5da5237868515498b447d51a" +checksum = "5c0307d03dadbf95633942e13901984f2059df4c963367348168cbd21c962669" dependencies = [ + "anyhow", "bare-metal", - "core-isa-parser", + "document-features", + "enum-as-inner", "minijinja", "r0", + "serde", + "strum", + "toml", + "xtensa-lx", "xtensa-lx-rt-proc-macros", ] [[package]] name = "xtensa-lx-rt-proc-macros" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "082cdede098bbec9af15b0e74085e5f3d16f2923597de7aed7b8112003af2da7" +checksum = "11277b1e4cbb7ffe44678c668518b249c843c81df249b8f096701757bc50d7ee" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.93", ] diff --git a/Cargo.toml b/Cargo.toml index f457b1b..37728f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ publish = false cfg-if = "1.0.0" critical-section = "1.1.3" -embassy-executor = { version = "0.5.0", features = ["task-arena-size-8192", "defmt"] } +embassy-executor = { version = "0.6.3", features = ["task-arena-size-8192", "defmt"] } embassy-sync = "0.5.0" embassy-time = { version = "0.3.1", features = ["defmt"]} embassy-time-driver = { version = "0.1.0", optional = true } @@ -20,8 +20,8 @@ embedded-hal-bus = { version = "0.1.0", features = ["async"] } embedded-io-async = "0.6.1" esp-backtrace = { version = "0.14.1", features = ["esp32c3", "exception-handler", "panic-handler", "println"] } -esp-hal = { version = "0.18.0", features = ["esp32c3", "async", "opsram-2m", "defmt"] } -esp-hal-embassy = { version = "0.1.0", features = ["esp32c3", "defmt", "integrated-timers", "time-timg0"]} +esp-hal = { version = "0.22.0", features = ["esp32c3", "defmt"] } +esp-hal-embassy = { version = "0.5.0", features = ["esp32c3", "defmt", "integrated-timers"]} esp-println = { version = "0.11.0", features = ["esp32c3", "defmt-espflash"] } defmt = "0.3.6" diff --git a/resources/pinmap.md b/resources/pinmap.md index 1d2a989..b363223 100644 --- a/resources/pinmap.md +++ b/resources/pinmap.md @@ -7,9 +7,12 @@ LORA RST -> Pin 6 LORA IRQ -> Pin 5 # tx/rx breadboard -LORA NSS -> Pin 7 -LORA MOSI -> Pin 10 -LORA MISO -> Pin 20 -LORA CLK -> Pin 21 -LORA RST -> Pin 5 -LORA IRQ -> Pin 6 \ No newline at end of file +LORA NSS -> Pin 0 +LORA MOSI -> Pin 1 +LORA MISO -> Pin 21 +LORA CLK -> Pin 20 +LORA RST -> Pin 10 +LORA IRQ -> Pin 2 + +UART RX -> Pin 5 +UART TX -> Pin 6 \ No newline at end of file diff --git a/src/alt.rs b/src/alt.rs index c4df900..988fcce 100644 --- a/src/alt.rs +++ b/src/alt.rs @@ -1,40 +1,40 @@ -// use bme280::i2c::AsyncBME280; -use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; -use embassy_executor::task; -use embassy_sync::blocking_mutex::raw::NoopRawMutex; -use embassy_time::{Delay, Timer}; -use esp_hal::{i2c::I2C, peripherals::I2C0, Async}; -use micromath::F32Ext; +// // use bme280::i2c::AsyncBME280; +// use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; +// use embassy_executor::task; +// use embassy_sync::blocking_mutex::raw::NoopRawMutex; +// use embassy_time::{Delay, Timer}; +// use esp_hal::{i2c::I2C, peripherals::I2C0, Async}; +// use micromath::F32Ext; -use crate::state::STATE; +// use crate::state::STATE; -fn get_absolute_altitude_from_pressure(pressure: f32) -> f32 { - // TODO This isn't giving me the numbers I expect - const SEA_LEVEL_PRESSURE_HPA: f32 = 101325_f32; - 44_330_f32 * (1_f32 - f32::powf(pressure / SEA_LEVEL_PRESSURE_HPA, 0.1903_f32)) -} +// fn get_absolute_altitude_from_pressure(pressure: f32) -> f32 { +// // TODO This isn't giving me the numbers I expect +// const SEA_LEVEL_PRESSURE_HPA: f32 = 101325_f32; +// 44_330_f32 * (1_f32 - f32::powf(pressure / SEA_LEVEL_PRESSURE_HPA, 0.1903_f32)) +// } -#[task] -pub async fn sample(i2c: I2cDevice<'static, NoopRawMutex, I2C<'static, I2C0, Async>>) -> ! { - // let mut alitmeter = AsyncBME280::new_primary(i2c); - // alitmeter.init(&mut Delay).await.unwrap(); +// #[task] +// pub async fn sample(i2c: I2cDevice<'static, NoopRawMutex, I2C<'static, I2C0, Async>>) -> ! { +// // let mut alitmeter = AsyncBME280::new_primary(i2c); +// // alitmeter.init(&mut Delay).await.unwrap(); - // // Idk try waiting 1 sec for things to get going? - // Timer::after_millis(5_000).await; +// // // Idk try waiting 1 sec for things to get going? +// // Timer::after_millis(5_000).await; - // let starting_alt = alitmeter.measure(&mut Delay).await.unwrap(); - // let starting_alt = get_absolute_altitude_from_pressure(starting_alt.pressure); +// // let starting_alt = alitmeter.measure(&mut Delay).await.unwrap(); +// // let starting_alt = get_absolute_altitude_from_pressure(starting_alt.pressure); - loop { - // let current_alt = alitmeter.measure(&mut Delay).await.unwrap(); - // { - // let mut state = STATE.lock().await; - // let alt = get_absolute_altitude_from_pressure(current_alt.pressure); - // state.aaa = Some(alt); - // state.aar = Some(alt - starting_alt); - // state.aaa = Some(current_alt.temperature) - // } +// loop { +// // let current_alt = alitmeter.measure(&mut Delay).await.unwrap(); +// // { +// // let mut state = STATE.lock().await; +// // let alt = get_absolute_altitude_from_pressure(current_alt.pressure); +// // state.aaa = Some(alt); +// // state.aar = Some(alt - starting_alt); +// // state.aaa = Some(current_alt.temperature) +// // } - // Timer::after_millis(1_000).await; - } -} +// // Timer::after_millis(1_000).await; +// } +// } diff --git a/src/bin/av.rs b/src/bin/av.rs index a823eb7..cd9f1ad 100644 --- a/src/bin/av.rs +++ b/src/bin/av.rs @@ -2,23 +2,19 @@ #![no_main] #![no_std] -use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; use embassy_executor::{task, Spawner}; use embassy_time::Timer; use esp_hal::{ - clock::{ClockControl, CpuClock}, - gpio::{any_pin::AnyPin, Io}, peripherals::Peripherals, prelude::*, - system::SystemControl, timer::timg::TimerGroup, }; use defmt::info; use esp_backtrace as _; -use stack_ripper::{alt, i2c, imu, state}; +use stack_ripper::state; #[task] async fn print_state() -> ! { @@ -32,30 +28,26 @@ async fn print_state() -> ! { async fn main(_spawner: Spawner) -> () { info!("Initializing"); - let peripherals: Peripherals = Peripherals::take(); - let system = SystemControl::new(peripherals.SYSTEM); - let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock160MHz).freeze(); - let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks); + let peripherals: Peripherals = esp_hal::init(esp_hal::Config::default()); + let timg0 = TimerGroup::new(peripherals.TIMG0); - esp_hal_embassy::init(&clocks, timg0); - - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + esp_hal_embassy::init(timg0.timer0); info!("Initializing compete"); - // Setup I2C bus - let i2c_clock = AnyPin::new(io.pins.gpio8); - let i2c_data = AnyPin::new(io.pins.gpio9); + // // Setup I2C bus + // let i2c_clock = AnyPin::new(io.pins.gpio8); + // let i2c_data = AnyPin::new(io.pins.gpio9); - let i2c_bus = i2c::init(peripherals.I2C0, &clocks, i2c_clock, i2c_data); + // let i2c_bus = i2c::init(peripherals.I2C0, &clocks, i2c_clock, i2c_data); - // let i2c_alt = I2cDevice::new(i2c_bus); - // _spawner.spawn(alt::sample(i2c_alt)).ok(); + // // let i2c_alt = I2cDevice::new(i2c_bus); + // // _spawner.spawn(alt::sample(i2c_alt)).ok(); - let i2c_imu = I2cDevice::new(i2c_bus); - _spawner.spawn(imu::sample(i2c_imu)).ok(); + // let i2c_imu = I2cDevice::new(i2c_bus); + // _spawner.spawn(imu::sample(i2c_imu)).ok(); - info!("Initializing compete"); + // info!("Initializing compete"); // Finally set up the task to print state _spawner.spawn(print_state()).ok(); diff --git a/src/bin/rx.rs b/src/bin/rx.rs index c170a8f..824da50 100644 --- a/src/bin/rx.rs +++ b/src/bin/rx.rs @@ -3,24 +3,19 @@ #![no_std] use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; -use embassy_executor::{task, Spawner}; +use embassy_executor::Spawner; use embassy_time::Timer; - use esp_hal::{ - clock::{ClockControl, CpuClock}, - gpio::{any_pin::AnyPin, AnyInput, AnyOutput, Io, Level, Pull}, + gpio::{Input, Level, Output, Pin, Pull}, peripherals::Peripherals, - prelude::*, - system::SystemControl, timer::timg::TimerGroup, }; - use defmt::info; use esp_backtrace as _; use stack_ripper::{lora, spi, state}; -#[task] +#[embassy_executor::task] async fn print_state() -> ! { loop { info!("{:?}", *state::STATE.lock().await); @@ -28,42 +23,38 @@ async fn print_state() -> ! { } } -#[main] -async fn main(_spawner: Spawner) -> () { +#[esp_hal_embassy::main] +async fn main(spawner: Spawner) { info!("Initializing"); - let peripherals: Peripherals = Peripherals::take(); - let system = SystemControl::new(peripherals.SYSTEM); - let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock160MHz).freeze(); - let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks); + let peripherals: Peripherals = esp_hal::init(esp_hal::Config::default()); + let timg0 = TimerGroup::new(peripherals.TIMG0); - esp_hal_embassy::init(&clocks, timg0); - - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + esp_hal_embassy::init(timg0.timer0); info!("Initializing compete"); // Set SPI bus - let spi_clock = AnyPin::new(io.pins.gpio4); - let spi_miso = AnyPin::new(io.pins.gpio3); - let spi_mosi = AnyPin::new(io.pins.gpio2); + let spi_clock = peripherals.GPIO4.degrade(); + let spi_miso = peripherals.GPIO3.degrade(); + let spi_mosi = peripherals.GPIO2.degrade(); let spi_bus = spi::init( peripherals.DMA, peripherals.SPI2, - &clocks, spi_clock, spi_mosi, spi_miso, ); - let lora_spi_csb = AnyOutput::new(io.pins.gpio1, Level::High); - let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); + let lora_spi_csb = Output::new(peripherals.GPIO1.degrade(), Level::High); + + let lora_spi= SpiDevice::new(spi_bus, lora_spi_csb); - let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio6, Level::High); - let lora_irq = AnyInput::new(io.pins.gpio5, Pull::Up); + let lora_rst = Output::new(peripherals.GPIO6.degrade(), Level::High); + let lora_irq = Input::new(peripherals.GPIO5.degrade(), Pull::Up); - _spawner - .spawn(lora::receive(lora_spi, lora_irq.into(), lora_rst.into())) + spawner + .spawn(lora::receive(lora_spi, lora_irq, lora_rst)) .ok(); } diff --git a/src/bin/tx.rs b/src/bin/tx.rs index db0c414..96a0ad3 100644 --- a/src/bin/tx.rs +++ b/src/bin/tx.rs @@ -2,24 +2,20 @@ #![no_main] #![no_std] -use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; use embassy_executor::{task, Spawner}; use embassy_time::Timer; use esp_hal::{ - clock::{ClockControl, CpuClock}, - gpio::{any_pin::AnyPin, AnyInput, AnyOutput, Io, Level, Pull}, peripherals::Peripherals, prelude::*, - system::SystemControl, timer::timg::TimerGroup, - uart::{config::Config, TxRxPins, Uart}, + uart::{Config, Uart}, }; use defmt::info; use esp_backtrace as _; -use stack_ripper::{gps, lora, spi, state}; +use stack_ripper::{gps, state}; #[task] async fn print_state() -> ! { @@ -33,51 +29,51 @@ async fn print_state() -> ! { async fn main(_spawner: Spawner) -> () { info!("Initializing"); - let peripherals: Peripherals = Peripherals::take(); - let system = SystemControl::new(peripherals.SYSTEM); - let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock160MHz).freeze(); - let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks); + let peripherals: Peripherals = esp_hal::init(esp_hal::Config::default()); + let timg0 = TimerGroup::new(peripherals.TIMG0); - esp_hal_embassy::init(&clocks, timg0); - - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + esp_hal_embassy::init(timg0.timer0); info!("Initializing compete"); // Setup UART for GPS - // let uart_pins = Some(TxRxPins::new_tx_rx(io.pins.gpio21, io.pins.gpio20)); - // let uart_config = Config::default().baudrate(9200); - // let uart = Uart::new_async_with_config(peripherals.UART0, uart_config, uart_pins, &clocks); + let tx_pin = peripherals.GPIO7.degrade(); + let rx_pin = peripherals.GPIO8.degrade(); + + let uart_config = Config::default().baudrate(9600); + let uart = Uart::new_with_config(peripherals.UART0, uart_config, tx_pin, rx_pin) + .unwrap() + .into_async(); - // let (_, rx) = uart.split(); + let (rx, _) = uart.split(); // Note that this task now owns the UART RX line completely // UART is a 1:1 interface, so this is fine - // _spawner.spawn(gps::sample_uart(rx)).unwrap(); + _spawner.spawn(gps::sample_uart(rx)).unwrap(); // Setup SPI bus - let spi_clock = AnyPin::new(io.pins.gpio20); - let spi_miso = AnyPin::new(io.pins.gpio21); - let spi_mosi = AnyPin::new(io.pins.gpio1); - - let spi_bus = spi::init( - peripherals.DMA, - peripherals.SPI2, - &clocks, - spi_clock, - spi_mosi, - spi_miso, - ); - - let lora_spi_csb = AnyOutput::new(io.pins.gpio0, Level::High); - let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); - - let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio10, Level::High); - let lora_irq = AnyInput::new(io.pins.gpio2, Pull::Up); - - _spawner - .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) - .ok(); + // let spi_clock = AnyPin::new(io.pins.gpio20); + // let spi_miso = AnyPin::new(io.pins.gpio21); + // let spi_mosi = AnyPin::new(io.pins.gpio1); + + // let spi_bus = spi::init( + // peripherals.DMA, + // peripherals.SPI2, + // &clocks, + // spi_clock, + // spi_mosi, + // spi_miso, + // ); + + // let lora_spi_csb = AnyOutput::new(io.pins.gpio0, Level::High); + // let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); + + // let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio10, Level::High); + // let lora_irq = AnyInput::new(io.pins.gpio2, Pull::Up); + + // _spawner + // .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) + // .ok(); // Finally set up the task to print state // _spawner.spawn(print_state()).ok(); diff --git a/src/gps.rs b/src/gps.rs index 1803df0..0f187d9 100644 --- a/src/gps.rs +++ b/src/gps.rs @@ -1,13 +1,13 @@ use defmt::{error, info}; use embassy_executor::task; use embedded_io_async::Read; -use esp_hal::{peripherals::UART0, uart::UartRx, Async}; +use esp_hal::{peripherals::UART0, uart::{AnyUart, UartRx}, Async}; use nmea0183::{ParseResult, Parser, Sentence}; use crate::state::STATE; #[task] -pub async fn sample_uart(mut rx: UartRx<'static, UART0, Async>) -> ! { +pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { // Apparently NMEA sentences are always 79 bytes long, but we'll give this a buffer let mut read_buffer: [u8; 1] = [0u8; 1]; @@ -16,8 +16,22 @@ pub async fn sample_uart(mut rx: UartRx<'static, UART0, Async>) -> ! { let mut parser: Parser = Parser::new().sentence_only(Sentence::GGA); loop { + info!("waiting for a byte"); + // Read one byte - Read::read(&mut rx, &mut read_buffer).await.unwrap(); + // let read_result = Read::read(&mut rx, &mut read_buffer).await; + + // match read_result { + // Ok(_) => { + // read_result.unwrap(); + // } + // Err(_) => { + // // Should we empty the buffer here? + // continue; + // } + // } + + info!("Read a byte"); let parsed_message = parser.parse_from_byte(read_buffer[0]); diff --git a/src/i2c.rs b/src/i2c.rs index d16e013..79153e4 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -1,19 +1,19 @@ -use embassy_sync::{blocking_mutex::raw::NoopRawMutex, mutex::Mutex}; -use esp_hal::{clock::Clocks, gpio::any_pin::AnyPin, i2c::I2C, peripherals::I2C0, Async}; -use fugit::RateExtU32; -use static_cell::StaticCell; +// use embassy_sync::{blocking_mutex::raw::NoopRawMutex, mutex::Mutex}; +// use esp_hal::{clock::Clocks, gpio::any_pin::AnyPin, i2c::I2C, peripherals::I2C0, Async}; +// use fugit::RateExtU32; +// use static_cell::StaticCell; -static I2C_BUS: StaticCell>> = StaticCell::new(); +// static I2C_BUS: StaticCell>> = StaticCell::new(); -pub fn init( - i2c: I2C0, - clocks: &Clocks, - clock: AnyPin<'static>, - sda: AnyPin<'static>, -) -> &'static mut Mutex> { - let i2c = I2C::new_async(i2c, sda, clock, 800_u32.kHz(), &clocks); +// pub fn init( +// i2c: I2C0, +// clocks: &Clocks, +// clock: AnyPin<'static>, +// sda: AnyPin<'static>, +// ) -> &'static mut Mutex> { +// let i2c = I2C::new_async(i2c, sda, clock, 800_u32.kHz(), &clocks); - let i2c_bus = Mutex::new(i2c); +// let i2c_bus = Mutex::new(i2c); - I2C_BUS.init(i2c_bus) -} +// I2C_BUS.init(i2c_bus) +// } diff --git a/src/imu.rs b/src/imu.rs index b2c988d..279450e 100644 --- a/src/imu.rs +++ b/src/imu.rs @@ -1,41 +1,41 @@ -use bno055::BNO055OperationMode; -use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; -use embassy_executor::task; -use embassy_sync::blocking_mutex::raw::NoopRawMutex; -use embassy_time::{Delay, Timer}; -use esp_hal::{i2c::I2C, peripherals::I2C0, Async}; - -#[task] -pub async fn sample(i2c: I2cDevice<'static, NoopRawMutex, I2C<'static, I2C0, Async>>) -> ! { - Timer::after_millis(2_000).await; - - let mut imu = bno055::Bno055::new(i2c); - - imu.init(&mut Delay).await.unwrap(); - - // Set to 9DOF Absolute Sensor Fusion mode - imu.set_mode(BNO055OperationMode::NDOF, &mut Delay) - .await - .unwrap(); - - // Update the G range of the accelerometer to ±16G - let mut acc_config = imu.get_acc_config().await.unwrap(); - acc_config.set_g_range(bno055::AccGRange::G16); - imu.set_acc_config(&acc_config).await.unwrap(); - - // This is annoyingly blocking - while !imu.is_fully_calibrated().await.unwrap() { - Timer::after_millis(100).await; - } - - loop { - // The quaternion encodes the info from the gyroscope - let _q = imu.quaternion().await.unwrap(); - - // The linear acceleration encodes the info from the accelerometer - // Gavity should be removed due to the sensor fusion mode - let _l = imu.linear_acceleration().await.unwrap(); - - Timer::after_millis(1_000).await; - } -} +// use bno055::BNO055OperationMode; +// use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; +// use embassy_executor::task; +// use embassy_sync::blocking_mutex::raw::NoopRawMutex; +// use embassy_time::{Delay, Timer}; +// use esp_hal::{i2c::I2C, peripherals::I2C0, Async}; + +// #[task] +// pub async fn sample(i2c: I2cDevice<'static, NoopRawMutex, I2C<'static, I2C0, Async>>) -> ! { +// Timer::after_millis(2_000).await; + +// let mut imu = bno055::Bno055::new(i2c); + +// imu.init(&mut Delay).await.unwrap(); + +// // Set to 9DOF Absolute Sensor Fusion mode +// imu.set_mode(BNO055OperationMode::NDOF, &mut Delay) +// .await +// .unwrap(); + +// // Update the G range of the accelerometer to ±16G +// let mut acc_config = imu.get_acc_config().await.unwrap(); +// acc_config.set_g_range(bno055::AccGRange::G16); +// imu.set_acc_config(&acc_config).await.unwrap(); + +// // This is annoyingly blocking +// while !imu.is_fully_calibrated().await.unwrap() { +// Timer::after_millis(100).await; +// } + +// loop { +// // The quaternion encodes the info from the gyroscope +// let _q = imu.quaternion().await.unwrap(); + +// // The linear acceleration encodes the info from the accelerometer +// // Gavity should be removed due to the sensor fusion mode +// let _l = imu.linear_acceleration().await.unwrap(); + +// Timer::after_millis(1_000).await; +// } +// } diff --git a/src/lib.rs b/src/lib.rs index f521697..30fa51d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,11 +2,11 @@ #![no_main] #![no_std] -pub mod i2c; +// pub mod i2c; pub mod spi; -pub mod alt; +// pub mod alt; pub mod gps; -pub mod imu; +// pub mod imu; pub mod lora; pub mod state; diff --git a/src/lora.rs b/src/lora.rs index c3427ff..9f63f8e 100644 --- a/src/lora.rs +++ b/src/lora.rs @@ -4,11 +4,7 @@ use embassy_executor::task; use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embassy_time::{with_timeout, Delay, Duration, Timer}; use esp_hal::{ - dma::Channel0, - gpio::{AnyInput, AnyOutput}, - peripherals::SPI2, - spi::{master::dma::SpiDma, FullDuplexMode}, - Async, + gpio::{AnyPin, Input, Output}, spi::master::SpiDmaBus, Async }; use lora_phy::{ iv::GenericSx127xInterfaceVariant, @@ -29,11 +25,11 @@ pub async fn receive( spi: SpiDevice< 'static, NoopRawMutex, - SpiDma<'static, SPI2, Channel0, FullDuplexMode, Async>, - AnyOutput<'static>, + SpiDmaBus<'static, Async>, + Output<'static, AnyPin>, >, - lora_irq: AnyInput<'static>, - lora_rst: AnyOutput<'static>, + lora_irq: Input<'static, AnyPin>, + lora_rst: Output<'static, AnyPin>, ) -> ! { // We're using an SX1278, but the SX1276 variant seems to work let config = sx127x::Config { @@ -129,11 +125,11 @@ pub async fn transmit( spi: SpiDevice< 'static, NoopRawMutex, - SpiDma<'static, SPI2, Channel0, FullDuplexMode, Async>, - AnyOutput<'static>, + SpiDmaBus<'static, Async>, + Output<'static, AnyPin>, >, - lora_irq: AnyInput<'static>, - lora_rst: AnyOutput<'static>, + lora_irq: Input<'static, AnyPin>, + lora_rst: Output<'static, AnyPin>, ) -> ! { // We're using an SX1278, but the SX1276 variant seems to work let config = sx127x::Config { diff --git a/src/spi.rs b/src/spi.rs index 74b9ee6..1298d0f 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -3,48 +3,42 @@ use fugit::RateExtU32; use static_cell::StaticCell; use esp_hal::{ - clock::Clocks, - dma::{Channel0, Dma, DmaDescriptor, DmaPriority}, - dma_descriptors, - gpio::any_pin::AnyPin, - peripherals::{DMA, SPI2}, - spi::{ - master::{dma::SpiDma, prelude::*, Spi}, - FullDuplexMode, SpiMode, - }, - Async, + dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, gpio::AnyPin, peripherals::{DMA, SPI2}, spi::{ + master::{Config, Spi, SpiDmaBus}, SpiMode, + }, Async }; -static SPI_BUS: StaticCell< - Mutex>, -> = StaticCell::new(); - -static DMA_DESCRIPTORS: StaticCell<([DmaDescriptor; 8], [DmaDescriptor; 8])> = StaticCell::new(); +static SPI_BUS: StaticCell>> = StaticCell::new(); pub fn init( dma: DMA, spi: SPI2, - clocks: &Clocks, - sck: AnyPin<'static>, - mosi: AnyPin<'static>, - miso: AnyPin<'static>, -) -> &'static mut Mutex> { + sck: AnyPin, + mosi: AnyPin, + miso: AnyPin, +) -> &'static mut Mutex> { + let dma = Dma::new(dma); let dma_channel = dma.channel0; - let dma_descriptors = DMA_DESCRIPTORS.init(dma_descriptors!(32000)); + let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(32000); + let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap(); + let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap(); + + let spi_config = Config { + frequency: 200.kHz(), + mode: SpiMode::Mode0, + ..Config::default() + }; // Max bitrate of the SX1278 is 300kbps vs. 2.2mbps for the NEO-M8. We have to pick the lower of the two. - let spi = Spi::new(spi, 22.kHz(), SpiMode::Mode0, &clocks) + let spi = Spi::new_with_config(spi, spi_config) .with_sck(sck) .with_mosi(mosi) .with_miso(miso) - .with_dma(dma_channel.configure_for_async( - false, - &mut dma_descriptors.0, - &mut dma_descriptors.1, - DmaPriority::Priority0, - )); + .with_dma(dma_channel.configure(false, DmaPriority::Priority0)) + .with_buffers(dma_rx_buf, dma_tx_buf) + .into_async(); SPI_BUS.init(Mutex::new(spi)) } From 941ca76690dd697a4f1949aed58f485ed46d08fd Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 1 Jan 2025 21:09:52 +1300 Subject: [PATCH 4/6] it's working, but at what cost. --- src/bin/tx.rs | 55 +++++++++++++++++++++++------------------------ src/gps.rs | 59 +++++++++++++++++++++++++++------------------------ 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/bin/tx.rs b/src/bin/tx.rs index 96a0ad3..0fb5cda 100644 --- a/src/bin/tx.rs +++ b/src/bin/tx.rs @@ -2,20 +2,18 @@ #![no_main] #![no_std] +use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; use embassy_executor::{task, Spawner}; use embassy_time::Timer; use esp_hal::{ - peripherals::Peripherals, - prelude::*, - timer::timg::TimerGroup, - uart::{Config, Uart}, + gpio::{Input, Level, Output, Pull}, peripherals::Peripherals, prelude::*, timer::timg::TimerGroup, uart::{Config, Uart} }; use defmt::info; use esp_backtrace as _; -use stack_ripper::{gps, state}; +use stack_ripper::{gps, lora, spi, state}; #[task] async fn print_state() -> ! { @@ -37,11 +35,11 @@ async fn main(_spawner: Spawner) -> () { info!("Initializing compete"); // Setup UART for GPS - let tx_pin = peripherals.GPIO7.degrade(); let rx_pin = peripherals.GPIO8.degrade(); + let tx_pin = peripherals.GPIO7.degrade(); let uart_config = Config::default().baudrate(9600); - let uart = Uart::new_with_config(peripherals.UART0, uart_config, tx_pin, rx_pin) + let uart = Uart::new_with_config(peripherals.UART0, uart_config, rx_pin, tx_pin) .unwrap() .into_async(); @@ -52,28 +50,27 @@ async fn main(_spawner: Spawner) -> () { _spawner.spawn(gps::sample_uart(rx)).unwrap(); // Setup SPI bus - // let spi_clock = AnyPin::new(io.pins.gpio20); - // let spi_miso = AnyPin::new(io.pins.gpio21); - // let spi_mosi = AnyPin::new(io.pins.gpio1); - - // let spi_bus = spi::init( - // peripherals.DMA, - // peripherals.SPI2, - // &clocks, - // spi_clock, - // spi_mosi, - // spi_miso, - // ); - - // let lora_spi_csb = AnyOutput::new(io.pins.gpio0, Level::High); - // let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into()); - - // let lora_rst: AnyOutput<'_> = AnyOutput::new(io.pins.gpio10, Level::High); - // let lora_irq = AnyInput::new(io.pins.gpio2, Pull::Up); - - // _spawner - // .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) - // .ok(); + let spi_clock = peripherals.GPIO20.degrade(); + let spi_miso = peripherals.GPIO21.degrade(); + let spi_mosi = peripherals.GPIO1.degrade(); + + let spi_bus = spi::init( + peripherals.DMA, + peripherals.SPI2, + spi_clock, + spi_mosi, + spi_miso, + ); + + let lora_spi_csb = Output::new(peripherals.GPIO0.degrade(), Level::High); + let lora_spi= SpiDevice::new(spi_bus, lora_spi_csb); + + let lora_rst = Output::new(peripherals.GPIO10.degrade(), Level::High); + let lora_irq = Input::new(peripherals.GPIO2.degrade(), Pull::Up); + + _spawner + .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) + .ok(); // Finally set up the task to print state // _spawner.spawn(print_state()).ok(); diff --git a/src/gps.rs b/src/gps.rs index 0f187d9..bc288e5 100644 --- a/src/gps.rs +++ b/src/gps.rs @@ -1,7 +1,7 @@ use defmt::{error, info}; use embassy_executor::task; use embedded_io_async::Read; -use esp_hal::{peripherals::UART0, uart::{AnyUart, UartRx}, Async}; +use esp_hal::{uart::{AnyUart, UartRx}, Async}; use nmea0183::{ParseResult, Parser, Sentence}; use crate::state::STATE; @@ -11,54 +11,57 @@ pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { // Apparently NMEA sentences are always 79 bytes long, but we'll give this a buffer let mut read_buffer: [u8; 1] = [0u8; 1]; - // We only want GGA sentences parsed, which contains the main GPS info we need - // let mut parser = Parser::new().sentence_only(Sentence::GGA); - let mut parser: Parser = Parser::new().sentence_only(Sentence::GGA); + // We only want GGA/GLL sentences parsed, which contain the main GPS info we need + let mut parser: Parser = Parser::new().sentence_filter(Sentence::GGA | Sentence::GLL); loop { - info!("waiting for a byte"); - // Read one byte - // let read_result = Read::read(&mut rx, &mut read_buffer).await; + let read_result = Read::read(&mut rx, &mut read_buffer).await; - // match read_result { - // Ok(_) => { - // read_result.unwrap(); - // } - // Err(_) => { - // // Should we empty the buffer here? - // continue; - // } - // } + // info!("Results: {}", u8s_to_str(&read_buffer)); - info!("Read a byte"); + match read_result { + Ok(_) => { + // I think we don't need to do this? + read_result.unwrap(); + } + Err(_) => { + // Should we empty the buffer here? + error!("read error"); + continue; + } + } - let parsed_message = parser.parse_from_byte(read_buffer[0]); + let message = parser.parse_from_byte(read_buffer[0]); - // Not enough info to prase a message yet - if parsed_message.is_none() { + if message.is_none() + { continue; } - // Parsed message but be something, match it - match parsed_message.unwrap() { + match message.unwrap() { Ok(ParseResult::GGA(Some(gps_result))) => { - info!("Location result parsed."); + info!("GGA Location result parsed."); let mut state = STATE.lock().await; state.lt = Some(gps_result.latitude.as_f64() as f32); state.ln = Some(gps_result.longitude.as_f64() as f32); state.ga = Some(gps_result.altitude.meters); } + Ok(ParseResult::GLL(Some(gps_result))) => { + info!("GLL location result parsed."); + let mut state = STATE.lock().await; + state.lt = Some(gps_result.latitude.as_f64() as f32); + state.ln = Some(gps_result.longitude.as_f64() as f32); + } Ok(ParseResult::GGA(None)) => { - info!("Location result recieved, but with empty information"); + // info!("Location result recieved, but with empty information"); } Ok(_) => { - /* Other results parsed. This shouldn't happen because of the filter */ - error!("Some other result recieved from GPS\n"); + // error!("Some other result recieved from GPS\n"); } Err(e) => { - error!("NMEA Parse Error: {:?}\n", e); + // error!("NMEA Parse Error: {:?}\n", e); } } } -} +} \ No newline at end of file From 07a97c3866fada606b6d8cc9f9df4aea63631a01 Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 1 Jan 2025 21:46:29 +1300 Subject: [PATCH 5/6] Remove AV stuff --- README.md | 11 ++--------- src/alt.rs | 40 -------------------------------------- src/bin/av.rs | 54 --------------------------------------------------- src/bin/tx.rs | 16 ++------------- src/gps.rs | 16 +++++++++++---- src/i2c.rs | 19 ------------------ src/imu.rs | 41 -------------------------------------- src/lib.rs | 3 --- src/state.rs | 2 ++ 9 files changed, 18 insertions(+), 184 deletions(-) delete mode 100644 src/alt.rs delete mode 100644 src/bin/av.rs delete mode 100644 src/i2c.rs delete mode 100644 src/imu.rs diff --git a/README.md b/README.md index 22c142c..b6f74bd 100644 --- a/README.md +++ b/README.md @@ -19,19 +19,12 @@ The reciever (`rx`) has: - an SX1278-based LoRA Radio The transmitter (`tx`) additionally includes: -- a u-blox NEO-M8N/MAX-M8N GNSS module, -- a custom LiPo power regulation and monitoring - -The full avionics setup (`av`) additionally includes: -- a BMP280 altimeter, -- a BMO055 IMU, -- multiple n-MOSFET terminals for firing pyrotechnic charges, -- additional hardware lockouts preventing unwanted firings. +- a u-blox GNSS module, ### Software All written in async Rust, using [embassy](https://embassy.dev). -Each platform (`rx`, `tx`, and `av`) has a seperate binary, in `/src/bin/[platform].rs`. +Each platform has a seperate binary, in `/src/bin/[platform].rs`. Each prehipheral is maintained in a resuable library in `/src/[prehipheral].rs` diff --git a/src/alt.rs b/src/alt.rs deleted file mode 100644 index 988fcce..0000000 --- a/src/alt.rs +++ /dev/null @@ -1,40 +0,0 @@ -// // use bme280::i2c::AsyncBME280; -// use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; -// use embassy_executor::task; -// use embassy_sync::blocking_mutex::raw::NoopRawMutex; -// use embassy_time::{Delay, Timer}; -// use esp_hal::{i2c::I2C, peripherals::I2C0, Async}; -// use micromath::F32Ext; - -// use crate::state::STATE; - -// fn get_absolute_altitude_from_pressure(pressure: f32) -> f32 { -// // TODO This isn't giving me the numbers I expect -// const SEA_LEVEL_PRESSURE_HPA: f32 = 101325_f32; -// 44_330_f32 * (1_f32 - f32::powf(pressure / SEA_LEVEL_PRESSURE_HPA, 0.1903_f32)) -// } - -// #[task] -// pub async fn sample(i2c: I2cDevice<'static, NoopRawMutex, I2C<'static, I2C0, Async>>) -> ! { -// // let mut alitmeter = AsyncBME280::new_primary(i2c); -// // alitmeter.init(&mut Delay).await.unwrap(); - -// // // Idk try waiting 1 sec for things to get going? -// // Timer::after_millis(5_000).await; - -// // let starting_alt = alitmeter.measure(&mut Delay).await.unwrap(); -// // let starting_alt = get_absolute_altitude_from_pressure(starting_alt.pressure); - -// loop { -// // let current_alt = alitmeter.measure(&mut Delay).await.unwrap(); -// // { -// // let mut state = STATE.lock().await; -// // let alt = get_absolute_altitude_from_pressure(current_alt.pressure); -// // state.aaa = Some(alt); -// // state.aar = Some(alt - starting_alt); -// // state.aaa = Some(current_alt.temperature) -// // } - -// // Timer::after_millis(1_000).await; -// } -// } diff --git a/src/bin/av.rs b/src/bin/av.rs deleted file mode 100644 index cd9f1ad..0000000 --- a/src/bin/av.rs +++ /dev/null @@ -1,54 +0,0 @@ -#![deny(unsafe_code)] -#![no_main] -#![no_std] - -use embassy_executor::{task, Spawner}; -use embassy_time::Timer; - -use esp_hal::{ - peripherals::Peripherals, - prelude::*, - timer::timg::TimerGroup, -}; - -use defmt::info; -use esp_backtrace as _; - -use stack_ripper::state; - -#[task] -async fn print_state() -> ! { - loop { - info!("{:?}", *state::STATE.lock().await); - Timer::after_millis(5_000).await; - } -} - -#[main] -async fn main(_spawner: Spawner) -> () { - info!("Initializing"); - - let peripherals: Peripherals = esp_hal::init(esp_hal::Config::default()); - let timg0 = TimerGroup::new(peripherals.TIMG0); - - esp_hal_embassy::init(timg0.timer0); - - info!("Initializing compete"); - - // // Setup I2C bus - // let i2c_clock = AnyPin::new(io.pins.gpio8); - // let i2c_data = AnyPin::new(io.pins.gpio9); - - // let i2c_bus = i2c::init(peripherals.I2C0, &clocks, i2c_clock, i2c_data); - - // // let i2c_alt = I2cDevice::new(i2c_bus); - // // _spawner.spawn(alt::sample(i2c_alt)).ok(); - - // let i2c_imu = I2cDevice::new(i2c_bus); - // _spawner.spawn(imu::sample(i2c_imu)).ok(); - - // info!("Initializing compete"); - - // Finally set up the task to print state - _spawner.spawn(print_state()).ok(); -} diff --git a/src/bin/tx.rs b/src/bin/tx.rs index 0fb5cda..d31b1fd 100644 --- a/src/bin/tx.rs +++ b/src/bin/tx.rs @@ -3,8 +3,7 @@ #![no_std] use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; -use embassy_executor::{task, Spawner}; -use embassy_time::Timer; +use embassy_executor::Spawner; use esp_hal::{ gpio::{Input, Level, Output, Pull}, peripherals::Peripherals, prelude::*, timer::timg::TimerGroup, uart::{Config, Uart} @@ -13,15 +12,7 @@ use esp_hal::{ use defmt::info; use esp_backtrace as _; -use stack_ripper::{gps, lora, spi, state}; - -#[task] -async fn print_state() -> ! { - loop { - info!("{:?}", *state::STATE.lock().await); - Timer::after_millis(5_000).await; - } -} +use stack_ripper::{gps, lora, spi}; #[main] async fn main(_spawner: Spawner) -> () { @@ -71,7 +62,4 @@ async fn main(_spawner: Spawner) -> () { _spawner .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) .ok(); - - // Finally set up the task to print state - // _spawner.spawn(print_state()).ok(); } diff --git a/src/gps.rs b/src/gps.rs index bc288e5..fab87e2 100644 --- a/src/gps.rs +++ b/src/gps.rs @@ -2,13 +2,21 @@ use defmt::{error, info}; use embassy_executor::task; use embedded_io_async::Read; use esp_hal::{uart::{AnyUart, UartRx}, Async}; -use nmea0183::{ParseResult, Parser, Sentence}; +use nmea0183::{datetime::Time, ParseResult, Parser, Sentence}; use crate::state::STATE; +fn get_time(time: Time) -> i32 { + let h = (time.hours as i32) * 10000; + let m = (time.minutes as i32) * 100; + let s = time.seconds as i32; + h + m + s +} + #[task] pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { - // Apparently NMEA sentences are always 79 bytes long, but we'll give this a buffer + // Apparently NMEA sentences are always 79 bytes long, but that doesn't seem to be true + // We'll just go 1 byte at a time, and let the parser deal with it. let mut read_buffer: [u8; 1] = [0u8; 1]; // We only want GGA/GLL sentences parsed, which contain the main GPS info we need @@ -18,8 +26,6 @@ pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { // Read one byte let read_result = Read::read(&mut rx, &mut read_buffer).await; - // info!("Results: {}", u8s_to_str(&read_buffer)); - match read_result { Ok(_) => { // I think we don't need to do this? @@ -46,12 +52,14 @@ pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { state.lt = Some(gps_result.latitude.as_f64() as f32); state.ln = Some(gps_result.longitude.as_f64() as f32); state.ga = Some(gps_result.altitude.meters); + state.t = Some(get_time(gps_result.time)); } Ok(ParseResult::GLL(Some(gps_result))) => { info!("GLL location result parsed."); let mut state = STATE.lock().await; state.lt = Some(gps_result.latitude.as_f64() as f32); state.ln = Some(gps_result.longitude.as_f64() as f32); + state.t = Some(get_time(gps_result.time)); } Ok(ParseResult::GGA(None)) => { // info!("Location result recieved, but with empty information"); diff --git a/src/i2c.rs b/src/i2c.rs deleted file mode 100644 index 79153e4..0000000 --- a/src/i2c.rs +++ /dev/null @@ -1,19 +0,0 @@ -// use embassy_sync::{blocking_mutex::raw::NoopRawMutex, mutex::Mutex}; -// use esp_hal::{clock::Clocks, gpio::any_pin::AnyPin, i2c::I2C, peripherals::I2C0, Async}; -// use fugit::RateExtU32; -// use static_cell::StaticCell; - -// static I2C_BUS: StaticCell>> = StaticCell::new(); - -// pub fn init( -// i2c: I2C0, -// clocks: &Clocks, -// clock: AnyPin<'static>, -// sda: AnyPin<'static>, -// ) -> &'static mut Mutex> { -// let i2c = I2C::new_async(i2c, sda, clock, 800_u32.kHz(), &clocks); - -// let i2c_bus = Mutex::new(i2c); - -// I2C_BUS.init(i2c_bus) -// } diff --git a/src/imu.rs b/src/imu.rs deleted file mode 100644 index 279450e..0000000 --- a/src/imu.rs +++ /dev/null @@ -1,41 +0,0 @@ -// use bno055::BNO055OperationMode; -// use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; -// use embassy_executor::task; -// use embassy_sync::blocking_mutex::raw::NoopRawMutex; -// use embassy_time::{Delay, Timer}; -// use esp_hal::{i2c::I2C, peripherals::I2C0, Async}; - -// #[task] -// pub async fn sample(i2c: I2cDevice<'static, NoopRawMutex, I2C<'static, I2C0, Async>>) -> ! { -// Timer::after_millis(2_000).await; - -// let mut imu = bno055::Bno055::new(i2c); - -// imu.init(&mut Delay).await.unwrap(); - -// // Set to 9DOF Absolute Sensor Fusion mode -// imu.set_mode(BNO055OperationMode::NDOF, &mut Delay) -// .await -// .unwrap(); - -// // Update the G range of the accelerometer to ±16G -// let mut acc_config = imu.get_acc_config().await.unwrap(); -// acc_config.set_g_range(bno055::AccGRange::G16); -// imu.set_acc_config(&acc_config).await.unwrap(); - -// // This is annoyingly blocking -// while !imu.is_fully_calibrated().await.unwrap() { -// Timer::after_millis(100).await; -// } - -// loop { -// // The quaternion encodes the info from the gyroscope -// let _q = imu.quaternion().await.unwrap(); - -// // The linear acceleration encodes the info from the accelerometer -// // Gavity should be removed due to the sensor fusion mode -// let _l = imu.linear_acceleration().await.unwrap(); - -// Timer::after_millis(1_000).await; -// } -// } diff --git a/src/lib.rs b/src/lib.rs index 30fa51d..f3afbfe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,11 +2,8 @@ #![no_main] #![no_std] -// pub mod i2c; pub mod spi; -// pub mod alt; pub mod gps; -// pub mod imu; pub mod lora; pub mod state; diff --git a/src/state.rs b/src/state.rs index 514e04b..e708fcc 100644 --- a/src/state.rs +++ b/src/state.rs @@ -10,6 +10,7 @@ pub struct State { pub ga: Option, // GPS reported altitude, meters pub aaa: Option, // Altimeter-reported altitude absolute, meters pub aar: Option, // Altimeter-reported altitude reletive from starting height, delta meters + pub t: Option // Time, in HHMMSS (UTC) } pub static STATE: Mutex = Mutex::new(State { @@ -18,4 +19,5 @@ pub static STATE: Mutex = Mutex::new(State { ga: None, aaa: None, aar: None, + t: None, }); From 32d81e87ffcb7a2de0588efd804c7bb649f92758 Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 1 Jan 2025 21:50:16 +1300 Subject: [PATCH 6/6] reformat --- src/bin/rx.rs | 8 ++++---- src/bin/tx.rs | 10 +++++++--- src/gps.rs | 12 +++++++----- src/lora.rs | 20 ++++++-------------- src/spi.rs | 13 +++++++++---- src/state.rs | 2 +- 6 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/bin/rx.rs b/src/bin/rx.rs index 824da50..87babd5 100644 --- a/src/bin/rx.rs +++ b/src/bin/rx.rs @@ -2,16 +2,16 @@ #![no_main] #![no_std] +use defmt::info; use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; use embassy_executor::Spawner; use embassy_time::Timer; +use esp_backtrace as _; use esp_hal::{ gpio::{Input, Level, Output, Pin, Pull}, peripherals::Peripherals, timer::timg::TimerGroup, }; -use defmt::info; -use esp_backtrace as _; use stack_ripper::{lora, spi, state}; @@ -49,10 +49,10 @@ async fn main(spawner: Spawner) { let lora_spi_csb = Output::new(peripherals.GPIO1.degrade(), Level::High); - let lora_spi= SpiDevice::new(spi_bus, lora_spi_csb); + let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb); let lora_rst = Output::new(peripherals.GPIO6.degrade(), Level::High); - let lora_irq = Input::new(peripherals.GPIO5.degrade(), Pull::Up); + let lora_irq = Input::new(peripherals.GPIO5.degrade(), Pull::Up); spawner .spawn(lora::receive(lora_spi, lora_irq, lora_rst)) diff --git a/src/bin/tx.rs b/src/bin/tx.rs index d31b1fd..4ca26d6 100644 --- a/src/bin/tx.rs +++ b/src/bin/tx.rs @@ -6,7 +6,11 @@ use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; use embassy_executor::Spawner; use esp_hal::{ - gpio::{Input, Level, Output, Pull}, peripherals::Peripherals, prelude::*, timer::timg::TimerGroup, uart::{Config, Uart} + gpio::{Input, Level, Output, Pull}, + peripherals::Peripherals, + prelude::*, + timer::timg::TimerGroup, + uart::{Config, Uart}, }; use defmt::info; @@ -54,10 +58,10 @@ async fn main(_spawner: Spawner) -> () { ); let lora_spi_csb = Output::new(peripherals.GPIO0.degrade(), Level::High); - let lora_spi= SpiDevice::new(spi_bus, lora_spi_csb); + let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb); let lora_rst = Output::new(peripherals.GPIO10.degrade(), Level::High); - let lora_irq = Input::new(peripherals.GPIO2.degrade(), Pull::Up); + let lora_irq = Input::new(peripherals.GPIO2.degrade(), Pull::Up); _spawner .spawn(lora::transmit(lora_spi, lora_irq, lora_rst)) diff --git a/src/gps.rs b/src/gps.rs index fab87e2..834f26a 100644 --- a/src/gps.rs +++ b/src/gps.rs @@ -1,7 +1,10 @@ use defmt::{error, info}; use embassy_executor::task; use embedded_io_async::Read; -use esp_hal::{uart::{AnyUart, UartRx}, Async}; +use esp_hal::{ + uart::{AnyUart, UartRx}, + Async, +}; use nmea0183::{datetime::Time, ParseResult, Parser, Sentence}; use crate::state::STATE; @@ -16,7 +19,7 @@ fn get_time(time: Time) -> i32 { #[task] pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { // Apparently NMEA sentences are always 79 bytes long, but that doesn't seem to be true - // We'll just go 1 byte at a time, and let the parser deal with it. + // We'll just go 1 byte at a time, and let the parser deal with it. let mut read_buffer: [u8; 1] = [0u8; 1]; // We only want GGA/GLL sentences parsed, which contain the main GPS info we need @@ -40,8 +43,7 @@ pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { let message = parser.parse_from_byte(read_buffer[0]); - if message.is_none() - { + if message.is_none() { continue; } @@ -72,4 +74,4 @@ pub async fn sample_uart(mut rx: UartRx<'static, Async, AnyUart>) -> ! { } } } -} \ No newline at end of file +} diff --git a/src/lora.rs b/src/lora.rs index 9f63f8e..c5bcc78 100644 --- a/src/lora.rs +++ b/src/lora.rs @@ -4,7 +4,9 @@ use embassy_executor::task; use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embassy_time::{with_timeout, Delay, Duration, Timer}; use esp_hal::{ - gpio::{AnyPin, Input, Output}, spi::master::SpiDmaBus, Async + gpio::{AnyPin, Input, Output}, + spi::master::SpiDmaBus, + Async, }; use lora_phy::{ iv::GenericSx127xInterfaceVariant, @@ -22,12 +24,7 @@ const LORA_MAX_PACKET_SIZE_BYTES: usize = 255; #[task] pub async fn receive( - spi: SpiDevice< - 'static, - NoopRawMutex, - SpiDmaBus<'static, Async>, - Output<'static, AnyPin>, - >, + spi: SpiDevice<'static, NoopRawMutex, SpiDmaBus<'static, Async>, Output<'static, AnyPin>>, lora_irq: Input<'static, AnyPin>, lora_rst: Output<'static, AnyPin>, ) -> ! { @@ -122,12 +119,7 @@ pub async fn receive( #[task] pub async fn transmit( - spi: SpiDevice< - 'static, - NoopRawMutex, - SpiDmaBus<'static, Async>, - Output<'static, AnyPin>, - >, + spi: SpiDevice<'static, NoopRawMutex, SpiDmaBus<'static, Async>, Output<'static, AnyPin>>, lora_irq: Input<'static, AnyPin>, lora_rst: Output<'static, AnyPin>, ) -> ! { @@ -198,7 +190,7 @@ pub async fn transmit( Ok(Ok(r)) => { info!("TX succeeded"); r - }, + } Ok(Err(_)) => { error!("TX failed"); continue; diff --git a/src/spi.rs b/src/spi.rs index 1298d0f..928b6b0 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -3,9 +3,15 @@ use fugit::RateExtU32; use static_cell::StaticCell; use esp_hal::{ - dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, gpio::AnyPin, peripherals::{DMA, SPI2}, spi::{ - master::{Config, Spi, SpiDmaBus}, SpiMode, - }, Async + dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, + dma_buffers, + gpio::AnyPin, + peripherals::{DMA, SPI2}, + spi::{ + master::{Config, Spi, SpiDmaBus}, + SpiMode, + }, + Async, }; static SPI_BUS: StaticCell>> = StaticCell::new(); @@ -17,7 +23,6 @@ pub fn init( mosi: AnyPin, miso: AnyPin, ) -> &'static mut Mutex> { - let dma = Dma::new(dma); let dma_channel = dma.channel0; diff --git a/src/state.rs b/src/state.rs index e708fcc..52bf8db 100644 --- a/src/state.rs +++ b/src/state.rs @@ -10,7 +10,7 @@ pub struct State { pub ga: Option, // GPS reported altitude, meters pub aaa: Option, // Altimeter-reported altitude absolute, meters pub aar: Option, // Altimeter-reported altitude reletive from starting height, delta meters - pub t: Option // Time, in HHMMSS (UTC) + pub t: Option, // Time, in HHMMSS (UTC) } pub static STATE: Mutex = Mutex::new(State {