Remove MySpi
MySpi was replaced by PioSpi and no longer used.
This commit is contained in:
parent
46efce6ea2
commit
4be1e4bd44
1 changed files with 2 additions and 88 deletions
|
@ -4,7 +4,6 @@
|
||||||
#![feature(async_fn_in_trait)]
|
#![feature(async_fn_in_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
use core::slice;
|
|
||||||
use core::str::from_utf8;
|
use core::str::from_utf8;
|
||||||
|
|
||||||
use cyw43_pio::PioSpi;
|
use cyw43_pio::PioSpi;
|
||||||
|
@ -12,8 +11,8 @@ use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_net::tcp::TcpSocket;
|
use embassy_net::tcp::TcpSocket;
|
||||||
use embassy_net::{Config, Stack, StackResources};
|
use embassy_net::{Config, Stack, StackResources};
|
||||||
use embassy_rp::gpio::{Flex, Level, Output};
|
use embassy_rp::gpio::{Level, Output};
|
||||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_24, PIN_25, PIN_29};
|
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25};
|
||||||
use embassy_rp::pio::{Pio0, PioPeripheral, PioStateMachineInstance, Sm0};
|
use embassy_rp::pio::{Pio0, PioPeripheral, PioStateMachineInstance, Sm0};
|
||||||
use embedded_io::asynch::Write;
|
use embedded_io::asynch::Write;
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
|
@ -150,88 +149,3 @@ async fn main(spawner: Spawner) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MySpi {
|
|
||||||
/// SPI clock
|
|
||||||
clk: Output<'static, PIN_29>,
|
|
||||||
|
|
||||||
/// 4 signals, all in one!!
|
|
||||||
/// - SPI MISO
|
|
||||||
/// - SPI MOSI
|
|
||||||
/// - IRQ
|
|
||||||
/// - strap to set to gSPI mode on boot.
|
|
||||||
dio: Flex<'static, PIN_24>,
|
|
||||||
|
|
||||||
/// Chip select
|
|
||||||
cs: Output<'static, PIN_25>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MySpi {
|
|
||||||
async fn read(&mut self, words: &mut [u32]) {
|
|
||||||
self.dio.set_as_input();
|
|
||||||
for word in words {
|
|
||||||
let mut w = 0;
|
|
||||||
for _ in 0..32 {
|
|
||||||
w = w << 1;
|
|
||||||
|
|
||||||
// rising edge, sample data
|
|
||||||
if self.dio.is_high() {
|
|
||||||
w |= 0x01;
|
|
||||||
}
|
|
||||||
self.clk.set_high();
|
|
||||||
|
|
||||||
// falling edge
|
|
||||||
self.clk.set_low();
|
|
||||||
}
|
|
||||||
*word = w
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn write(&mut self, words: &[u32]) {
|
|
||||||
self.dio.set_as_output();
|
|
||||||
for word in words {
|
|
||||||
let mut word = *word;
|
|
||||||
for _ in 0..32 {
|
|
||||||
// falling edge, setup data
|
|
||||||
self.clk.set_low();
|
|
||||||
if word & 0x8000_0000 == 0 {
|
|
||||||
self.dio.set_low();
|
|
||||||
} else {
|
|
||||||
self.dio.set_high();
|
|
||||||
}
|
|
||||||
|
|
||||||
// rising edge
|
|
||||||
self.clk.set_high();
|
|
||||||
|
|
||||||
word = word << 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.clk.set_low();
|
|
||||||
|
|
||||||
self.dio.set_as_input();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl cyw43::SpiBusCyw43 for MySpi {
|
|
||||||
async fn cmd_write(&mut self, write: &[u32]) -> u32 {
|
|
||||||
self.cs.set_low();
|
|
||||||
self.write(write).await;
|
|
||||||
|
|
||||||
let mut status = 0;
|
|
||||||
self.read(slice::from_mut(&mut status)).await;
|
|
||||||
|
|
||||||
self.cs.set_high();
|
|
||||||
status
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn cmd_read(&mut self, write: u32, read: &mut [u32]) -> u32 {
|
|
||||||
self.cs.set_low();
|
|
||||||
self.write(slice::from_ref(&write)).await;
|
|
||||||
self.read(read).await;
|
|
||||||
|
|
||||||
let mut status = 0;
|
|
||||||
self.read(slice::from_mut(&mut status)).await;
|
|
||||||
|
|
||||||
self.cs.set_high();
|
|
||||||
status
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue