2022-11-05 00:15:43 +01:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
use defmt::info;
|
|
|
|
use embassy_executor::Spawner;
|
2022-11-05 01:40:20 +01:00
|
|
|
use embassy_nrf::spis::{Config, Spis};
|
2023-03-05 22:05:02 +01:00
|
|
|
use embassy_nrf::{bind_interrupts, peripherals, spis};
|
2022-11-05 00:15:43 +01:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
|
2023-03-05 22:05:02 +01:00
|
|
|
bind_interrupts!(struct Irqs {
|
|
|
|
SPIM2_SPIS2_SPI2 => spis::InterruptHandler<peripherals::SPI2>;
|
|
|
|
});
|
|
|
|
|
2022-11-05 00:15:43 +01:00
|
|
|
#[embassy_executor::main]
|
|
|
|
async fn main(_spawner: Spawner) {
|
|
|
|
let p = embassy_nrf::init(Default::default());
|
|
|
|
info!("Running!");
|
|
|
|
|
2023-03-05 22:05:02 +01:00
|
|
|
let mut spis = Spis::new(p.SPI2, Irqs, p.P0_31, p.P0_29, p.P0_28, p.P0_30, Config::default());
|
2022-11-05 00:15:43 +01:00
|
|
|
|
|
|
|
loop {
|
2022-11-13 01:49:55 +01:00
|
|
|
let mut rx_buf = [0_u8; 64];
|
|
|
|
let tx_buf = [1_u8, 2, 3, 4, 5, 6, 7, 8];
|
|
|
|
if let Ok((n_rx, n_tx)) = spis.transfer(&mut rx_buf, &tx_buf).await {
|
|
|
|
info!("RX: {:?}", rx_buf[..n_rx]);
|
|
|
|
info!("TX: {:?}", tx_buf[..n_tx]);
|
2022-11-05 00:15:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|