parent
e196387e69
commit
4b63829110
13 changed files with 160 additions and 70 deletions
tests/rp
|
@ -29,6 +29,8 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
|
|||
embedded-io = { version = "0.4.0", features = ["async"] }
|
||||
embedded-storage = { version = "0.3" }
|
||||
static_cell = { version = "1.1", features = ["nightly"]}
|
||||
pio = "0.2"
|
||||
pio-proc = "0.2"
|
||||
|
||||
[profile.dev]
|
||||
debug = 2
|
||||
|
|
|
@ -12,12 +12,16 @@ use embassy_net::tcp::TcpSocket;
|
|||
use embassy_net::{Config, Ipv4Address, Stack, StackResources};
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||
use embassy_rp::pio::Pio;
|
||||
use embassy_rp::rom_data;
|
||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||
use embassy_rp::{bind_interrupts, rom_data};
|
||||
use embassy_time::{with_timeout, Duration, Timer};
|
||||
use static_cell::make_static;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
PIO0_IRQ_0 => InterruptHandler<PIO0>;
|
||||
});
|
||||
|
||||
teleprobe_meta::timeout!(120);
|
||||
|
||||
#[embassy_executor::task]
|
||||
|
@ -51,7 +55,7 @@ async fn main(spawner: Spawner) {
|
|||
|
||||
let pwr = Output::new(p.PIN_23, Level::Low);
|
||||
let cs = Output::new(p.PIN_25, Level::High);
|
||||
let mut pio = Pio::new(p.PIO0);
|
||||
let mut pio = Pio::new(p.PIO0, Irqs);
|
||||
let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
|
||||
|
||||
let state = make_static!(cyw43::State::new());
|
||||
|
|
55
tests/rp/src/bin/pio_irq.rs
Normal file
55
tests/rp/src/bin/pio_irq.rs
Normal file
|
@ -0,0 +1,55 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#[path = "../common.rs"]
|
||||
mod common;
|
||||
|
||||
use defmt::info;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_rp::bind_interrupts;
|
||||
use embassy_rp::peripherals::PIO0;
|
||||
use embassy_rp::pio::{Config, InterruptHandler, Pio};
|
||||
use embassy_rp::relocate::RelocatedProgram;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
PIO0_IRQ_0 => InterruptHandler<PIO0>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_rp::init(Default::default());
|
||||
let pio = p.PIO0;
|
||||
let Pio {
|
||||
mut common,
|
||||
sm0: mut sm,
|
||||
irq_flags,
|
||||
..
|
||||
} = Pio::new(pio, Irqs);
|
||||
|
||||
let prg = pio_proc::pio_asm!(
|
||||
"irq set 0",
|
||||
"irq wait 0",
|
||||
"irq set 1",
|
||||
// pause execution here
|
||||
"irq wait 1",
|
||||
);
|
||||
|
||||
let relocated = RelocatedProgram::new(&prg.program);
|
||||
let mut cfg = Config::default();
|
||||
cfg.use_program(&common.load_program(&relocated), &[]);
|
||||
sm.set_config(&cfg);
|
||||
sm.set_enable(true);
|
||||
|
||||
// not using the wait futures on purpose because they clear the irq bits,
|
||||
// and we want to see in which order they are set.
|
||||
while !irq_flags.check(0) {}
|
||||
cortex_m::asm::nop();
|
||||
assert!(!irq_flags.check(1));
|
||||
irq_flags.clear(0);
|
||||
cortex_m::asm::nop();
|
||||
assert!(irq_flags.check(1));
|
||||
|
||||
info!("Test OK");
|
||||
cortex_m::asm::bkpt();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue