1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![no_std]
use embedded_hal::{
blocking::spi::{Transfer, Write},
digital::v2::OutputPin,
spi::{Mode, Phase, Polarity}
};
pub const MODE: Mode = Mode {
phase: Phase::CaptureOnSecondTransition,
polarity: Polarity::IdleLow,
};
pub struct Tmc5160<SPI, CS> {
spi: SPI,
cs: CS,
}
impl<SPI, CS, E> Tmc5160<SPI, CS>
where
SPI: Transfer<u8, Error = E> + Write<u8, Error = E>,
CS: OutputPin,
{
pub fn new(spi: SPI, cs: CS) -> Result<Self, E> {
Ok(Tmc5160 { spi, cs })
}
}