esp-hal/examples/src/bin/embassy_parl_io_rx.rs
Sergio Gasquez Arcos b5f0246129
Reordered RX-TX pairs to be consistent (#2074)
* feat: Update rx-tx order in i2s

* feat: Update rx-tx order in dma macros

* feat: Update rx-tx order in spi

* feat: Update rx-tx order in aes

* feat: Update rx-tx order in mem2mem

* feat: Update rx-tx order in twai and split methods

* feat: Update rx-tx order in twai

* feat: Update rx-tx order in twai and uart docs

* docs: Add sentence about order

* docs: Update changelog

* feat: Update rx-tx order in embassy_interrupt_spi_dma tests

* style: Rustfmt

* docs: Migrating guide

* fix: Typo

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* fix: Diff

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* fix: Tests rx-tx order

* fix: Update new_with_default_pins order

* feat: Update rx/tx order in hil_test::common_test_pins!

* feat: Update dma_extmem2mem example

* fix: Revert deleted input arg

* style: rustfmt

* feat: Disable test_asymmetric_dma_transfer for S2

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2024-09-06 09:56:10 +00:00

68 lines
1.8 KiB
Rust

//! This shows using Parallel IO to input 4 bit parallel data at 1MHz clock
//! rate.
//!
//! The following wiring is assumed:
//! - Data pins => GPIO1, GPIO2, GPIO3, and GPIO4.
//% CHIPS: esp32c6 esp32h2
//% FEATURES: embassy embassy-generic-timers
#![no_std]
#![no_main]
use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use esp_backtrace as _;
use esp_hal::{
dma::{Dma, DmaPriority},
dma_buffers,
gpio::Io,
parl_io::{no_clk_pin, BitPackOrder, ParlIoRxOnly, RxFourBits},
prelude::*,
timer::systimer::{SystemTimer, Target},
};
use esp_println::println;
#[esp_hal_embassy::main]
async fn main(_spawner: Spawner) {
esp_println::println!("Init!");
let peripherals = esp_hal::init(esp_hal::Config::default());
let systimer = SystemTimer::new(peripherals.SYSTIMER).split::<Target>();
esp_hal_embassy::init(systimer.alarm0);
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(0, 32000);
let dma = Dma::new(peripherals.DMA);
let dma_channel = dma.channel0;
let mut rx_pins = RxFourBits::new(io.pins.gpio1, io.pins.gpio2, io.pins.gpio3, io.pins.gpio4);
let parl_io = ParlIoRxOnly::new(
peripherals.PARL_IO,
dma_channel.configure_for_async(false, DmaPriority::Priority0),
rx_descriptors,
1.MHz(),
)
.unwrap();
let mut parl_io_rx = parl_io
.rx
.with_config(&mut rx_pins, no_clk_pin(), BitPackOrder::Msb, Some(0xfff))
.unwrap();
let buffer = rx_buffer;
loop {
parl_io_rx.read_dma_async(buffer).await.unwrap();
println!(
"Received: {:02x?} ... {:02x?}",
&buffer[..30],
&buffer[(buffer.len() - 30)..]
);
Timer::after(Duration::from_millis(500)).await;
}
}