Attepted to switch to the embassy framework
This commit is contained in:
1 parent
a3d5a63a7f
commit
11a8fa7c6d
5 files changed
+57
-53
No files matched your search
+11
-5
@@ -6,17 +6,23 @@ name = "test-cargo"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rp-pico = "0.9.0"
|
|
||||||
cortex-m = "0.7.7"
|
cortex-m = "0.7.7"
|
||||||
cortex-m-rt = "0.7.3"
|
cortex-m-rt = "0.7.3"
|
||||||
cortex-m-semihosting = "0.5.0"
|
|
||||||
panic-halt = "0.2.0"
|
panic-halt = "0.2.0"
|
||||||
rp2040-boot2 = "0.3.0"
|
|
||||||
rp2040-hal = { version = "0.10.2", features = ["rt"] }
|
|
||||||
embedded-time = "0.12.1"
|
|
||||||
defmt = "0.3.8"
|
defmt = "0.3.8"
|
||||||
defmt-rtt = "0.4.1"
|
defmt-rtt = "0.4.1"
|
||||||
embedded-hal = "1.0.0"
|
embedded-hal = "1.0.0"
|
||||||
|
embedded-hal-async = "1.0.0"
|
||||||
|
embedded-io = "0.6.1"
|
||||||
|
embedded-io-async = "0.6.1"
|
||||||
|
embedded-storage = "0.3.1"
|
||||||
|
embassy-rp = { version = "0.2.0", features = [ "defmt", "time-driver", "unstable-pac", "critical-section-impl" ] }
|
||||||
|
embassy-time = { version = "0.3.0", features = [ "defmt", "defmt-timestamp-uptime" ] }
|
||||||
|
embassy-executor = { version = "0.5.0", features = [ "task-arena-size-1024", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers", "executor-interrupt" ] }
|
||||||
|
cyw43 = { version = "=0.1.0", features = [ "defmt", "firmware-logs" ] }
|
||||||
|
cyw43-pio = "0.2.0"
|
||||||
|
static_cell = "2.1.0"
|
||||||
|
portable-atomic = { version = "1.7.0", features = ["critical-section"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "test-cargo"
|
name = "test-cargo"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+46
-48
@@ -1,62 +1,60 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cyw43_pio::PioSpi;
|
||||||
use cortex_m::delay::Delay;
|
use embassy_executor::Spawner;
|
||||||
use embedded_hal::digital::OutputPin;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
|
use embassy_rp::{
|
||||||
use rp2040_hal as hal;
|
bind_interrupts, gpio::{Level, Output}, pio::{InterruptHandler, Pio}, peripherals::{DMA_CH0, PIO0}
|
||||||
|
|
||||||
use hal::{
|
|
||||||
clocks::{init_clocks_and_plls, Clock},
|
|
||||||
pac,
|
|
||||||
watchdog::Watchdog,
|
|
||||||
Sio,
|
|
||||||
};
|
};
|
||||||
|
use defmt::{info, unwrap};
|
||||||
|
use defmt_rtt as _;
|
||||||
|
use panic_halt as _;
|
||||||
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
// Initialize BOOT2 sector
|
macro_rules! singleton {
|
||||||
#[link_section = ".boot2"]
|
($val:expr) => {{
|
||||||
#[used]
|
type T = impl Sized;
|
||||||
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
|
static STATIC_CELL: StaticCell<T> = StaticCell::new();
|
||||||
|
STATIC_CELL.init_with(move || $val)
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
#[entry]
|
bind_interrupts!(struct Irqs {
|
||||||
fn main() -> ! {
|
PIO0_IRQ_0 => InterruptHandler<PIO0>;
|
||||||
let mut pac = pac::Peripherals::take().unwrap();
|
});
|
||||||
let core = pac::CorePeripherals::take().unwrap();
|
|
||||||
let mut watchdog = Watchdog::new(pac.WATCHDOG);
|
|
||||||
let sio = Sio::new(pac.SIO);
|
|
||||||
|
|
||||||
let external_xtal_freq_hz = 12_000_000u32;
|
#[embassy_executor::task]
|
||||||
let clocks = init_clocks_and_plls(
|
async fn cyw43_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! {
|
||||||
external_xtal_freq_hz,
|
runner.run().await
|
||||||
pac.XOSC,
|
}
|
||||||
pac.CLOCKS,
|
|
||||||
pac.PLL_SYS,
|
|
||||||
pac.PLL_USB,
|
|
||||||
&mut pac.RESETS,
|
|
||||||
&mut watchdog,
|
|
||||||
)
|
|
||||||
.ok()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut delay = Delay::new(core.SYST, clocks.system_clock.freq().raw());
|
#[embassy_executor::main]
|
||||||
|
async fn main(spawner: Spawner) {
|
||||||
|
let p = embassy_rp::init(Default::default());
|
||||||
|
let fw = include_bytes!("../firmware/43439A0.bin");
|
||||||
|
let clm = include_bytes!("../firmware/43439A0_clm.bin");
|
||||||
|
|
||||||
let pins = hal::gpio::Pins::new(
|
let power = Output::new(p.PIN_23, Level::Low);
|
||||||
pac.IO_BANK0,
|
let cs = Output::new(p.PIN_25, Level::High);
|
||||||
pac.PADS_BANK0,
|
let mut pio = Pio::new(p.PIO0, Irqs);
|
||||||
sio.gpio_bank0,
|
let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
|
||||||
&mut pac.RESETS,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut led_pin = pins.gpio25.into_push_pull_output();
|
let state = singleton!(cyw43::State::new());
|
||||||
let mut ext_pin = pins.gpio20.into_push_pull_output();
|
static THING: StaticCell<cyw43::State> = StaticCell::new();
|
||||||
|
let state = THING.init_with(cyw43::State::new());
|
||||||
|
let (_net_device, mut control, runner) = cyw43::new(state, power, spi, fw).await;
|
||||||
|
unwrap!(spawner.spawn(cyw43_task(runner)));
|
||||||
|
|
||||||
|
control.init(clm).await;
|
||||||
|
control.set_power_management(cyw43::PowerManagementMode::PowerSave).await;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
led_pin.set_high().unwrap();
|
// Main loop
|
||||||
ext_pin.set_high().unwrap();
|
info!("Blink!");
|
||||||
delay.delay_ms(500);
|
control.gpio_set(0, true).await;
|
||||||
led_pin.set_low().unwrap();
|
Timer::after(Duration::from_millis(500)).await;
|
||||||
ext_pin.set_low().unwrap();
|
control.gpio_set(0, false).await;
|
||||||
delay.delay_ms(500);
|
Timer::after(Duration::from_millis(500)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user