From 4e1f1932c78f65d8575497e882906a9c6a570e65 Mon Sep 17 00:00:00 2001 From: Tobias Breitwieser Date: Tue, 26 Dec 2023 17:18:28 +0100 Subject: [PATCH] remove things to comply with non nighty; set supply configuration to match old default --- Cargo.toml | 10 +++-- examples/embassy-stm32-example/Cargo.toml | 21 ++++++--- .../embassy-stm32-example/rust-toolchain.toml | 4 +- examples/embassy-stm32-example/src/main.rs | 44 +++++++++++++------ src/lib.rs | 6 +-- 5 files changed, 57 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 723b734..b44eb81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,6 +90,10 @@ exclude = ["examples"] no-std-net = { git = "https://github.com/rushmorem/no-std-net", branch = "issue-15" } ublox-sockets = { path = "../ublox-sockets" } atat = { git = "https://github.com/BlackbirdHQ/atat", branch = "master" } -embassy-time = { package = "embassy-time", git = "https://github.com/embassy-rs/embassy", branch = "main" } -embassy-sync = { package = "embassy-sync", git = "https://github.com/embassy-rs/embassy", branch = "main" } -embassy-futures = { package = "embassy-futures", git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-time = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-sync = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-futures = { git = "https://github.com/embassy-rs/embassy", branch = "main" } + +#embassy-time = { path = "../embassy/embassy-time" } +#embassy-sync = { path = "../embassy/embassy-sync" } +#embassy-futures = { path = "../embassy/embassy-futures" } diff --git a/examples/embassy-stm32-example/Cargo.toml b/examples/embassy-stm32-example/Cargo.toml index 61d5585..f8dd8ea 100644 --- a/examples/embassy-stm32-example/Cargo.toml +++ b/examples/embassy-stm32-example/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" # Example for the STM32H747I-DISCO board with SARA-R5 modem attached to UART8 [dependencies] -embassy-stm32 = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", branch = "main", features = ["defmt", "stm32h747xi-cm7", "time-driver-any", "exti", "memory-x", "unstable-pac"] } -embassy-executor = { version = "0.4.0", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-stm32 = { version = "0.1.0", features = ["defmt", "stm32h747xi-cm7", "time-driver-any", "exti", "memory-x", "unstable-pac"] } +embassy-executor = { version = "0.4.0", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", features = ["defmt", "defmt-timestamp-uptime"] } embassy-sync = { version = "0.5", features = ["defmt"] } @@ -18,7 +18,7 @@ defmt = "0.3.5" defmt-rtt = "0.4.0" panic-probe = { version = "0.3.1", features = ["print-defmt"] } -static_cell = { version = "2.0", features = ["nightly"]} +static_cell = { version = "2.0", features = []} atat = { version = "0.20.0", features = ["derive", "bytes", "defmt"] } ublox-cellular-rs = {version = "0.4.0", path = "../..", features = ["sara-r5", "defmt", "async"]} @@ -27,10 +27,17 @@ ublox-cellular-rs = {version = "0.4.0", path = "../..", features = ["sara-r5", " ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", branch = "feature/async-borrowed-sockets" } atat = { git = "https://github.com/BlackbirdHQ/atat", branch = "master" } no-std-net = { git = "https://github.com/rushmorem/no-std-net", branch = "issue-15" } -embassy-time = { package = "embassy-time", git = "https://github.com/embassy-rs/embassy", branch = "main" } -embassy-sync = { package = "embassy-sync", git = "https://github.com/embassy-rs/embassy", branch = "main" } -embassy-futures = { package = "embassy-futures", git = "https://github.com/embassy-rs/embassy", branch = "main" } -embassy-executor = { package = "embassy-executor", git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-stm32 = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-time = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-sync = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-futures = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-executor = { git = "https://github.com/embassy-rs/embassy", branch = "main" } + +#embassy-stm32 = { path = "../../../embassy/embassy-stm32" } +#embassy-time = { path = "../../../embassy/embassy-time" } +#embassy-sync = { path = "../../../embassy/embassy-sync" } +#embassy-futures = { path = "../../../embassy/embassy-futures" } +#embassy-executor = { path = "../../../embassy/embassy-executor" } #ublox-sockets = { path = "../../../ublox-sockets" } #atat = { path = "../../../atat/atat" } diff --git a/examples/embassy-stm32-example/rust-toolchain.toml b/examples/embassy-stm32-example/rust-toolchain.toml index 3c44968..203817d 100644 --- a/examples/embassy-stm32-example/rust-toolchain.toml +++ b/examples/embassy-stm32-example/rust-toolchain.toml @@ -1,8 +1,8 @@ # Before upgrading check that everything is available on all tier1 targets here: # https://rust-lang.github.io/rustup-components-history [toolchain] -#channel = "beta-2023-12-17" -channel = "nightly-2023-12-17" +channel = "beta-2023-12-17" +#channel = "nightly-2023-12-17" components = [ "rust-src", "rustfmt", "llvm-tools" ] targets = [ "thumbv7em-none-eabi", diff --git a/examples/embassy-stm32-example/src/main.rs b/examples/embassy-stm32-example/src/main.rs index 593666d..2634ec0 100644 --- a/examples/embassy-stm32-example/src/main.rs +++ b/examples/embassy-stm32-example/src/main.rs @@ -1,11 +1,11 @@ #![no_std] #![no_main] #![allow(stable_features)] -#![feature(type_alias_impl_trait)] +// #![feature(type_alias_impl_trait)] use atat::asynch::Client; -use atat::UrcChannel; use atat::ResponseSlot; +use atat::UrcChannel; use core::cell::RefCell; use cortex_m_rt::entry; use defmt::*; @@ -17,7 +17,6 @@ use embassy_stm32::time::{khz, mhz}; use embassy_stm32::usart::{BufferedUart, BufferedUartRx, BufferedUartTx}; use embassy_stm32::{bind_interrupts, interrupt, peripherals, usart, Config}; use embassy_time::{Duration, Timer}; -use static_cell::make_static; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; @@ -80,6 +79,7 @@ async fn main_task(spawner: Spawner) { let mut config = Config::default(); { use embassy_stm32::rcc::*; + config.rcc.supply_config = SupplyConfig::DirectSMPS; config.rcc.hsi = Some(HSIPrescaler::DIV1); config.rcc.csi = true; config.rcc.pll1 = Some(Pll { @@ -87,7 +87,7 @@ async fn main_task(spawner: Spawner) { prediv: PllPreDiv::DIV4, mul: PllMul::MUL50, divp: Some(PllDiv::DIV2), - divq: Some(PllDiv::DIV8), // used by SPI3. 100Mhz. + divq: Some(PllDiv::DIV8), // 100mhz divr: None, }); config.rcc.sys = Sysclk::PLL1_P; // 400 Mhz @@ -104,8 +104,9 @@ async fn main_task(spawner: Spawner) { let led2_pin = p.PI13.degrade(); let led3_pin = p.PI14.degrade(); - let tx_buf = &mut make_static!([0u8; 16])[..]; - let rx_buf = &mut make_static!([0u8; 16])[..]; + static tx_buf: StaticCell<[u8; 16]> = StaticCell::new(); + static rx_buf: StaticCell<[u8; 16]> = StaticCell::new(); + let (tx_pin, rx_pin, uart) = (p.PJ8, p.PJ9, p.UART8); let mut uart_config = embassy_stm32::usart::Config::default(); { @@ -116,7 +117,15 @@ async fn main_task(spawner: Spawner) { uart_config.data_bits = embassy_stm32::usart::DataBits::DataBits8; } - let uart = BufferedUart::new(uart, Irqs, rx_pin, tx_pin, tx_buf, rx_buf, uart_config); + let uart = BufferedUart::new( + uart, + Irqs, + rx_pin, + tx_pin, + tx_buf.init([0u8; 16]), + rx_buf.init([0u8; 16]), + uart_config, + ); let (writer, reader) = uart.unwrap().split(); // let power = Output::new(p.PJ4, Level::High, Speed::VeryHigh).degrade(); // let reset = Output::new(p.PF8, Level::High, Speed::VeryHigh).degrade(); @@ -138,14 +147,24 @@ async fn main_task(spawner: Spawner) { &RES_SLOT, &URC_CHANNEL, ); - let buf = static_cell::make_static!([0; 1024]); - let mut client = Client::new(writer, &RES_SLOT, buf, atat::Config::default()); + static buf: StaticCell<[u8; INGRESS_BUF_SIZE]> = StaticCell::new(); + let mut client = Client::new( + writer, + &RES_SLOT, + buf.init([0; INGRESS_BUF_SIZE]), + atat::Config::default(), + ); spawner.spawn(ingress_task(ingress, reader)).unwrap(); - let state = make_static!(State::new(client)); - let (device, mut control, mut runner) = - ublox_cellular::asynch::new(state, &URC_CHANNEL, celullar_config).await; + static state: StaticCell, INGRESS_BUF_SIZE>>> = + StaticCell::new(); + let (device, mut control, mut runner) = ublox_cellular::asynch::new( + state.init(State::new(client)), + &URC_CHANNEL, + celullar_config, + ) + .await; // defmt::info!("{:?}", runner.init().await); // control.set_desired_state(PowerState::Connected).await; @@ -165,7 +184,6 @@ async fn main_task(spawner: Spawner) { } Timer::after(Duration::from_millis(5000)).await; } - defmt::unwrap!(spawner.spawn(cellular_task(runner))); loop { Timer::after(Duration::from_millis(1000)).await; diff --git a/src/lib.rs b/src/lib.rs index c34fb44..312a885 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ #![cfg_attr(not(test), no_std)] #![cfg_attr(feature = "async", allow(incomplete_features))] -#![cfg_attr(feature = "async", feature(generic_const_exprs))] -#![cfg_attr(feature = "async", feature(async_fn_in_trait))] -#![cfg_attr(feature = "async", feature(type_alias_impl_trait))] +// #![cfg_attr(feature = "async", feature(generic_const_exprs))] +// #![cfg_attr(feature = "async", feature(async_fn_in_trait))] +// #![cfg_attr(feature = "async", feature(type_alias_impl_trait))] // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt;