-
Notifications
You must be signed in to change notification settings - Fork 0
/
peripherals.rs
51 lines (46 loc) · 1.26 KB
/
peripherals.rs
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
use esp_idf_hal::{
adc::ADC1,
gpio::{AnyOutputPin, Gpio2},
modem::Modem,
prelude::Peripherals,
};
pub struct SystemPeripherals<ADC, GP> {
pub fan: FanPeripherals,
pub coil1: CoilPeripherals,
pub coil2: CoilPeripherals,
pub thermometer: ThermometerPeripherals<ADC, GP>,
pub modem: Modem,
}
impl SystemPeripherals<ADC1, Gpio2> {
pub fn take() -> Self {
let peripherals = Peripherals::take().unwrap();
SystemPeripherals {
fan: FanPeripherals {
power: peripherals.pins.gpio7.into(),
},
coil1: CoilPeripherals {
power: peripherals.pins.gpio8.into(),
},
coil2: CoilPeripherals {
power: peripherals.pins.gpio9.into(),
},
thermometer: ThermometerPeripherals {
adc: peripherals.adc1,
voltage: peripherals.pins.gpio2,
vcc: peripherals.pins.gpio10.into(),
},
modem: peripherals.modem,
}
}
}
pub struct FanPeripherals {
pub power: AnyOutputPin,
}
pub struct CoilPeripherals {
pub power: AnyOutputPin,
}
pub struct ThermometerPeripherals<ADC, GP> {
pub adc: ADC,
pub voltage: GP,
pub vcc: AnyOutputPin,
}