2021-12-17 12:50:48 +01:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::*;
|
2022-05-26 18:54:58 +02:00
|
|
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
2022-08-17 23:40:16 +02:00
|
|
|
use embassy_executor::Spawner;
|
2021-12-17 12:50:48 +01:00
|
|
|
use embassy_stm32::dma::NoDma;
|
|
|
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
|
|
|
use embassy_stm32::spi::{Config, Spi};
|
2023-07-31 00:02:50 +02:00
|
|
|
use embassy_stm32::time::Hertz;
|
2022-02-16 03:54:39 +01:00
|
|
|
use embedded_hal_async::spi::SpiBus;
|
2022-06-12 22:15:44 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
2021-12-17 12:50:48 +01:00
|
|
|
|
2022-07-29 21:58:35 +02:00
|
|
|
#[embassy_executor::main]
|
2022-08-17 18:49:55 +02:00
|
|
|
async fn main(_spawner: Spawner) {
|
|
|
|
let p = embassy_stm32::init(Default::default());
|
2021-12-17 12:50:48 +01:00
|
|
|
info!("Hello World!");
|
|
|
|
|
2023-07-31 00:02:50 +02:00
|
|
|
let mut spi_config = Config::default();
|
|
|
|
spi_config.frequency = Hertz(1_000_000);
|
|
|
|
|
|
|
|
let spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, spi_config);
|
2021-12-17 12:50:48 +01:00
|
|
|
|
|
|
|
let mut spi = BlockingAsync::new(spi);
|
|
|
|
|
|
|
|
// These are the pins for the Inventek eS-Wifi SPI Wifi Adapter.
|
|
|
|
|
|
|
|
let _boot = Output::new(p.PB12, Level::Low, Speed::VeryHigh);
|
|
|
|
let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh);
|
|
|
|
let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh);
|
|
|
|
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
2023-12-14 16:01:51 +01:00
|
|
|
let mut ready = Input::new(p.PE1, Pull::Up);
|
2021-12-17 12:50:48 +01:00
|
|
|
|
|
|
|
cortex_m::asm::delay(100_000);
|
2022-01-14 22:02:00 +01:00
|
|
|
reset.set_high();
|
2021-12-17 12:50:48 +01:00
|
|
|
cortex_m::asm::delay(100_000);
|
|
|
|
|
2022-01-14 22:02:00 +01:00
|
|
|
while ready.is_low() {
|
2021-12-17 12:50:48 +01:00
|
|
|
info!("waiting for ready");
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:39:06 +01:00
|
|
|
let write: [u8; 10] = [0x0A; 10];
|
|
|
|
let mut read: [u8; 10] = [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-12-17 12:50:48 +01:00
|
|
|
info!("xfer {=[u8]:x}", read);
|
|
|
|
}
|