aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/mcxa/src/bin/clkout.rs84
-rw-r--r--examples/rp/src/bin/usb_webusb.rs11
-rw-r--r--examples/stm32wb/Cargo.toml4
-rw-r--r--examples/stm32wb/src/bin/blinky.rs2
-rw-r--r--examples/stm32wb/src/bin/button_exti.rs2
-rw-r--r--examples/stm32wb/src/bin/eddystone_beacon.rs2
-rw-r--r--examples/stm32wb/src/bin/gatt_server.rs2
-rw-r--r--examples/stm32wb/src/bin/mac_ffd.rs2
-rw-r--r--examples/stm32wb/src/bin/mac_ffd_net.rs2
-rw-r--r--examples/stm32wb/src/bin/mac_rfd.rs2
-rw-r--r--examples/stm32wb/src/bin/tl_mbox.rs2
-rw-r--r--examples/stm32wb/src/bin/tl_mbox_ble.rs2
-rw-r--r--examples/stm32wb/src/bin/tl_mbox_mac.rs2
13 files changed, 66 insertions, 53 deletions
diff --git a/examples/mcxa/src/bin/clkout.rs b/examples/mcxa/src/bin/clkout.rs
index 1e52912d3..e6e6a2d3d 100644
--- a/examples/mcxa/src/bin/clkout.rs
+++ b/examples/mcxa/src/bin/clkout.rs
@@ -4,6 +4,7 @@
4use embassy_executor::Spawner; 4use embassy_executor::Spawner;
5use embassy_mcxa::clkout::{ClockOut, ClockOutSel, Config, Div4}; 5use embassy_mcxa::clkout::{ClockOut, ClockOutSel, Config, Div4};
6use embassy_mcxa::clocks::PoweredClock; 6use embassy_mcxa::clocks::PoweredClock;
7use embassy_mcxa::clocks::config::{SoscConfig, SoscMode};
7use embassy_mcxa::gpio::{DriveStrength, Level, Output, SlewRate}; 8use embassy_mcxa::gpio::{DriveStrength, Level, Output, SlewRate};
8use embassy_time::Timer; 9use embassy_time::Timer;
9use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; 10use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _};
@@ -11,58 +12,61 @@ use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _};
11/// Demonstrate CLKOUT, using Pin P4.2 12/// Demonstrate CLKOUT, using Pin P4.2
12#[embassy_executor::main] 13#[embassy_executor::main]
13async fn main(_spawner: Spawner) { 14async fn main(_spawner: Spawner) {
14 let p = hal::init(hal::config::Config::default()); 15 let mut cfg = hal::config::Config::default();
16 cfg.clock_cfg.sosc = Some(SoscConfig {
17 mode: SoscMode::CrystalOscillator,
18 frequency: 8_000_000,
19 power: PoweredClock::NormalEnabledDeepSleepDisabled,
20 });
21
22 let p = hal::init(cfg);
23
15 let mut pin = p.P4_2; 24 let mut pin = p.P4_2;
16 let mut clkout = p.CLKOUT; 25 let mut clkout = p.CLKOUT;
17 26
18 loop { 27 const K16_CONFIG: Config = Config {
19 defmt::info!("Set Low..."); 28 sel: ClockOutSel::Clk16K,
20 let mut output = Output::new(pin.reborrow(), Level::Low, DriveStrength::Normal, SlewRate::Slow); 29 div: Div4::no_div(),
21 Timer::after_millis(500).await; 30 level: PoweredClock::NormalEnabledDeepSleepDisabled,
31 };
32 const M4_CONFIG: Config = Config {
33 sel: ClockOutSel::Fro12M,
34 div: const { Div4::from_divisor(3).unwrap() },
35 level: PoweredClock::NormalEnabledDeepSleepDisabled,
36 };
37 const K512_CONFIG: Config = Config {
38 sel: ClockOutSel::ClkIn,
39 div: const { Div4::from_divisor(16).unwrap() },
40 level: PoweredClock::NormalEnabledDeepSleepDisabled,
41 };
22 42
43 let configs = [
44 ("16K -> /1 = 16K", K16_CONFIG),
45 ("12M -> /3 = 4M", M4_CONFIG),
46 ("8M -> /16 = 512K", K512_CONFIG),
47 ];
48
49 loop {
23 defmt::info!("Set High..."); 50 defmt::info!("Set High...");
24 output.set_high(); 51 let mut output = Output::new(pin.reborrow(), Level::High, DriveStrength::Normal, SlewRate::Slow);
25 Timer::after_millis(400).await; 52 Timer::after_millis(250).await;
26 53
27 defmt::info!("Set Low..."); 54 defmt::info!("Set Low...");
28 output.set_low(); 55 output.set_low();
29 Timer::after_millis(500).await; 56 Timer::after_millis(750).await;
30 57
31 defmt::info!("16k..."); 58 for (name, conf) in configs.iter() {
32 // Run Clock Out with the 16K clock 59 defmt::info!("Running {=str}", name);
33 let _clock_out = ClockOut::new(
34 clkout.reborrow(),
35 pin.reborrow(),
36 Config {
37 sel: ClockOutSel::Clk16K,
38 div: Div4::no_div(),
39 level: PoweredClock::NormalEnabledDeepSleepDisabled,
40 },
41 )
42 .unwrap();
43 60
44 Timer::after_millis(3000).await; 61 let _clock_out = ClockOut::new(clkout.reborrow(), pin.reborrow(), *conf).unwrap();
45
46 defmt::info!("Set Low...");
47 drop(_clock_out);
48 62
49 let _output = Output::new(pin.reborrow(), Level::Low, DriveStrength::Normal, SlewRate::Slow); 63 Timer::after_millis(3000).await;
50 Timer::after_millis(500).await;
51 64
52 // Run Clock Out with the 12M clock, divided by 3 65 defmt::info!("Set Low...");
53 defmt::info!("4M..."); 66 drop(_clock_out);
54 let _clock_out = ClockOut::new(
55 clkout.reborrow(),
56 pin.reborrow(),
57 Config {
58 sel: ClockOutSel::Fro12M,
59 div: const { Div4::from_divisor(3).unwrap() },
60 level: PoweredClock::NormalEnabledDeepSleepDisabled,
61 },
62 )
63 .unwrap();
64 67
65 // Let it run for 3 seconds... 68 let _output = Output::new(pin.reborrow(), Level::Low, DriveStrength::Normal, SlewRate::Slow);
66 Timer::after_millis(3000).await; 69 Timer::after_millis(500).await;
70 }
67 } 71 }
68} 72}
diff --git a/examples/rp/src/bin/usb_webusb.rs b/examples/rp/src/bin/usb_webusb.rs
index 5cecb92f0..edc9a0c52 100644
--- a/examples/rp/src/bin/usb_webusb.rs
+++ b/examples/rp/src/bin/usb_webusb.rs
@@ -26,6 +26,7 @@ use embassy_rp::usb::{Driver as UsbDriver, InterruptHandler};
26use embassy_usb::class::web_usb::{Config as WebUsbConfig, State, Url, WebUsb}; 26use embassy_usb::class::web_usb::{Config as WebUsbConfig, State, Url, WebUsb};
27use embassy_usb::driver::{Driver, Endpoint, EndpointIn, EndpointOut}; 27use embassy_usb::driver::{Driver, Endpoint, EndpointIn, EndpointOut};
28use embassy_usb::msos::{self, windows_version}; 28use embassy_usb::msos::{self, windows_version};
29use embassy_usb::types::InterfaceNumber;
29use embassy_usb::{Builder, Config}; 30use embassy_usb::{Builder, Config};
30use {defmt_rtt as _, panic_probe as _}; 31use {defmt_rtt as _, panic_probe as _};
31 32
@@ -56,7 +57,7 @@ async fn main(_spawner: Spawner) {
56 let mut config_descriptor = [0; 256]; 57 let mut config_descriptor = [0; 256];
57 let mut bos_descriptor = [0; 256]; 58 let mut bos_descriptor = [0; 256];
58 let mut control_buf = [0; 64]; 59 let mut control_buf = [0; 64];
59 let mut msos_descriptor = [0; 256]; 60 let mut msos_descriptor = [0; 512];
60 61
61 let webusb_config = WebUsbConfig { 62 let webusb_config = WebUsbConfig {
62 max_packet_size: 64, 63 max_packet_size: 64,
@@ -83,6 +84,14 @@ async fn main(_spawner: Spawner) {
83 // In principle you might want to call msos_feature() just on a specific function, 84 // In principle you might want to call msos_feature() just on a specific function,
84 // if your device also has other functions that still use standard class drivers. 85 // if your device also has other functions that still use standard class drivers.
85 builder.msos_descriptor(windows_version::WIN8_1, 0); 86 builder.msos_descriptor(windows_version::WIN8_1, 0);
87 builder.msos_writer().configuration(0);
88 builder.msos_writer().function(InterfaceNumber(0));
89 builder.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", ""));
90 builder.msos_feature(msos::RegistryPropertyFeatureDescriptor::new(
91 "DeviceInterfaceGUIDs",
92 msos::PropertyData::RegMultiSz(DEVICE_INTERFACE_GUIDS),
93 ));
94 builder.msos_writer().function(InterfaceNumber(1));
86 builder.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", "")); 95 builder.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", ""));
87 builder.msos_feature(msos::RegistryPropertyFeatureDescriptor::new( 96 builder.msos_feature(msos::RegistryPropertyFeatureDescriptor::new(
88 "DeviceInterfaceGUIDs", 97 "DeviceInterfaceGUIDs",
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml
index 83f7cb56b..496500f75 100644
--- a/examples/stm32wb/Cargo.toml
+++ b/examples/stm32wb/Cargo.toml
@@ -7,10 +7,10 @@ publish = false
7 7
8[dependencies] 8[dependencies]
9# Change stm32wb55rg to your chip name in both dependencies, if necessary. 9# Change stm32wb55rg to your chip name in both dependencies, if necessary.
10embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti", "low-power"] } 10embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti", "low-power-pender"] }
11embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } 11embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] }
12embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } 12embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] }
13embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 13embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["defmt"] }
14embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 14embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
15embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional = true } 15embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional = true }
16 16
diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs
index f37e8b1d8..e2737fcd5 100644
--- a/examples/stm32wb/src/bin/blinky.rs
+++ b/examples/stm32wb/src/bin/blinky.rs
@@ -7,7 +7,7 @@ use embassy_stm32::gpio::{Level, Output, Speed};
7use embassy_time::Timer; 7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 8use {defmt_rtt as _, panic_probe as _};
9 9
10#[embassy_executor::main] 10#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
11async fn main(_spawner: Spawner) { 11async fn main(_spawner: Spawner) {
12 let p = embassy_stm32::init(Default::default()); 12 let p = embassy_stm32::init(Default::default());
13 info!("Hello World!"); 13 info!("Hello World!");
diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs
index 3c58eb556..37a207519 100644
--- a/examples/stm32wb/src/bin/button_exti.rs
+++ b/examples/stm32wb/src/bin/button_exti.rs
@@ -13,7 +13,7 @@ bind_interrupts!(
13 EXTI4 => exti::InterruptHandler<interrupt::typelevel::EXTI4>; 13 EXTI4 => exti::InterruptHandler<interrupt::typelevel::EXTI4>;
14}); 14});
15 15
16#[embassy_executor::main] 16#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let p = embassy_stm32::init(Default::default()); 18 let p = embassy_stm32::init(Default::default());
19 info!("Hello World!"); 19 info!("Hello World!");
diff --git a/examples/stm32wb/src/bin/eddystone_beacon.rs b/examples/stm32wb/src/bin/eddystone_beacon.rs
index 413b1ac8f..a679e6fb1 100644
--- a/examples/stm32wb/src/bin/eddystone_beacon.rs
+++ b/examples/stm32wb/src/bin/eddystone_beacon.rs
@@ -26,7 +26,7 @@ bind_interrupts!(struct Irqs{
26 26
27const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7; 27const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7;
28 28
29#[embassy_executor::main] 29#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
30async fn main(_spawner: Spawner) { 30async fn main(_spawner: Spawner) {
31 /* 31 /*
32 How to make this work: 32 How to make this work:
diff --git a/examples/stm32wb/src/bin/gatt_server.rs b/examples/stm32wb/src/bin/gatt_server.rs
index 3484f1844..10c7fd0ba 100644
--- a/examples/stm32wb/src/bin/gatt_server.rs
+++ b/examples/stm32wb/src/bin/gatt_server.rs
@@ -38,7 +38,7 @@ bind_interrupts!(struct Irqs{
38 38
39const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7; 39const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7;
40 40
41#[embassy_executor::main] 41#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
42async fn main(spawner: Spawner) { 42async fn main(spawner: Spawner) {
43 /* 43 /*
44 How to make this work: 44 How to make this work:
diff --git a/examples/stm32wb/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs
index 4bab6ea9f..cd15968d2 100644
--- a/examples/stm32wb/src/bin/mac_ffd.rs
+++ b/examples/stm32wb/src/bin/mac_ffd.rs
@@ -23,7 +23,7 @@ async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
23 memory_manager.run_queue().await; 23 memory_manager.run_queue().await;
24} 24}
25 25
26#[embassy_executor::main] 26#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
27async fn main(spawner: Spawner) { 27async fn main(spawner: Spawner) {
28 /* 28 /*
29 How to make this work: 29 How to make this work:
diff --git a/examples/stm32wb/src/bin/mac_ffd_net.rs b/examples/stm32wb/src/bin/mac_ffd_net.rs
index b4789e3ee..244b35243 100644
--- a/examples/stm32wb/src/bin/mac_ffd_net.rs
+++ b/examples/stm32wb/src/bin/mac_ffd_net.rs
@@ -41,7 +41,7 @@ async fn run_net(mut runner: embassy_net::Runner<'static, Driver<'static>>) -> !
41 runner.run().await 41 runner.run().await
42} 42}
43 43
44#[embassy_executor::main] 44#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
45async fn main(spawner: Spawner) { 45async fn main(spawner: Spawner) {
46 /* 46 /*
47 How to make this work: 47 How to make this work:
diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs
index dae3c5200..f3e65c66b 100644
--- a/examples/stm32wb/src/bin/mac_rfd.rs
+++ b/examples/stm32wb/src/bin/mac_rfd.rs
@@ -25,7 +25,7 @@ async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
25 memory_manager.run_queue().await; 25 memory_manager.run_queue().await;
26} 26}
27 27
28#[embassy_executor::main] 28#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
29async fn main(spawner: Spawner) { 29async fn main(spawner: Spawner) {
30 /* 30 /*
31 How to make this work: 31 How to make this work:
diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs
index 0902e28e8..adb6eff7b 100644
--- a/examples/stm32wb/src/bin/tl_mbox.rs
+++ b/examples/stm32wb/src/bin/tl_mbox.rs
@@ -15,7 +15,7 @@ bind_interrupts!(struct Irqs{
15 IPCC_C1_TX => TransmitInterruptHandler; 15 IPCC_C1_TX => TransmitInterruptHandler;
16}); 16});
17 17
18#[embassy_executor::main] 18#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
19async fn main(_spawner: Spawner) { 19async fn main(_spawner: Spawner) {
20 /* 20 /*
21 How to make this work: 21 How to make this work:
diff --git a/examples/stm32wb/src/bin/tl_mbox_ble.rs b/examples/stm32wb/src/bin/tl_mbox_ble.rs
index 763dc32cd..376b808de 100644
--- a/examples/stm32wb/src/bin/tl_mbox_ble.rs
+++ b/examples/stm32wb/src/bin/tl_mbox_ble.rs
@@ -20,7 +20,7 @@ async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
20 memory_manager.run_queue().await; 20 memory_manager.run_queue().await;
21} 21}
22 22
23#[embassy_executor::main] 23#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
24async fn main(spawner: Spawner) { 24async fn main(spawner: Spawner) {
25 /* 25 /*
26 How to make this work: 26 How to make this work:
diff --git a/examples/stm32wb/src/bin/tl_mbox_mac.rs b/examples/stm32wb/src/bin/tl_mbox_mac.rs
index 235a48241..697e061c1 100644
--- a/examples/stm32wb/src/bin/tl_mbox_mac.rs
+++ b/examples/stm32wb/src/bin/tl_mbox_mac.rs
@@ -20,7 +20,7 @@ async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
20 memory_manager.run_queue().await; 20 memory_manager.run_queue().await;
21} 21}
22 22
23#[embassy_executor::main] 23#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
24async fn main(spawner: Spawner) { 24async fn main(spawner: Spawner) {
25 /* 25 /*
26 How to make this work: 26 How to make this work: