mirror of
https://github.com/esp-rs/esp-idf-hal.git
synced 2025-09-29 21:31:17 +00:00
Fix examples
This commit is contained in:
parent
9f7b96804f
commit
5667be95ac
@ -47,7 +47,7 @@ fn main() -> anyhow::Result<()> {
|
||||
let _ = std::thread::spawn(move || loop {
|
||||
println!("Rx Loop");
|
||||
|
||||
let mut pulses: [(Pulse::zero(), Pulse::zero()); 250];
|
||||
let mut pulses = [(Pulse::zero(), Pulse::zero()); 250];
|
||||
|
||||
// See sdkconfig.defaults to determine the tick time value ( default is one tick = 10 milliseconds)
|
||||
// Set ticks_to_wait to 0 for non-blocking
|
||||
|
@ -12,8 +12,6 @@
|
||||
//! This example transfers data via SPI.
|
||||
//! Connect SDI and SDO pins to see the outgoing data is read as incoming data.
|
||||
|
||||
use embedded_hal::spi::SpiDevice;
|
||||
|
||||
use esp_idf_hal::delay::FreeRtos;
|
||||
use esp_idf_hal::peripherals::Peripherals;
|
||||
use esp_idf_hal::prelude::*;
|
||||
@ -33,13 +31,13 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
println!("Starting SPI loopback test");
|
||||
|
||||
let mut spi = SpiDriver::new::<SPI2>(spi, sclk, serial_out, Some(serial_in), Dma::Disabled)?;
|
||||
let driver = SpiDriver::new::<SPI2>(spi, sclk, serial_out, Some(serial_in), Dma::Disabled)?;
|
||||
|
||||
let config_1 = config::Config::new().baudrate(26.MHz().into());
|
||||
let mut device_1 = SpiDeviceDriver::new(&spi, Some(cs_1), &config_1)?;
|
||||
let mut device_1 = SpiDeviceDriver::new(&driver, Some(cs_1), &config_1)?;
|
||||
|
||||
let config_2 = config::Config::new().baudrate(13.MHz().into());
|
||||
let mut device_2 = SpiDeviceDriver::new(&spi, Some(cs_2), &config_2)?;
|
||||
let mut device_2 = SpiDeviceDriver::new(&driver, Some(cs_2), &config_2)?;
|
||||
|
||||
let mut read = [0u8; 4];
|
||||
let write = [0xde, 0xad, 0xbe, 0xef];
|
||||
@ -53,7 +51,7 @@ fn main() -> anyhow::Result<()> {
|
||||
println!("Device 1: Wrote {:x?}, read {:x?}", write, read);
|
||||
|
||||
println!("Device 2: To write {:x?} ... ", in_place_buf);
|
||||
device_2.transaction(|bus| bus.transfer_in_place(&mut in_place_buf));
|
||||
device_2.transaction(|bus| bus.transfer_in_place(&mut in_place_buf))?;
|
||||
println!("... read {:x?}", in_place_buf);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user