diff options
| author | Gerzain Mata <[email protected]> | 2025-07-27 15:57:55 -0700 |
|---|---|---|
| committer | Gerzain Mata <[email protected]> | 2025-07-27 16:40:25 -0700 |
| commit | 00f94972d7293b946e4bf7de2722ea55dca6b0db (patch) | |
| tree | cf371c517ac02218aabfd3dae20960440d353fc9 | |
| parent | 1d3c48cf4539fe1959f25918a6fa3521a5678837 (diff) | |
| parent | 4e4a1c0054fe1245426798166b3bf51e8a0300d3 (diff) | |
Merge branch 'main' into feat/stm32wba-usb-example
| -rwxr-xr-x | .github/ci/book.sh | 2 | ||||
| -rwxr-xr-x | .github/ci/doc.sh | 1 | ||||
| -rw-r--r-- | embassy-net/src/lib.rs | 6 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_tcp_server.rs | 27 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_webrequest.rs | 33 | ||||
| -rw-r--r-- | examples/stm32wba/.cargo/config.toml | 2 | ||||
| -rw-r--r-- | examples/stm32wba/Cargo.toml | 7 | ||||
| -rw-r--r-- | examples/stm32wba/src/bin/pwm.rs | 10 |
8 files changed, 37 insertions, 51 deletions
diff --git a/.github/ci/book.sh b/.github/ci/book.sh index c91d10d16..dada4b348 100755 --- a/.github/ci/book.sh +++ b/.github/ci/book.sh | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | ## on push branch=main | 2 | ## on push branch=main |
| 3 | ## priority -100 | 3 | ## priority -100 |
| 4 | ## dedup dequeue | 4 | ## dedup dequeue |
| 5 | ## cooldown 15m | ||
| 5 | 6 | ||
| 6 | set -euxo pipefail | 7 | set -euxo pipefail |
| 7 | 8 | ||
| @@ -17,3 +18,4 @@ kubectl exec $POD -- mkdir -p /usr/share/nginx/html | |||
| 17 | kubectl cp book.tar $POD:/usr/share/nginx/html/ | 18 | kubectl cp book.tar $POD:/usr/share/nginx/html/ |
| 18 | kubectl exec $POD -- find /usr/share/nginx/html | 19 | kubectl exec $POD -- find /usr/share/nginx/html |
| 19 | kubectl exec $POD -- tar -C /usr/share/nginx/html -xvf /usr/share/nginx/html/book.tar | 20 | kubectl exec $POD -- tar -C /usr/share/nginx/html -xvf /usr/share/nginx/html/book.tar |
| 21 | 3 | ||
diff --git a/.github/ci/doc.sh b/.github/ci/doc.sh index 26971afdc..ac96008d8 100755 --- a/.github/ci/doc.sh +++ b/.github/ci/doc.sh | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | ## on push branch=main | 2 | ## on push branch=main |
| 3 | ## priority -100 | 3 | ## priority -100 |
| 4 | ## dedup dequeue | 4 | ## dedup dequeue |
| 5 | ## cooldown 15m | ||
| 5 | 6 | ||
| 6 | set -euxo pipefail | 7 | set -euxo pipefail |
| 7 | 8 | ||
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 2b1888170..0bc6ffe6c 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -171,7 +171,7 @@ impl Default for DhcpConfig { | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | /// Network stack configuration. | 173 | /// Network stack configuration. |
| 174 | #[derive(Debug, Clone, Default)] | 174 | #[derive(Debug, Clone, Default, PartialEq, Eq)] |
| 175 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 175 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 176 | #[non_exhaustive] | 176 | #[non_exhaustive] |
| 177 | pub struct Config { | 177 | pub struct Config { |
| @@ -223,7 +223,7 @@ impl Config { | |||
| 223 | 223 | ||
| 224 | /// Network stack IPv4 configuration. | 224 | /// Network stack IPv4 configuration. |
| 225 | #[cfg(feature = "proto-ipv4")] | 225 | #[cfg(feature = "proto-ipv4")] |
| 226 | #[derive(Debug, Clone, Default)] | 226 | #[derive(Debug, Clone, Default, PartialEq, Eq)] |
| 227 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 227 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 228 | pub enum ConfigV4 { | 228 | pub enum ConfigV4 { |
| 229 | /// Do not configure IPv4. | 229 | /// Do not configure IPv4. |
| @@ -238,7 +238,7 @@ pub enum ConfigV4 { | |||
| 238 | 238 | ||
| 239 | /// Network stack IPv6 configuration. | 239 | /// Network stack IPv6 configuration. |
| 240 | #[cfg(feature = "proto-ipv6")] | 240 | #[cfg(feature = "proto-ipv6")] |
| 241 | #[derive(Debug, Clone, Default)] | 241 | #[derive(Debug, Clone, Default, PartialEq, Eq)] |
| 242 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 242 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 243 | pub enum ConfigV6 { | 243 | pub enum ConfigV6 { |
| 244 | /// Do not configure IPv6. | 244 | /// Do not configure IPv6. |
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index fbc957e0e..ed1a03fcf 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -18,7 +18,7 @@ use embassy_rp::clocks::RoscRng; | |||
| 18 | use embassy_rp::gpio::{Level, Output}; | 18 | use embassy_rp::gpio::{Level, Output}; |
| 19 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; | 19 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; |
| 20 | use embassy_rp::pio::{InterruptHandler, Pio}; | 20 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 21 | use embassy_time::{Duration, Timer}; | 21 | use embassy_time::Duration; |
| 22 | use embedded_io_async::Write; | 22 | use embedded_io_async::Write; |
| 23 | use static_cell::StaticCell; | 23 | use static_cell::StaticCell; |
| 24 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -97,26 +97,21 @@ async fn main(spawner: Spawner) { | |||
| 97 | 97 | ||
| 98 | unwrap!(spawner.spawn(net_task(runner))); | 98 | unwrap!(spawner.spawn(net_task(runner))); |
| 99 | 99 | ||
| 100 | loop { | 100 | while let Err(err) = control |
| 101 | match control | 101 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) |
| 102 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) | 102 | .await |
| 103 | .await | 103 | { |
| 104 | { | 104 | info!("join failed with status={}", err.status); |
| 105 | Ok(_) => break, | ||
| 106 | Err(err) => { | ||
| 107 | info!("join failed with status={}", err.status); | ||
| 108 | } | ||
| 109 | } | ||
| 110 | } | 105 | } |
| 111 | 106 | ||
| 112 | // Wait for DHCP, not necessary when using static IP | 107 | info!("waiting for link..."); |
| 108 | stack.wait_link_up().await; | ||
| 109 | |||
| 113 | info!("waiting for DHCP..."); | 110 | info!("waiting for DHCP..."); |
| 114 | while !stack.is_config_up() { | 111 | stack.wait_config_up().await; |
| 115 | Timer::after_millis(100).await; | ||
| 116 | } | ||
| 117 | info!("DHCP is now up!"); | ||
| 118 | 112 | ||
| 119 | // And now we can use it! | 113 | // And now we can use it! |
| 114 | info!("Stack is up!"); | ||
| 120 | 115 | ||
| 121 | let mut rx_buffer = [0; 4096]; | 116 | let mut rx_buffer = [0; 4096]; |
| 122 | let mut tx_buffer = [0; 4096]; | 117 | let mut tx_buffer = [0; 4096]; |
diff --git a/examples/rp/src/bin/wifi_webrequest.rs b/examples/rp/src/bin/wifi_webrequest.rs index 1efd1cd28..a75253bb0 100644 --- a/examples/rp/src/bin/wifi_webrequest.rs +++ b/examples/rp/src/bin/wifi_webrequest.rs | |||
| @@ -100,33 +100,20 @@ async fn main(spawner: Spawner) { | |||
| 100 | 100 | ||
| 101 | unwrap!(spawner.spawn(net_task(runner))); | 101 | unwrap!(spawner.spawn(net_task(runner))); |
| 102 | 102 | ||
| 103 | loop { | 103 | while let Err(err) = control |
| 104 | match control | 104 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) |
| 105 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) | 105 | .await |
| 106 | .await | 106 | { |
| 107 | { | 107 | info!("join failed with status={}", err.status); |
| 108 | Ok(_) => break, | ||
| 109 | Err(err) => { | ||
| 110 | info!("join failed with status={}", err.status); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 | // Wait for DHCP, not necessary when using static IP | ||
| 116 | info!("waiting for DHCP..."); | ||
| 117 | while !stack.is_config_up() { | ||
| 118 | Timer::after_millis(100).await; | ||
| 119 | } | 108 | } |
| 120 | info!("DHCP is now up!"); | ||
| 121 | 109 | ||
| 122 | info!("waiting for link up..."); | 110 | info!("waiting for link..."); |
| 123 | while !stack.is_link_up() { | 111 | stack.wait_link_up().await; |
| 124 | Timer::after_millis(500).await; | ||
| 125 | } | ||
| 126 | info!("Link is up!"); | ||
| 127 | 112 | ||
| 128 | info!("waiting for stack to be up..."); | 113 | info!("waiting for DHCP..."); |
| 129 | stack.wait_config_up().await; | 114 | stack.wait_config_up().await; |
| 115 | |||
| 116 | // And now we can use it! | ||
| 130 | info!("Stack is up!"); | 117 | info!("Stack is up!"); |
| 131 | 118 | ||
| 132 | // And now we can use it! | 119 | // And now we can use it! |
diff --git a/examples/stm32wba/.cargo/config.toml b/examples/stm32wba/.cargo/config.toml index 1896068d8..c96a5cb6c 100644 --- a/examples/stm32wba/.cargo/config.toml +++ b/examples/stm32wba/.cargo/config.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 2 | runner = "probe-rs run --chip STM32WBA65RI" | 2 | runner = "probe-rs run --chip STM32WBA55CGUx" |
| 3 | 3 | ||
| 4 | [build] | 4 | [build] |
| 5 | target = "thumbv8m.main-none-eabihf" | 5 | target = "thumbv8m.main-none-eabihf" |
diff --git a/examples/stm32wba/Cargo.toml b/examples/stm32wba/Cargo.toml index 336ea1e2e..2c638f9f4 100644 --- a/examples/stm32wba/Cargo.toml +++ b/examples/stm32wba/Cargo.toml | |||
| @@ -5,19 +5,18 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wba65ri", "time-driver-any", "memory-x", "exti"] } | 8 | embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wba55cg", "time-driver-any", "memory-x", "exti"] } |
| 9 | embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } | 9 | embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } |
| 10 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } | 10 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } |
| 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 12 | embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] } | 12 | embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional = true } |
| 13 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 14 | 13 | ||
| 15 | defmt = "1.0.1" | 14 | defmt = "1.0.1" |
| 16 | defmt-rtt = "1.0.0" | 15 | defmt-rtt = "1.0.0" |
| 17 | 16 | ||
| 18 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 17 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 18 | cortex-m-rt = "0.7.0" |
| 20 | embedded-hal = "0.2.6" | 19 | embedded-hal = "1.0.0" |
| 21 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } | 20 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } |
| 22 | heapless = { version = "0.8", default-features = false } | 21 | heapless = { version = "0.8", default-features = false } |
| 23 | static_cell = "2" | 22 | static_cell = "2" |
diff --git a/examples/stm32wba/src/bin/pwm.rs b/examples/stm32wba/src/bin/pwm.rs index fc1e0ff2d..de690fda0 100644 --- a/examples/stm32wba/src/bin/pwm.rs +++ b/examples/stm32wba/src/bin/pwm.rs | |||
| @@ -5,8 +5,9 @@ use defmt::*; | |||
| 5 | use defmt_rtt as _; // global logger | 5 | use defmt_rtt as _; // global logger |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::OutputType; | 7 | use embassy_stm32::gpio::OutputType; |
| 8 | use embassy_stm32::rcc::{AHB5Prescaler, AHBPrescaler, APBPrescaler, Sysclk, VoltageScale}; | 8 | use embassy_stm32::rcc::{ |
| 9 | use embassy_stm32::rcc::{PllDiv, PllMul, PllPreDiv, PllSource}; | 9 | AHB5Prescaler, AHBPrescaler, APBPrescaler, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale, |
| 10 | }; | ||
| 10 | use embassy_stm32::time::khz; | 11 | use embassy_stm32::time::khz; |
| 11 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 12 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 12 | use embassy_stm32::Config; | 13 | use embassy_stm32::Config; |
| @@ -38,12 +39,13 @@ async fn main(_spawner: Spawner) { | |||
| 38 | 39 | ||
| 39 | // voltage scale for max performance | 40 | // voltage scale for max performance |
| 40 | config.rcc.voltage_scale = VoltageScale::RANGE1; | 41 | config.rcc.voltage_scale = VoltageScale::RANGE1; |
| 42 | // route PLL1_P into the USB‐OTG‐HS block | ||
| 41 | config.rcc.sys = Sysclk::PLL1_R; | 43 | config.rcc.sys = Sysclk::PLL1_R; |
| 42 | 44 | ||
| 43 | let p = embassy_stm32::init(config); | 45 | let p = embassy_stm32::init(config); |
| 44 | 46 | ||
| 45 | let ch1_pin = PwmPin::new(p.PA2, OutputType::PushPull); | 47 | let ch1_pin = PwmPin::new(p.PB8, OutputType::PushPull); |
| 46 | let mut pwm = SimplePwm::new(p.TIM3, Some(ch1_pin), None, None, None, khz(10), Default::default()); | 48 | let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(10), Default::default()); |
| 47 | let mut ch1 = pwm.ch1(); | 49 | let mut ch1 = pwm.ch1(); |
| 48 | ch1.enable(); | 50 | ch1.enable(); |
| 49 | 51 | ||
