From b6718cf800b4e6ad49b6c42ee79fd68f92d21de5 Mon Sep 17 00:00:00 2001 From: Stephen D <webmaster@scd31.com> Date: Mon, 14 Oct 2024 16:48:56 -0300 Subject: [PATCH] upgrade packages and allow the ability to change frequency. untested --- Cargo.lock | 114 +++++++++++++++++++++++++++++++--------------------- Cargo.toml | 2 +- src/main.rs | 36 +++++++++++------ 3 files changed, 93 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 45ce266..6ff6a31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "atomic-polyfill" -version = "0.1.11" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" dependencies = [ "critical-section", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bare-metal" @@ -40,15 +40,15 @@ checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" [[package]] name = "bitflags" -version = "2.2.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cortex-m" @@ -122,9 +122,18 @@ dependencies = [ [[package]] name = "critical-section" -version = "1.1.1" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f64009896348fc5af4222e9cf7d7d82a95a256c634ebcf61c53e4ea461422242" + +[[package]] +name = "deranged" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] [[package]] name = "embedded-dma" @@ -162,9 +171,9 @@ checksum = "723dce4e9f25b6e6c5f35628e144794e5b459216ed7da97b7c4b66cdb3fa82ca" [[package]] name = "fugit" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab17bb279def6720d058cb6c052249938e7f99260ab534879281a95367a87e5" +checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7" dependencies = [ "gcd", ] @@ -181,9 +190,9 @@ dependencies = [ [[package]] name = "gcd" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1b088ad0a967aa29540456b82fc8903f854775d33f71e9709c4efb3dfbfd2" +checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" [[package]] name = "hash32" @@ -202,13 +211,13 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heapless" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" dependencies = [ "atomic-polyfill", "hash32", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "spin", "stable_deref_trait", ] @@ -225,9 +234,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -248,6 +257,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "panic-semihosting" version = "0.6.0" @@ -273,6 +288,12 @@ dependencies = [ "systick-monotonic", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -299,18 +320,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -324,7 +345,7 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "rf4463" version = "0.1.0" -source = "git+https://gitlab.scd31.com/stephen/rf4463-lib#e82e919b8c84127428391389dbfdbb0b5b81ed58" +source = "git+https://gitlab.scd31.com/stephen/rf4463-lib#44b1ec1a15aab230388a8da3a313cbaa21a849e7" dependencies = [ "embedded-hal 0.2.7", ] @@ -370,18 +391,18 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.17", + "semver 1.0.23", ] [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" @@ -394,9 +415,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "semver-parser" @@ -433,9 +454,9 @@ dependencies = [ [[package]] name = "stm32f4xx-hal" -version = "0.16.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "431cd6045c6644beb39d421a37967e7f0708bce98ed6e38559137e09d5ae6d81" +checksum = "cc2877159274bc374744f10a4dd913b5175593ce02a94d70b8ba978e49db199b" dependencies = [ "bare-metal 1.0.0", "bitflags", @@ -458,9 +479,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.105" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -480,24 +501,27 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ + "deranged", + "num-conv", + "powerfmt", "time-core", ] [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "vcell" @@ -507,9 +531,9 @@ checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "void" @@ -519,9 +543,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "volatile-register" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" +checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" dependencies = [ "vcell", ] diff --git a/Cargo.toml b/Cargo.toml index 8dc8eb6..5f21bfe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,6 @@ cortex-m-semihosting = "0.5" panic-semihosting = "0.6" rf4463 = { git = "https://gitlab.scd31.com/stephen/rf4463-lib" } cortex-m-rtic = { version = "1.1.4" } -ringbuffer = { version = "0.13.0", default_features = false } +ringbuffer = { version = "0.13.0", default-features = false } systick-monotonic = "1.0.1" #panic-reset = "0.1.1" diff --git a/src/main.rs b/src/main.rs index 62f6a32..d6075a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,7 +46,6 @@ mod app { }; type Radio = Rf4463< - PACKET_LEN, Spi<SPI1>, gpio::Pin<'B', 1, gpio::Output>, gpio::Pin<'B', 0, gpio::Output>, @@ -92,6 +91,7 @@ mod app { #[shared] struct Shared { radio: Radio, + radio_buf: [u8; PACKET_LEN], tx_buf: ConstGenericRingBuffer<Packet, BUFFER_LEN>, pi_tx: TxTransfer, @@ -146,7 +146,8 @@ mod app { let spi = Spi::new(ctx.device.SPI1, (sclk, miso, mosi), MODE, 10.MHz(), &clocks); let delay = ctx.device.TIM5.delay_us(&clocks); - let radio = Rf4463::new(spi, sdn, cs, delay, &mut RADIO_CONFIG_500_2.clone()).unwrap(); + let mut radio = Rf4463::new(spi, sdn, cs, delay, &mut RADIO_CONFIG_500_2.clone()).unwrap(); + radio.set_frequency(446_900_000).unwrap(); radio_irq.make_interrupt_source(&mut sys_cfg); radio_irq.enable_interrupt(&mut ctx.device.EXTI); @@ -219,6 +220,8 @@ mod app { ( Shared { radio, + radio_buf: [0; PACKET_LEN], + tx_buf: ConstGenericRingBuffer::new(), pi_tx, @@ -237,7 +240,7 @@ mod app { ) } - #[idle(shared=[radio, tx_buf, pi_tx, other_tx_buf, spi_data])] + #[idle(shared=[radio, radio_buf, tx_buf, pi_tx, other_tx_buf, spi_data])] fn idle(mut ctx: idle::Context) -> ! { let mut iterations_since_last_packet = 0; loop { @@ -246,23 +249,30 @@ mod app { // if we haven't transmitted in a while, the receiver's AGC is going to be messed up // send 5 packets just so it can calibrate before we actually send it for _ in 0..5 { - const GARBAGE: [u8; PACKET_LEN] = [0x00; PACKET_LEN]; - ctx.shared.radio.lock(|r| r.start_tx(GARBAGE).unwrap()); + ctx.shared.radio_buf.lock(|b| { + *b = [0x00; PACKET_LEN]; + ctx.shared.radio.lock(|r| r.start_tx(b).unwrap()); + }); // wait for radio to be idle again loop { - if ctx.shared.radio.lock(tick) { + if (&mut ctx.shared.radio, &mut ctx.shared.radio_buf) + .lock(|r, b| tick(r, b)) + { break; } } } } - ctx.shared.radio.lock(|r| r.start_tx(pkt.data).unwrap()); + ctx.shared.radio_buf.lock(|b| { + *b = pkt.data; + ctx.shared.radio.lock(|r| r.start_tx(b).unwrap()); + }); // wait for radio to be idle again loop { - if ctx.shared.radio.lock(tick) { + if (&mut ctx.shared.radio, &mut ctx.shared.radio_buf).lock(|r, b| tick(r, b)) { break; } } @@ -335,9 +345,9 @@ mod app { ctx.shared.pi_tx.lock(|tx| tx.clear_fifo_error_interrupt()); } - #[task(binds = EXTI2, shared = [radio], local = [radio_irq])] - fn radio_irq(mut ctx: radio_irq::Context) { - ctx.shared.radio.lock(|r| r.interrupt()).unwrap(); + #[task(binds = EXTI2, shared = [radio, radio_buf], local = [radio_irq])] + fn radio_irq(ctx: radio_irq::Context) { + (ctx.shared.radio, ctx.shared.radio_buf).lock(|r, b| r.interrupt(None, Some(b)).unwrap()); let irq = ctx.local.radio_irq; if irq.is_high() { @@ -422,8 +432,8 @@ mod app { }); } - fn tick(r: &mut Radio) -> bool { - r.interrupt().unwrap(); + fn tick(r: &mut Radio, buf: &[u8; PACKET_LEN]) -> bool { + r.interrupt(None, Some(buf)).unwrap(); r.is_idle() } } -- GitLab