Skip to content

Commit

Permalink
Merge pull request #8 from twitchyliquid64/master
Browse files Browse the repository at this point in the history
Set clock line to idle level on SPI initialization
  • Loading branch information
sajattack authored Sep 20, 2019
2 parents ed42bbb + 890f036 commit f70f7f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bitbang-hal"
version = "0.3.0"
version = "0.3.1"
authors = ["Paul Sajna <sajattack@gmail.com>"]
edition = "2018"
description = "Implements embedded-hal traits by bitbanging"
Expand Down
13 changes: 10 additions & 3 deletions src/spi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use embedded_hal::spi::{MODE_0, MODE_1, MODE_2, MODE_3};

use embedded_hal::digital::v2::{InputPin, OutputPin};
use embedded_hal::spi::{FullDuplex, Mode};
use embedded_hal::spi::{FullDuplex, Mode, Polarity};
use embedded_hal::timer::{CountDown, Periodic};
use nb::block;

Expand Down Expand Up @@ -56,15 +56,22 @@ where
sck: Sck,
timer: Timer,
) -> Self {
SPI {
let mut spi = SPI {
mode,
miso,
mosi,
sck,
timer,
read_val: None,
bit_order: BitOrder::default(),
}
};

match mode.polarity {
Polarity::IdleLow => spi.sck.set_low(),
Polarity::IdleHigh => spi.sck.set_high(),
}.unwrap_or(());

spi
}

pub fn set_bit_order(&mut self, order: BitOrder) {
Expand Down

0 comments on commit f70f7f9

Please sign in to comment.