Fix SPI loopback exmaple -- mixed up SDI and SDO (#72)

* Fix SPI loopback exmaple

Fix SDI and SDO been mixed up in example
Update to new names

* change SPI println back to orignal

* run cargo fmt
This commit is contained in:
Brendan Horan 2022-05-16 22:22:58 +09:30 committed by GitHub
parent 719eea4777
commit 076390200a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,15 @@
//! SPI loopback test //! SPI loopback test
//! //!
//! Folowing pins are used: //! Folowing pins are used:
//! SCLK GPIO6 //! SCLK GPIO6
//! MISO GPIO2 //! SDI GPIO2
//! MOSI GPIO7 //! SDO GPIO7
//! CS GPIO10 //! CS GPIO10
//! //!
//! Depending on your target and the board you are using you have to change the pins. //! Depending on your target and the board you are using you have to change the pins.
//! //!
//! This example transfers data via SPI. //! This example transfers data via SPI.
//! Connect MISO and MOSI pins to see the outgoing data is read as incoming data. //! Connect SDI and SDO pins to see the outgoing data is read as incoming data.
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
@ -27,8 +27,8 @@ fn main() -> anyhow::Result<()> {
let spi = peripherals.spi2; let spi = peripherals.spi2;
let sclk = peripherals.pins.gpio6; let sclk = peripherals.pins.gpio6;
let miso = peripherals.pins.gpio2; let serial_in = peripherals.pins.gpio2; //SDI
let mosi = peripherals.pins.gpio7; let serial_out = peripherals.pins.gpio7; //SDO
let cs = peripherals.pins.gpio10; let cs = peripherals.pins.gpio10;
println!("Starting SPI loopback test"); println!("Starting SPI loopback test");
@ -37,8 +37,8 @@ fn main() -> anyhow::Result<()> {
spi, spi,
spi::Pins { spi::Pins {
sclk, sclk,
sdo: miso, sdo: serial_out,
sdi: Some(mosi), sdi: Some(serial_in),
cs: Some(cs), cs: Some(cs),
}, },
config, config,