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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#![no_std]
mod pins;
pub use esp8266_hal::{self as hal, target};
pub use pins::Pins;
use bitbang_hal::i2c::I2cBB;
use esp8266_hal::ehal::timer::{CountDown, Periodic};
use esp8266_hal::gpio::*;
use esp8266_hal::prelude::*;
use esp8266_hal::spi::{SPI1Master, SpiClock};
use esp8266_hal::target::SPI1;
pub fn i2c_master<TIM>(
d1: Gpio5<Input<Floating>>,
d2: Gpio4<Input<Floating>>,
timer: TIM,
) -> I2cBB<Gpio5<Output<OpenDrain>>, Gpio4<Output<OpenDrain>>, TIM>
where
TIM: CountDown + Periodic,
{
let scl = d1.into_open_drain_output();
let sda = d2.into_open_drain_output();
I2cBB::new(scl, sda, timer)
}
pub fn spi_master(
spi1: SPI1,
d5: Gpio14<UnInitialized>,
d6: Gpio12<UnInitialized>,
d7: Gpio13<UART>,
frequency: SpiClock,
) -> SPI1Master {
let sck = d5.into_hspi();
let miso = d6.into_hspi();
let mosi = d7.into_hspi();
spi1.spi(sck, miso, mosi, frequency)
}