embassy/tests/rp/src/bin/spi.rs

31 lines
738 B
Rust
Raw Normal View History

2022-08-30 23:04:58 +02:00
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
2023-05-30 00:10:36 +02:00
#[path = "../common.rs"]
mod common;
2022-08-30 23:04:58 +02:00
use defmt::{assert_eq, *};
use embassy_executor::Spawner;
2022-08-31 22:28:47 +02:00
use embassy_rp::spi::{Config, Spi};
2022-08-30 23:04:58 +02:00
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
info!("Hello World!");
let clk = p.PIN_2;
let mosi = p.PIN_3;
let miso = p.PIN_4;
2022-08-31 22:28:47 +02:00
let mut spi = Spi::new_blocking(p.SPI0, clk, mosi, miso, Config::default());
2022-08-30 23:04:58 +02:00
let tx_buf = [1_u8, 2, 3, 4, 5, 6];
let mut rx_buf = [0_u8; 6];
spi.blocking_transfer(&mut rx_buf, &tx_buf).unwrap();
assert_eq!(rx_buf, tx_buf);
info!("Test OK");
cortex_m::asm::bkpt();
}