aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBailey Townsend <[email protected]>2024-12-28 00:07:14 -0600
committerBailey Townsend <[email protected]>2024-12-28 00:07:14 -0600
commit8243a8a3892dc499be560a0bf2134e641b856760 (patch)
treed7e2d8d7371c4672879a9dfbb1219529d5ea5c29 /examples
parentdd31ffadfbd145f26b6bb54cf2036cb54149aefe (diff)
Added new param to examples and created a pico plus 2 w example
Diffstat (limited to 'examples')
-rw-r--r--examples/rp/src/bin/wifi_ap_tcp_server.rs13
-rw-r--r--examples/rp/src/bin/wifi_blinky.rs13
-rw-r--r--examples/rp/src/bin/wifi_scan.rs13
-rw-r--r--examples/rp/src/bin/wifi_tcp_server.rs13
-rw-r--r--examples/rp/src/bin/wifi_webrequest.rs13
-rw-r--r--examples/rp23/src/bin/wifi_blinky_pico_plus_2.rs94
6 files changed, 149 insertions, 10 deletions
diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs
index 4c9651433..e97ddb4c1 100644
--- a/examples/rp/src/bin/wifi_ap_tcp_server.rs
+++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs
@@ -7,7 +7,7 @@
7 7
8use core::str::from_utf8; 8use core::str::from_utf8;
9 9
10use cyw43_pio::PioSpi; 10use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER};
11use defmt::*; 11use defmt::*;
12use embassy_executor::Spawner; 12use embassy_executor::Spawner;
13use embassy_net::tcp::TcpSocket; 13use embassy_net::tcp::TcpSocket;
@@ -57,7 +57,16 @@ async fn main(spawner: Spawner) {
57 let pwr = Output::new(p.PIN_23, Level::Low); 57 let pwr = Output::new(p.PIN_23, Level::Low);
58 let cs = Output::new(p.PIN_25, Level::High); 58 let cs = Output::new(p.PIN_25, Level::High);
59 let mut pio = Pio::new(p.PIO0, Irqs); 59 let mut pio = Pio::new(p.PIO0, Irqs);
60 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); 60 let spi = PioSpi::new(
61 &mut pio.common,
62 pio.sm0,
63 DEFAULT_CLOCK_DIVIDER,
64 pio.irq0,
65 cs,
66 p.PIN_24,
67 p.PIN_29,
68 p.DMA_CH0,
69 );
61 70
62 static STATE: StaticCell<cyw43::State> = StaticCell::new(); 71 static STATE: StaticCell<cyw43::State> = StaticCell::new();
63 let state = STATE.init(cyw43::State::new()); 72 let state = STATE.init(cyw43::State::new());
diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs
index 0107a2326..6e91ce167 100644
--- a/examples/rp/src/bin/wifi_blinky.rs
+++ b/examples/rp/src/bin/wifi_blinky.rs
@@ -5,7 +5,7 @@
5#![no_std] 5#![no_std]
6#![no_main] 6#![no_main]
7 7
8use cyw43_pio::PioSpi; 8use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER};
9use defmt::*; 9use defmt::*;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_rp::bind_interrupts; 11use embassy_rp::bind_interrupts;
@@ -41,7 +41,16 @@ async fn main(spawner: Spawner) {
41 let pwr = Output::new(p.PIN_23, Level::Low); 41 let pwr = Output::new(p.PIN_23, Level::Low);
42 let cs = Output::new(p.PIN_25, Level::High); 42 let cs = Output::new(p.PIN_25, Level::High);
43 let mut pio = Pio::new(p.PIO0, Irqs); 43 let mut pio = Pio::new(p.PIO0, Irqs);
44 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); 44 let spi = PioSpi::new(
45 &mut pio.common,
46 pio.sm0,
47 DEFAULT_CLOCK_DIVIDER,
48 pio.irq0,
49 cs,
50 p.PIN_24,
51 p.PIN_29,
52 p.DMA_CH0,
53 );
45 54
46 static STATE: StaticCell<cyw43::State> = StaticCell::new(); 55 static STATE: StaticCell<cyw43::State> = StaticCell::new();
47 let state = STATE.init(cyw43::State::new()); 56 let state = STATE.init(cyw43::State::new());
diff --git a/examples/rp/src/bin/wifi_scan.rs b/examples/rp/src/bin/wifi_scan.rs
index 2ef899080..fe9c363d9 100644
--- a/examples/rp/src/bin/wifi_scan.rs
+++ b/examples/rp/src/bin/wifi_scan.rs
@@ -7,7 +7,7 @@
7 7
8use core::str; 8use core::str;
9 9
10use cyw43_pio::PioSpi; 10use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER};
11use defmt::*; 11use defmt::*;
12use embassy_executor::Spawner; 12use embassy_executor::Spawner;
13use embassy_rp::bind_interrupts; 13use embassy_rp::bind_interrupts;
@@ -45,7 +45,16 @@ async fn main(spawner: Spawner) {
45 let pwr = Output::new(p.PIN_23, Level::Low); 45 let pwr = Output::new(p.PIN_23, Level::Low);
46 let cs = Output::new(p.PIN_25, Level::High); 46 let cs = Output::new(p.PIN_25, Level::High);
47 let mut pio = Pio::new(p.PIO0, Irqs); 47 let mut pio = Pio::new(p.PIO0, Irqs);
48 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); 48 let spi = PioSpi::new(
49 &mut pio.common,
50 pio.sm0,
51 DEFAULT_CLOCK_DIVIDER,
52 pio.irq0,
53 cs,
54 p.PIN_24,
55 p.PIN_29,
56 p.DMA_CH0,
57 );
49 58
50 static STATE: StaticCell<cyw43::State> = StaticCell::new(); 59 static STATE: StaticCell<cyw43::State> = StaticCell::new();
51 let state = STATE.init(cyw43::State::new()); 60 let state = STATE.init(cyw43::State::new());
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs
index 7bf546e01..14dbf4552 100644
--- a/examples/rp/src/bin/wifi_tcp_server.rs
+++ b/examples/rp/src/bin/wifi_tcp_server.rs
@@ -8,7 +8,7 @@
8use core::str::from_utf8; 8use core::str::from_utf8;
9 9
10use cyw43::JoinOptions; 10use cyw43::JoinOptions;
11use cyw43_pio::PioSpi; 11use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER};
12use defmt::*; 12use defmt::*;
13use embassy_executor::Spawner; 13use embassy_executor::Spawner;
14use embassy_net::tcp::TcpSocket; 14use embassy_net::tcp::TcpSocket;
@@ -61,7 +61,16 @@ async fn main(spawner: Spawner) {
61 let pwr = Output::new(p.PIN_23, Level::Low); 61 let pwr = Output::new(p.PIN_23, Level::Low);
62 let cs = Output::new(p.PIN_25, Level::High); 62 let cs = Output::new(p.PIN_25, Level::High);
63 let mut pio = Pio::new(p.PIO0, Irqs); 63 let mut pio = Pio::new(p.PIO0, Irqs);
64 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); 64 let spi = PioSpi::new(
65 &mut pio.common,
66 pio.sm0,
67 DEFAULT_CLOCK_DIVIDER,
68 pio.irq0,
69 cs,
70 p.PIN_24,
71 p.PIN_29,
72 p.DMA_CH0,
73 );
65 74
66 static STATE: StaticCell<cyw43::State> = StaticCell::new(); 75 static STATE: StaticCell<cyw43::State> = StaticCell::new();
67 let state = STATE.init(cyw43::State::new()); 76 let state = STATE.init(cyw43::State::new());
diff --git a/examples/rp/src/bin/wifi_webrequest.rs b/examples/rp/src/bin/wifi_webrequest.rs
index 1ae909917..f1b398b65 100644
--- a/examples/rp/src/bin/wifi_webrequest.rs
+++ b/examples/rp/src/bin/wifi_webrequest.rs
@@ -8,7 +8,7 @@
8use core::str::from_utf8; 8use core::str::from_utf8;
9 9
10use cyw43::JoinOptions; 10use cyw43::JoinOptions;
11use cyw43_pio::PioSpi; 11use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER};
12use defmt::*; 12use defmt::*;
13use embassy_executor::Spawner; 13use embassy_executor::Spawner;
14use embassy_net::dns::DnsSocket; 14use embassy_net::dns::DnsSocket;
@@ -63,7 +63,16 @@ async fn main(spawner: Spawner) {
63 let pwr = Output::new(p.PIN_23, Level::Low); 63 let pwr = Output::new(p.PIN_23, Level::Low);
64 let cs = Output::new(p.PIN_25, Level::High); 64 let cs = Output::new(p.PIN_25, Level::High);
65 let mut pio = Pio::new(p.PIO0, Irqs); 65 let mut pio = Pio::new(p.PIO0, Irqs);
66 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); 66 let spi = PioSpi::new(
67 &mut pio.common,
68 pio.sm0,
69 DEFAULT_CLOCK_DIVIDER,
70 pio.irq0,
71 cs,
72 p.PIN_24,
73 p.PIN_29,
74 p.DMA_CH0,
75 );
67 76
68 static STATE: StaticCell<cyw43::State> = StaticCell::new(); 77 static STATE: StaticCell<cyw43::State> = StaticCell::new();
69 let state = STATE.init(cyw43::State::new()); 78 let state = STATE.init(cyw43::State::new());
diff --git a/examples/rp23/src/bin/wifi_blinky_pico_plus_2.rs b/examples/rp23/src/bin/wifi_blinky_pico_plus_2.rs
new file mode 100644
index 000000000..240588762
--- /dev/null
+++ b/examples/rp23/src/bin/wifi_blinky_pico_plus_2.rs
@@ -0,0 +1,94 @@
1//! This example test the Pimoroni Pico Plus 2 on board LED.
2//!
3//! It does not work with the RP Pico board. See blinky.rs.
4
5#![no_std]
6#![no_main]
7
8use cyw43_pio::{PioSpi, RM2_CLOCK_DIVIDER};
9use defmt::*;
10use embassy_executor::Spawner;
11use embassy_rp::block::ImageDef;
12use embassy_rp::gpio;
13use embassy_rp::peripherals::{DMA_CH0, PIO0};
14use embassy_rp::pio::Pio;
15use embassy_rp::{bind_interrupts, pio::InterruptHandler};
16use embassy_time::{Duration, Timer};
17use gpio::{Level, Output};
18use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _};
20
21#[link_section = ".start_block"]
22#[used]
23pub static IMAGE_DEF: ImageDef = ImageDef::secure_exe();
24
25// Program metadata for `picotool info`.
26// This isn't needed, but it's recomended to have these minimal entries.
27#[link_section = ".bi_entries"]
28#[used]
29pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
30 embassy_rp::binary_info::rp_program_name!(c"Blinky Example"),
31 embassy_rp::binary_info::rp_program_description!(
32 c"This example tests the RP Pico on board LED, connected to gpio 25"
33 ),
34 embassy_rp::binary_info::rp_cargo_version!(),
35 embassy_rp::binary_info::rp_program_build_attribute!(),
36];
37
38bind_interrupts!(struct Irqs {
39 PIO0_IRQ_0 => InterruptHandler<PIO0>;
40});
41
42#[embassy_executor::task]
43async fn cyw43_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! {
44 runner.run().await
45}
46
47#[embassy_executor::main]
48async fn main(spawner: Spawner) {
49 let p = embassy_rp::init(Default::default());
50 let fw = include_bytes!("../../../../cyw43-firmware/43439A0.bin");
51 let clm = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin");
52
53 // To make flashing faster for development, you may want to flash the firmwares independently
54 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`:
55 // probe-rs download ../../cyw43-firmware/43439A0.bin --binary-format bin --chip RP2040 --base-address 0x10100000
56 // probe-rs download ../../cyw43-firmware/43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x10140000
57 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
58 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
59
60 let pwr = Output::new(p.PIN_23, Level::Low);
61 let cs = Output::new(p.PIN_25, Level::High);
62 let mut pio = Pio::new(p.PIO0, Irqs);
63 let spi = PioSpi::new(
64 &mut pio.common,
65 pio.sm0,
66 RM2_CLOCK_DIVIDER,
67 pio.irq0,
68 cs,
69 p.PIN_24,
70 p.PIN_29,
71 p.DMA_CH0,
72 );
73
74 static STATE: StaticCell<cyw43::State> = StaticCell::new();
75 let state = STATE.init(cyw43::State::new());
76 let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
77 unwrap!(spawner.spawn(cyw43_task(runner)));
78
79 control.init(clm).await;
80 control
81 .set_power_management(cyw43::PowerManagementMode::PowerSave)
82 .await;
83
84 let delay = Duration::from_secs(1);
85 loop {
86 info!("led on!");
87 control.gpio_set(0, true).await;
88 Timer::after(delay).await;
89
90 info!("led off!");
91 control.gpio_set(0, false).await;
92 Timer::after(delay).await;
93 }
94}