Remove Peripheral trait, rename PeripheralRef->Peri.

This commit is contained in:
Dario Nieuwenhuis
2025-03-26 16:01:37 +01:00
parent 9edf5b7f04
commit d41eeeae79
225 changed files with 2645 additions and 3215 deletions

View File

@@ -30,12 +30,12 @@ async fn main(_spawner: Spawner) {
{
{
let mut p = Channel::new_pin(&mut a, Pull::Down);
let mut p = Channel::new_pin(a.reborrow(), Pull::Down);
defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
defmt::assert!(adc.read(&mut p).await.unwrap() < 0b01_0000_0000);
}
{
let mut p = Channel::new_pin(&mut a, Pull::Up);
let mut p = Channel::new_pin(a.reborrow(), Pull::Up);
defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
defmt::assert!(adc.read(&mut p).await.unwrap() > 0b11_0000_0000);
}
@@ -43,21 +43,21 @@ async fn main(_spawner: Spawner) {
// not bothering with async reads from now on
{
{
let mut p = Channel::new_pin(&mut b, Pull::Down);
let mut p = Channel::new_pin(b.reborrow(), Pull::Down);
defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
}
{
let mut p = Channel::new_pin(&mut b, Pull::Up);
let mut p = Channel::new_pin(b.reborrow(), Pull::Up);
defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
}
}
{
{
let mut p = Channel::new_pin(&mut c, Pull::Down);
let mut p = Channel::new_pin(c.reborrow(), Pull::Down);
defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
}
{
let mut p = Channel::new_pin(&mut c, Pull::Up);
let mut p = Channel::new_pin(c.reborrow(), Pull::Up);
defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
}
}
@@ -65,15 +65,15 @@ async fn main(_spawner: Spawner) {
// gp29 is connected to vsys through a 200k/100k divider,
// adding pulls should change the value
let low = {
let mut p = Channel::new_pin(&mut d, Pull::Down);
let mut p = Channel::new_pin(d.reborrow(), Pull::Down);
adc.blocking_read(&mut p).unwrap()
};
let none = {
let mut p = Channel::new_pin(&mut d, Pull::None);
let mut p = Channel::new_pin(d.reborrow(), Pull::None);
adc.blocking_read(&mut p).unwrap()
};
let up = {
let mut p = Channel::new_pin(&mut d, Pull::Up);
let mut p = Channel::new_pin(d.reborrow(), Pull::Up);
adc.blocking_read(&mut p).unwrap()
};
defmt::assert!(low < none);
@@ -81,7 +81,7 @@ async fn main(_spawner: Spawner) {
}
{
let temp = convert_to_celsius(
adc.read(&mut Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR))
adc.read(&mut Channel::new_temp_sensor(p.ADC_TEMP_SENSOR.reborrow()))
.await
.unwrap(),
);
@@ -97,14 +97,29 @@ async fn main(_spawner: Spawner) {
let mut low = [0u16; 16];
let mut none = [0u8; 16];
let mut up = [Sample::default(); 16];
adc.read_many(&mut Channel::new_pin(&mut d, Pull::Down), &mut low, 1, &mut p.DMA_CH0)
.await
.unwrap();
adc.read_many(&mut Channel::new_pin(&mut d, Pull::None), &mut none, 1, &mut p.DMA_CH0)
.await
.unwrap();
adc.read_many_raw(&mut Channel::new_pin(&mut d, Pull::Up), &mut up, 1, &mut p.DMA_CH0)
.await;
adc.read_many(
&mut Channel::new_pin(d.reborrow(), Pull::Down),
&mut low,
1,
p.DMA_CH0.reborrow(),
)
.await
.unwrap();
adc.read_many(
&mut Channel::new_pin(d.reborrow(), Pull::None),
&mut none,
1,
p.DMA_CH0.reborrow(),
)
.await
.unwrap();
adc.read_many_raw(
&mut Channel::new_pin(d.reborrow(), Pull::Up),
&mut up,
1,
p.DMA_CH0.reborrow(),
)
.await;
defmt::assert!(low.iter().zip(none.iter()).all(|(l, n)| *l >> 4 < *n as u16));
defmt::assert!(up.iter().all(|s| s.good()));
defmt::assert!(none.iter().zip(up.iter()).all(|(n, u)| (*n as u16) < u.value()));
@@ -112,10 +127,10 @@ async fn main(_spawner: Spawner) {
{
let mut temp = [0u16; 16];
adc.read_many(
&mut Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR),
&mut Channel::new_temp_sensor(p.ADC_TEMP_SENSOR.reborrow()),
&mut temp,
1,
&mut p.DMA_CH0,
p.DMA_CH0.reborrow(),
)
.await
.unwrap();
@@ -126,10 +141,10 @@ async fn main(_spawner: Spawner) {
{
let mut multi = [0u16; 2];
let mut channels = [
Channel::new_pin(&mut a, Pull::Up),
Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR),
Channel::new_pin(a.reborrow(), Pull::Up),
Channel::new_temp_sensor(p.ADC_TEMP_SENSOR.reborrow()),
];
adc.read_many_multichannel(&mut channels, &mut multi, 1, &mut p.DMA_CH0)
adc.read_many_multichannel(&mut channels, &mut multi, 1, p.DMA_CH0.reborrow())
.await
.unwrap();
defmt::assert!(multi[0] > 3_000);

View File

@@ -4,12 +4,13 @@ teleprobe_meta::target!(b"rpi-pico");
use defmt::{assert_eq, *};
use embassy_executor::Spawner;
use embassy_rp::bootsel::is_bootsel_pressed;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let mut p = embassy_rp::init(Default::default());
let p = embassy_rp::init(Default::default());
info!("Hello World!");
// add some delay to give an attached debug probe time to parse the
@@ -18,7 +19,7 @@ async fn main(_spawner: Spawner) {
// https://github.com/knurling-rs/defmt/pull/683
Timer::after_millis(10).await;
assert_eq!(p.BOOTSEL.is_pressed(), false);
assert_eq!(is_bootsel_pressed(p.BOOTSEL), false);
info!("Test OK");
cortex_m::asm::bkpt();

View File

@@ -21,10 +21,10 @@ async fn main(_spawner: Spawner) {
// Test initial output
{
let b = Input::new(&mut b, Pull::None);
let b = Input::new(b.reborrow(), Pull::None);
{
let a = Output::new(&mut a, Level::Low);
let a = Output::new(a.reborrow(), Level::Low);
delay();
assert!(b.is_low());
assert!(!b.is_high());
@@ -32,7 +32,7 @@ async fn main(_spawner: Spawner) {
assert!(!a.is_set_high());
}
{
let mut a = Output::new(&mut a, Level::High);
let mut a = Output::new(a.reborrow(), Level::High);
delay();
assert!(!b.is_low());
assert!(b.is_high());
@@ -69,10 +69,10 @@ async fn main(_spawner: Spawner) {
// Test input no pull
{
let b = Input::new(&mut b, Pull::None);
let b = Input::new(b.reborrow(), Pull::None);
// no pull, the status is undefined
let mut a = Output::new(&mut a, Level::Low);
let mut a = Output::new(a.reborrow(), Level::Low);
delay();
assert!(b.is_low());
a.set_high();
@@ -83,11 +83,11 @@ async fn main(_spawner: Spawner) {
// Test input pulldown
#[cfg(feature = "rp2040")]
{
let b = Input::new(&mut b, Pull::Down);
let b = Input::new(b.reborrow(), Pull::Down);
delay();
assert!(b.is_low());
let mut a = Output::new(&mut a, Level::Low);
let mut a = Output::new(a.reborrow(), Level::Low);
delay();
assert!(b.is_low());
a.set_high();
@@ -97,11 +97,11 @@ async fn main(_spawner: Spawner) {
// Test input pullup
{
let b = Input::new(&mut b, Pull::Up);
let b = Input::new(b.reborrow(), Pull::Up);
delay();
assert!(b.is_high());
let mut a = Output::new(&mut a, Level::Low);
let mut a = Output::new(a.reborrow(), Level::Low);
delay();
assert!(b.is_low());
a.set_high();
@@ -112,8 +112,8 @@ async fn main(_spawner: Spawner) {
// OUTPUT OPEN DRAIN
#[cfg(feature = "rp2040")]
{
let mut b = OutputOpenDrain::new(&mut b, Level::High);
let mut a = Flex::new(&mut a);
let mut b = OutputOpenDrain::new(b.reborrow(), Level::High);
let mut a = Flex::new(a.reborrow());
a.set_as_input();
// When an OutputOpenDrain is high, it doesn't drive the pin.
@@ -170,12 +170,12 @@ async fn main(_spawner: Spawner) {
// Test initial output
{
//Flex pin configured as input
let mut b = Flex::new(&mut b);
let mut b = Flex::new(b.reborrow());
b.set_as_input();
{
//Flex pin configured as output
let mut a = Flex::new(&mut a); //Flex pin configured as output
let mut a = Flex::new(a.reborrow()); //Flex pin configured as output
a.set_low(); // Pin state must be set before configuring the pin, thus we avoid unknown state
a.set_as_output();
delay();
@@ -183,7 +183,7 @@ async fn main(_spawner: Spawner) {
}
{
//Flex pin configured as output
let mut a = Flex::new(&mut a);
let mut a = Flex::new(a.reborrow());
a.set_high();
a.set_as_output();
@@ -194,10 +194,10 @@ async fn main(_spawner: Spawner) {
// Test input no pull
{
let mut b = Flex::new(&mut b);
let mut b = Flex::new(b.reborrow());
b.set_as_input(); // no pull by default.
let mut a = Flex::new(&mut a);
let mut a = Flex::new(a.reborrow());
a.set_low();
a.set_as_output();
@@ -211,13 +211,13 @@ async fn main(_spawner: Spawner) {
// Test input pulldown
#[cfg(feature = "rp2040")]
{
let mut b = Flex::new(&mut b);
let mut b = Flex::new(b.reborrow());
b.set_as_input();
b.set_pull(Pull::Down);
delay();
assert!(b.is_low());
let mut a = Flex::new(&mut a);
let mut a = Flex::new(a.reborrow());
a.set_low();
a.set_as_output();
delay();
@@ -229,13 +229,13 @@ async fn main(_spawner: Spawner) {
// Test input pullup
{
let mut b = Flex::new(&mut b);
let mut b = Flex::new(b.reborrow());
b.set_as_input();
b.set_pull(Pull::Up);
delay();
assert!(b.is_high());
let mut a = Flex::new(&mut a);
let mut a = Flex::new(a.reborrow());
a.set_high();
a.set_as_output();
delay();

View File

@@ -22,8 +22,8 @@ async fn main(_spawner: Spawner) {
{
info!("test wait_for_high");
let mut output = Output::new(&mut output_pin, Level::Low);
let mut input = Input::new(&mut input_pin, Pull::None);
let mut output = Output::new(output_pin.reborrow(), Level::Low);
let mut input = Input::new(input_pin.reborrow(), Pull::None);
assert!(input.is_low(), "input was expected to be low");
@@ -43,8 +43,8 @@ async fn main(_spawner: Spawner) {
{
info!("test wait_for_low");
let mut output = Output::new(&mut output_pin, Level::High);
let mut input = Input::new(&mut input_pin, Pull::None);
let mut output = Output::new(output_pin.reborrow(), Level::High);
let mut input = Input::new(input_pin.reborrow(), Pull::None);
assert!(input.is_high(), "input was expected to be high");
@@ -63,8 +63,8 @@ async fn main(_spawner: Spawner) {
{
info!("test wait_for_rising_edge");
let mut output = Output::new(&mut output_pin, Level::Low);
let mut input = Input::new(&mut input_pin, Pull::None);
let mut output = Output::new(output_pin.reborrow(), Level::Low);
let mut input = Input::new(input_pin.reborrow(), Pull::None);
assert!(input.is_low(), "input was expected to be low");
@@ -83,8 +83,8 @@ async fn main(_spawner: Spawner) {
{
info!("test wait_for_falling_edge");
let mut output = Output::new(&mut output_pin, Level::High);
let mut input = Input::new(&mut input_pin, Pull::None);
let mut output = Output::new(output_pin.reborrow(), Level::High);
let mut input = Input::new(input_pin.reborrow(), Pull::None);
assert!(input.is_high(), "input was expected to be high");
@@ -103,8 +103,8 @@ async fn main(_spawner: Spawner) {
{
info!("test wait_for_any_edge (falling)");
let mut output = Output::new(&mut output_pin, Level::High);
let mut input = Input::new(&mut input_pin, Pull::None);
let mut output = Output::new(output_pin.reborrow(), Level::High);
let mut input = Input::new(input_pin.reborrow(), Pull::None);
assert!(input.is_high(), "input was expected to be high");
@@ -123,8 +123,8 @@ async fn main(_spawner: Spawner) {
{
info!("test wait_for_any_edge (rising)");
let mut output = Output::new(&mut output_pin, Level::Low);
let mut input = Input::new(&mut input_pin, Pull::None);
let mut output = Output::new(output_pin.reborrow(), Level::Low);
let mut input = Input::new(input_pin.reborrow(), Pull::None);
assert!(input.is_low(), "input was expected to be low");

View File

@@ -10,6 +10,7 @@ use embassy_executor::Executor;
use embassy_rp::gpio::{Input, Level, Output, Pull};
use embassy_rp::multicore::{spawn_core1, Stack};
use embassy_rp::peripherals::{PIN_0, PIN_1};
use embassy_rp::Peri;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::channel::Channel;
use static_cell::StaticCell;
@@ -37,7 +38,7 @@ fn main() -> ! {
}
#[embassy_executor::task]
async fn core0_task(p: PIN_0) {
async fn core0_task(p: Peri<'static, PIN_0>) {
info!("CORE0 is running");
let mut pin = Output::new(p, Level::Low);
@@ -54,7 +55,7 @@ async fn core0_task(p: PIN_0) {
}
#[embassy_executor::task]
async fn core1_task(p: PIN_1) {
async fn core1_task(p: Peri<'static, PIN_1>) {
info!("CORE1 is running");
CHANNEL0.receive().await;

View File

@@ -33,7 +33,7 @@ async fn main(_spawner: Spawner) {
// Test free-running clock
{
let pwm = Pwm::new_free(&mut p.PWM_SLICE3, cfg.clone());
let pwm = Pwm::new_free(p.PWM_SLICE3.reborrow(), cfg.clone());
cortex_m::asm::delay(125);
let ctr = pwm.counter();
assert!(ctr > 0);
@@ -50,8 +50,8 @@ async fn main(_spawner: Spawner) {
// Test output from A
{
let pin1 = Input::new(&mut p9, Pull::None);
let _pwm = Pwm::new_output_a(&mut p.PWM_SLICE3, &mut p6, cfg.clone());
let pin1 = Input::new(p9.reborrow(), Pull::None);
let _pwm = Pwm::new_output_a(p.PWM_SLICE3.reborrow(), p6.reborrow(), cfg.clone());
Timer::after_millis(1).await;
assert_eq!(pin1.is_low(), invert_a);
Timer::after_millis(5).await;
@@ -64,8 +64,8 @@ async fn main(_spawner: Spawner) {
// Test output from B
{
let pin2 = Input::new(&mut p11, Pull::None);
let _pwm = Pwm::new_output_b(&mut p.PWM_SLICE3, &mut p7, cfg.clone());
let pin2 = Input::new(p11.reborrow(), Pull::None);
let _pwm = Pwm::new_output_b(p.PWM_SLICE3.reborrow(), p7.reborrow(), cfg.clone());
Timer::after_millis(1).await;
assert_ne!(pin2.is_low(), invert_a);
Timer::after_millis(5).await;
@@ -78,9 +78,9 @@ async fn main(_spawner: Spawner) {
// Test output from A+B
{
let pin1 = Input::new(&mut p9, Pull::None);
let pin2 = Input::new(&mut p11, Pull::None);
let _pwm = Pwm::new_output_ab(&mut p.PWM_SLICE3, &mut p6, &mut p7, cfg.clone());
let pin1 = Input::new(p9.reborrow(), Pull::None);
let pin2 = Input::new(p11.reborrow(), Pull::None);
let _pwm = Pwm::new_output_ab(p.PWM_SLICE3.reborrow(), p6.reborrow(), p7.reborrow(), cfg.clone());
Timer::after_millis(1).await;
assert_eq!(pin1.is_low(), invert_a);
assert_ne!(pin2.is_low(), invert_a);
@@ -99,8 +99,14 @@ async fn main(_spawner: Spawner) {
// Test level-gated
#[cfg(feature = "rp2040")]
{
let mut pin2 = Output::new(&mut p11, Level::Low);
let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, Pull::None, InputMode::Level, cfg.clone());
let mut pin2 = Output::new(p11.reborrow(), Level::Low);
let pwm = Pwm::new_input(
p.PWM_SLICE3.reborrow(),
p7.reborrow(),
Pull::None,
InputMode::Level,
cfg.clone(),
);
assert_eq!(pwm.counter(), 0);
Timer::after_millis(5).await;
assert_eq!(pwm.counter(), 0);
@@ -117,10 +123,10 @@ async fn main(_spawner: Spawner) {
// Test rising-gated
#[cfg(feature = "rp2040")]
{
let mut pin2 = Output::new(&mut p11, Level::Low);
let mut pin2 = Output::new(p11.reborrow(), Level::Low);
let pwm = Pwm::new_input(
&mut p.PWM_SLICE3,
&mut p7,
p.PWM_SLICE3.reborrow(),
p7.reborrow(),
Pull::None,
InputMode::RisingEdge,
cfg.clone(),
@@ -139,10 +145,10 @@ async fn main(_spawner: Spawner) {
// Test falling-gated
#[cfg(feature = "rp2040")]
{
let mut pin2 = Output::new(&mut p11, Level::High);
let mut pin2 = Output::new(p11.reborrow(), Level::High);
let pwm = Pwm::new_input(
&mut p.PWM_SLICE3,
&mut p7,
p.PWM_SLICE3.reborrow(),
p7.reborrow(),
Pull::None,
InputMode::FallingEdge,
cfg.clone(),
@@ -160,10 +166,10 @@ async fn main(_spawner: Spawner) {
// pull-down
{
let pin2 = Input::new(&mut p11, Pull::None);
let pin2 = Input::new(p11.reborrow(), Pull::None);
Pwm::new_input(
&mut p.PWM_SLICE3,
&mut p7,
p.PWM_SLICE3.reborrow(),
p7.reborrow(),
Pull::Down,
InputMode::FallingEdge,
cfg.clone(),
@@ -174,10 +180,10 @@ async fn main(_spawner: Spawner) {
// pull-up
{
let pin2 = Input::new(&mut p11, Pull::None);
let pin2 = Input::new(p11.reborrow(), Pull::None);
Pwm::new_input(
&mut p.PWM_SLICE3,
&mut p7,
p.PWM_SLICE3.reborrow(),
p7.reborrow(),
Pull::Up,
InputMode::FallingEdge,
cfg.clone(),

View File

@@ -56,7 +56,7 @@ async fn main(_spawner: Spawner) {
{
let config = Config::default();
let mut uart = Uart::new_blocking(&mut uart, &mut tx, &mut rx, config);
let mut uart = Uart::new_blocking(uart.reborrow(), tx.reborrow(), rx.reborrow(), config);
// We can't send too many bytes, they have to fit in the FIFO.
// This is because we aren't sending+receiving at the same time.
@@ -69,7 +69,7 @@ async fn main(_spawner: Spawner) {
info!("test overflow detection");
{
let config = Config::default();
let mut uart = Uart::new_blocking(&mut uart, &mut tx, &mut rx, config);
let mut uart = Uart::new_blocking(uart.reborrow(), tx.reborrow(), rx.reborrow(), config);
let data = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
@@ -93,7 +93,7 @@ async fn main(_spawner: Spawner) {
info!("test break detection");
{
let config = Config::default();
let mut uart = Uart::new_blocking(&mut uart, &mut tx, &mut rx, config);
let mut uart = Uart::new_blocking(uart.reborrow(), tx.reborrow(), rx.reborrow(), config);
// break on empty fifo
uart.send_break(20).await;
@@ -113,11 +113,11 @@ async fn main(_spawner: Spawner) {
// parity detection. here we bitbang to not require two uarts.
info!("test parity error detection");
{
let mut pin = Output::new(&mut tx, Level::High);
let mut pin = Output::new(tx.reborrow(), Level::High);
let mut config = Config::default();
config.baudrate = 1000;
config.parity = Parity::ParityEven;
let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config);
let mut uart = UartRx::new_blocking(uart.reborrow(), rx.reborrow(), config);
async fn chr(pin: &mut Output<'_>, v: u8, parity: u8) {
send(pin, v, Some(parity != 0)).await;
@@ -140,10 +140,10 @@ async fn main(_spawner: Spawner) {
// framing error detection. here we bitbang because there's no other way.
info!("test framing error detection");
{
let mut pin = Output::new(&mut tx, Level::High);
let mut pin = Output::new(tx.reborrow(), Level::High);
let mut config = Config::default();
config.baudrate = 1000;
let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config);
let mut uart = UartRx::new_blocking(uart.reborrow(), rx.reborrow(), config);
async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
if good {

View File

@@ -73,7 +73,15 @@ async fn main(_spawner: Spawner) {
let config = Config::default();
let tx_buf = &mut [0u8; 16];
let rx_buf = &mut [0u8; 16];
let mut uart = BufferedUart::new(&mut uart, Irqs, &mut tx, &mut rx, tx_buf, rx_buf, config);
let mut uart = BufferedUart::new(
uart.reborrow(),
Irqs,
tx.reborrow(),
rx.reborrow(),
tx_buf,
rx_buf,
config,
);
// Make sure we send more bytes than fits in the FIFO, to test the actual
// bufferedUart.
@@ -93,7 +101,15 @@ async fn main(_spawner: Spawner) {
let config = Config::default();
let tx_buf = &mut [0u8; 16];
let rx_buf = &mut [0u8; 16];
let mut uart = BufferedUart::new(&mut uart, Irqs, &mut tx, &mut rx, tx_buf, rx_buf, config);
let mut uart = BufferedUart::new(
uart.reborrow(),
Irqs,
tx.reborrow(),
rx.reborrow(),
tx_buf,
rx_buf,
config,
);
// Make sure we send more bytes than fits in the FIFO, to test the actual
// bufferedUart.
@@ -128,7 +144,15 @@ async fn main(_spawner: Spawner) {
config.baudrate = 1000;
let tx_buf = &mut [0u8; 16];
let rx_buf = &mut [0u8; 16];
let mut uart = BufferedUart::new(&mut uart, Irqs, &mut tx, &mut rx, tx_buf, rx_buf, config);
let mut uart = BufferedUart::new(
uart.reborrow(),
Irqs,
tx.reborrow(),
rx.reborrow(),
tx_buf,
rx_buf,
config,
);
// break on empty buffer
uart.send_break(20).await;
@@ -156,13 +180,13 @@ async fn main(_spawner: Spawner) {
// parity detection. here we bitbang to not require two uarts.
info!("test parity error detection");
{
let mut pin = Output::new(&mut tx, Level::High);
let mut pin = Output::new(tx.reborrow(), Level::High);
// choose a very slow baud rate to make tests reliable even with O0
let mut config = Config::default();
config.baudrate = 1000;
config.parity = Parity::ParityEven;
let rx_buf = &mut [0u8; 16];
let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config);
let mut uart = BufferedUartRx::new(uart.reborrow(), Irqs, rx.reborrow(), rx_buf, config);
async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) {
send(pin, v, Some(parity != 0)).await;
@@ -204,12 +228,12 @@ async fn main(_spawner: Spawner) {
// framing error detection. here we bitbang because there's no other way.
info!("test framing error detection");
{
let mut pin = Output::new(&mut tx, Level::High);
let mut pin = Output::new(tx.reborrow(), Level::High);
// choose a very slow baud rate to make tests reliable even with O0
let mut config = Config::default();
config.baudrate = 1000;
let rx_buf = &mut [0u8; 16];
let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config);
let mut uart = BufferedUartRx::new(uart.reborrow(), Irqs, rx.reborrow(), rx_buf, config);
async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
if good {

View File

@@ -65,12 +65,12 @@ async fn main(_spawner: Spawner) {
{
let config = Config::default();
let mut uart = Uart::new(
&mut uart,
&mut tx,
&mut rx,
uart.reborrow(),
tx.reborrow(),
rx.reborrow(),
Irqs,
&mut p.DMA_CH0,
&mut p.DMA_CH1,
p.DMA_CH0.reborrow(),
p.DMA_CH1.reborrow(),
config,
);
@@ -86,12 +86,12 @@ async fn main(_spawner: Spawner) {
{
let config = Config::default();
let mut uart = Uart::new(
&mut uart,
&mut tx,
&mut rx,
uart.reborrow(),
tx.reborrow(),
rx.reborrow(),
Irqs,
&mut p.DMA_CH0,
&mut p.DMA_CH1,
p.DMA_CH0.reborrow(),
p.DMA_CH1.reborrow(),
config,
);
@@ -115,12 +115,12 @@ async fn main(_spawner: Spawner) {
{
let config = Config::default();
let (mut tx, mut rx) = Uart::new(
&mut uart,
&mut tx,
&mut rx,
uart.reborrow(),
tx.reborrow(),
rx.reborrow(),
Irqs,
&mut p.DMA_CH0,
&mut p.DMA_CH1,
p.DMA_CH0.reborrow(),
p.DMA_CH1.reborrow(),
config,
)
.split();
@@ -156,12 +156,12 @@ async fn main(_spawner: Spawner) {
// parity detection. here we bitbang to not require two uarts.
info!("test parity error detection");
{
let mut pin = Output::new(&mut tx, Level::High);
let mut pin = Output::new(tx.reborrow(), Level::High);
// choose a very slow baud rate to make tests reliable even with O0
let mut config = Config::default();
config.baudrate = 1000;
config.parity = Parity::ParityEven;
let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config);
let mut uart = UartRx::new(uart.reborrow(), rx.reborrow(), Irqs, p.DMA_CH0.reborrow(), config);
async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) {
send(pin, v, Some(parity != 0)).await;
@@ -202,11 +202,11 @@ async fn main(_spawner: Spawner) {
// framing error detection. here we bitbang because there's no other way.
info!("test framing error detection");
{
let mut pin = Output::new(&mut tx, Level::High);
let mut pin = Output::new(tx.reborrow(), Level::High);
// choose a very slow baud rate to make tests reliable even with O0
let mut config = Config::default();
config.baudrate = 1000;
let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config);
let mut uart = UartRx::new(uart.reborrow(), rx.reborrow(), Irqs, p.DMA_CH0.reborrow(), config);
async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
if good {