Skip to content

Commit

Permalink
nss pullup
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Apr 22, 2023
1 parent d215783 commit 41433f1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions examples/spi_slave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use panic_halt as _;

use crate::hal::spi::{Mode, Phase, Polarity};
use crate::hal::{pac, prelude::*};
use crate::hal::{gpio::Pull, pac, prelude::*};
use cortex_m::asm;
use cortex_m_rt::entry;
use stm32f4xx_hal as hal;
Expand All @@ -24,14 +24,21 @@ fn main() -> ! {

let gpioa = p.GPIOA.split();

let sck = gpioa.pa5;
let miso = gpioa.pa6;
let mosi = gpioa.pa7;
let sck = gpioa.pa5.internal_resistor(Pull::Up);
let miso = gpioa.pa6.internal_resistor(Pull::Down);
let mosi = gpioa.pa7.internal_resistor(Pull::Down);

// clock speed is determined by the master
let mut spi = p
.SPI1
.spi_slave((sck, miso, mosi, Some(gpioa.pa4.into())), MODE);
let nss = gpioa.pa4.internal_resistor(Pull::Up).into();
let mut spi = p.SPI1.spi_slave(
(
sck,
miso,
mosi,
Some(nss),
),
MODE,
);
// alternativelly you could use software `chip select`
// let mut spi = SpiSlave::new(p.SPI1, (sck, miso, mosi, None), MODE);
// spi.set_internal_nss(false);
Expand Down

0 comments on commit 41433f1

Please sign in to comment.