2022-07-10 17:45:26 +00:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait, concat_bytes)]
|
|
|
|
|
|
|
|
use core::slice;
|
|
|
|
|
|
|
|
use defmt::{assert, assert_eq, panic, *};
|
|
|
|
use embassy::executor::Spawner;
|
2022-07-11 20:44:42 +00:00
|
|
|
use embassy::time::{Duration, Timer};
|
2022-07-10 22:25:35 +00:00
|
|
|
use embassy::util::Forever;
|
2022-07-10 17:45:26 +00:00
|
|
|
use embassy_rp::gpio::{Flex, Level, Output, Pin};
|
2022-07-10 22:25:35 +00:00
|
|
|
use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29};
|
2022-07-10 17:45:26 +00:00
|
|
|
use embassy_rp::Peripherals;
|
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
|
|
|
|
macro_rules! forever {
|
|
|
|
($val:expr) => {{
|
|
|
|
type T = impl Sized;
|
|
|
|
static FOREVER: Forever<T> = Forever::new();
|
|
|
|
FOREVER.put_with(move || $val)
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2022-07-10 22:25:35 +00:00
|
|
|
#[embassy::task]
|
|
|
|
async fn wifi_task(runner: cyw43::Runner<'static, PIN_23, PIN_25, PIN_29, PIN_24>) -> ! {
|
|
|
|
runner.run().await
|
|
|
|
}
|
|
|
|
|
2022-07-10 17:45:26 +00:00
|
|
|
#[embassy::main]
|
2022-07-10 22:25:35 +00:00
|
|
|
async fn main(spawner: Spawner, p: Peripherals) {
|
2022-07-10 17:45:26 +00:00
|
|
|
info!("Hello World!");
|
|
|
|
|
|
|
|
let (pwr, cs, clk, dio) = (p.PIN_23, p.PIN_25, p.PIN_29, p.PIN_24);
|
|
|
|
//let (pwr, cs, clk, dio) = (p.PIN_23, p.PIN_0, p.PIN_1, p.PIN_2);
|
|
|
|
|
2022-07-10 22:25:35 +00:00
|
|
|
let state = forever!(cyw43::State::new());
|
|
|
|
let (mut control, runner) = cyw43::new(
|
|
|
|
state,
|
2022-07-10 17:45:26 +00:00
|
|
|
Output::new(pwr, Level::Low),
|
|
|
|
Output::new(cs, Level::High),
|
|
|
|
Output::new(clk, Level::Low),
|
|
|
|
Flex::new(dio),
|
2022-07-10 22:25:35 +00:00
|
|
|
)
|
|
|
|
.await;
|
2022-07-10 17:45:26 +00:00
|
|
|
|
2022-07-10 22:25:35 +00:00
|
|
|
spawner.spawn(wifi_task(runner)).unwrap();
|
2022-07-10 17:45:26 +00:00
|
|
|
|
2022-07-10 22:25:35 +00:00
|
|
|
control.init().await;
|
2022-07-11 03:19:31 +00:00
|
|
|
|
|
|
|
let ssid = "MikroTik-951589";
|
|
|
|
control.join(ssid).await;
|
2022-07-10 17:45:26 +00:00
|
|
|
}
|