Implement FullDuplex for nrf spim

This commit is contained in:
Dario Nieuwenhuis
2021-03-18 01:27:30 +01:00
parent c403a47b7f
commit 3de2d5c5bd
3 changed files with 43 additions and 15 deletions

View File

@ -6,6 +6,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_traits::spi::FullDuplex;
use example_common::*;
use cortex_m_rt::entry;
@ -49,7 +50,7 @@ async fn run() {
ncs.set_low().unwrap();
cortex_m::asm::delay(5);
let tx = [0xFF];
unwrap!(spim.as_mut().send_receive(&tx, &mut []).await);
unwrap!(spim.as_mut().read_write(&mut [], &tx).await);
cortex_m::asm::delay(10);
ncs.set_high().unwrap();
@ -62,7 +63,7 @@ async fn run() {
ncs.set_low().unwrap();
cortex_m::asm::delay(5000);
let tx = [0b000_11101, 0];
unwrap!(spim.as_mut().send_receive(&tx, &mut rx).await);
unwrap!(spim.as_mut().read_write(&mut rx, &tx).await);
cortex_m::asm::delay(5000);
ncs.set_high().unwrap();
info!("estat: {=[?]}", rx);
@ -72,7 +73,7 @@ async fn run() {
ncs.set_low().unwrap();
cortex_m::asm::delay(5);
let tx = [0b100_11111, 0b11];
unwrap!(spim.as_mut().send_receive(&tx, &mut rx).await);
unwrap!(spim.as_mut().read_write(&mut rx, &tx).await);
cortex_m::asm::delay(10);
ncs.set_high().unwrap();
@ -81,7 +82,7 @@ async fn run() {
ncs.set_low().unwrap();
cortex_m::asm::delay(5);
let tx = [0b000_10010, 0];
unwrap!(spim.as_mut().send_receive(&tx, &mut rx).await);
unwrap!(spim.as_mut().read_write(&mut rx, &tx).await);
cortex_m::asm::delay(10);
ncs.set_high().unwrap();