2021-07-21 16:42:22 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::*;
|
2021-07-24 13:57:11 +02:00
|
|
|
use embassy::executor::Spawner;
|
|
|
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
|
|
|
use embassy_stm32::spi::{Config, Spi};
|
2021-07-21 16:42:22 +02:00
|
|
|
use embassy_stm32::time::Hertz;
|
2021-07-29 15:54:11 +02:00
|
|
|
use embassy_stm32::Peripherals;
|
2022-06-12 22:15:44 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
2021-07-21 16:42:22 +02:00
|
|
|
|
2021-07-24 13:57:11 +02:00
|
|
|
#[embassy::main]
|
|
|
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
|
|
|
info!("Hello World!");
|
|
|
|
|
2021-07-21 16:42:22 +02:00
|
|
|
let mut spi = Spi::new(
|
|
|
|
p.SPI3,
|
|
|
|
p.PC10,
|
|
|
|
p.PC12,
|
|
|
|
p.PC11,
|
|
|
|
p.DMA1_CH1,
|
2022-03-09 00:12:50 +01:00
|
|
|
p.DMA1_CH2,
|
2021-07-21 16:42:22 +02:00
|
|
|
Hertz(1_000_000),
|
|
|
|
Config::default(),
|
|
|
|
);
|
|
|
|
|
2021-07-21 16:52:26 +02:00
|
|
|
// These are the pins for the Inventek eS-Wifi SPI Wifi Adapter.
|
|
|
|
|
2021-07-21 17:28:02 +02:00
|
|
|
let _boot = Output::new(p.PB12, Level::Low, Speed::VeryHigh);
|
|
|
|
let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh);
|
2021-07-21 16:52:26 +02:00
|
|
|
let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh);
|
2021-07-21 16:42:22 +02:00
|
|
|
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
2021-07-21 17:20:03 +02:00
|
|
|
let ready = Input::new(p.PE1, Pull::Up);
|
2021-07-21 16:42:22 +02:00
|
|
|
|
2021-07-21 16:52:26 +02:00
|
|
|
cortex_m::asm::delay(100_000);
|
2022-01-14 22:02:00 +01:00
|
|
|
reset.set_high();
|
2021-07-21 16:52:26 +02:00
|
|
|
cortex_m::asm::delay(100_000);
|
|
|
|
|
2022-01-14 22:02:00 +01:00
|
|
|
while ready.is_low() {
|
2021-07-21 16:52:26 +02:00
|
|
|
info!("waiting for ready");
|
2021-07-21 16:42:22 +02:00
|
|
|
}
|
2021-07-21 16:52:26 +02:00
|
|
|
|
|
|
|
let write = [0x0A; 10];
|
|
|
|
let mut read = [0; 10];
|
2022-01-14 22:02:00 +01:00
|
|
|
cs.set_low();
|
2022-01-26 22:39:06 +01:00
|
|
|
spi.transfer(&mut read, &write).await.ok();
|
2022-01-14 22:02:00 +01:00
|
|
|
cs.set_high();
|
2021-07-21 16:52:26 +02:00
|
|
|
info!("xfer {=[u8]:x}", read);
|
2021-07-21 16:42:22 +02:00
|
|
|
}
|