riot_wrappers/gpio/
impl_1.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
52
53
54
55
56
57
58
59
60
61
62
63
64
use super::*;

use core::convert::Infallible;
use embedded_hal::digital::{ErrorType, InputPin, OutputPin, PinState};

impl ErrorType for InputGPIO {
    type Error = Infallible;
}

impl InputPin for InputGPIO {
    fn is_high(&mut self) -> Result<bool, Infallible> {
        Ok(InputGPIO::is_high(self))
    }

    fn is_low(&mut self) -> Result<bool, Infallible> {
        Ok(InputGPIO::is_low(self))
    }
}

impl ErrorType for OutputGPIO {
    type Error = Infallible;
}

impl OutputPin for OutputGPIO {
    fn set_high(&mut self) -> Result<(), Infallible> {
        Ok(OutputGPIO::set_high(self))
    }

    fn set_low(&mut self) -> Result<(), Infallible> {
        Ok(OutputGPIO::set_low(self))
    }

    fn set_state(&mut self, state: PinState) -> Result<(), Infallible> {
        Ok(OutputGPIO::set_state(self, state.into()))
    }
}

impl ErrorType for InOutGPIO {
    type Error = Infallible;
}

impl InputPin for InOutGPIO {
    fn is_high(&mut self) -> Result<bool, Infallible> {
        Ok(InOutGPIO::is_high(self))
    }

    fn is_low(&mut self) -> Result<bool, Infallible> {
        Ok(InOutGPIO::is_low(self))
    }
}

impl OutputPin for InOutGPIO {
    fn set_high(&mut self) -> Result<(), Infallible> {
        Ok(InOutGPIO::set_high(self))
    }

    fn set_low(&mut self) -> Result<(), Infallible> {
        Ok(InOutGPIO::set_low(self))
    }

    fn set_state(&mut self, state: PinState) -> Result<(), Infallible> {
        Ok(InOutGPIO::set_state(self, state.into()))
    }
}