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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
pub use crate::rp::rp_dpin_t as Pin;
pub fn reset() -> crate::Result<()>
{
handle_unsafe!(
crate::rp::rp_DpinReset()
)
}
pub fn set_state(pin: Pin, state: super::State) -> crate::Result<()>
{
handle_unsafe!(
crate::rp::rp_DpinSetState(pin, state)
)
}
pub fn state(pin: Pin) -> crate::Result<super::State>
{
let mut state = super::State::RP_LOW;
match handle_unsafe!(
crate::rp::rp_DpinGetState(pin, &mut state)
) {
Ok(_) => Ok(state),
Err(err) => Err(err),
}
}
pub fn set_direction(pin: Pin, direction: super::Direction) -> crate::Result<()>
{
handle_unsafe!(
crate::rp::rp_DpinSetDirection(pin, direction)
)
}
pub fn direction(pin: Pin) -> crate::Result<super::Direction>
{
let mut direction = super::Direction::RP_IN;
match handle_unsafe!(
crate::rp::rp_DpinGetDirection(pin, &mut direction)
) {
Ok(_) => Ok(direction),
Err(err) => Err(err),
}
}