diff options
| author | Bailey Townsend <[email protected]> | 2024-12-28 00:07:14 -0600 |
|---|---|---|
| committer | Bailey Townsend <[email protected]> | 2024-12-28 00:07:14 -0600 |
| commit | 8243a8a3892dc499be560a0bf2134e641b856760 (patch) | |
| tree | d7e2d8d7371c4672879a9dfbb1219529d5ea5c29 /examples/rp23/src | |
| parent | dd31ffadfbd145f26b6bb54cf2036cb54149aefe (diff) | |
Added new param to examples and created a pico plus 2 w example
Diffstat (limited to 'examples/rp23/src')
| -rw-r--r-- | examples/rp23/src/bin/wifi_blinky_pico_plus_2.rs | 94 |
1 files changed, 94 insertions, 0 deletions
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 | |||
| 8 | use cyw43_pio::{PioSpi, RM2_CLOCK_DIVIDER}; | ||
| 9 | use defmt::*; | ||
| 10 | use embassy_executor::Spawner; | ||
| 11 | use embassy_rp::block::ImageDef; | ||
| 12 | use embassy_rp::gpio; | ||
| 13 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; | ||
| 14 | use embassy_rp::pio::Pio; | ||
| 15 | use embassy_rp::{bind_interrupts, pio::InterruptHandler}; | ||
| 16 | use embassy_time::{Duration, Timer}; | ||
| 17 | use gpio::{Level, Output}; | ||
| 18 | use static_cell::StaticCell; | ||
| 19 | use {defmt_rtt as _, panic_probe as _}; | ||
| 20 | |||
| 21 | #[link_section = ".start_block"] | ||
| 22 | #[used] | ||
| 23 | pub 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] | ||
| 29 | pub 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 | |||
| 38 | bind_interrupts!(struct Irqs { | ||
| 39 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 40 | }); | ||
| 41 | |||
| 42 | #[embassy_executor::task] | ||
| 43 | async 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] | ||
| 48 | async 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 | } | ||
