|
1 | 1 | use core::convert::Infallible; |
2 | 2 |
|
3 | 3 | use super::{ |
4 | | - dynamic::PinModeError, marker, DynamicPin, ErasedPin, Input, OpenDrain, Output, |
5 | | - PartiallyErasedPin, Pin, PinMode, |
| 4 | + dynamic::PinModeError, marker, DynamicPin, ErasedPin, Output, PartiallyErasedPin, Pin, |
6 | 5 | }; |
7 | 6 |
|
8 | 7 | pub use embedded_hal_one::digital::PinState; |
9 | 8 | use embedded_hal_one::digital::{ |
10 | | - blocking::{InputPin, IoPin, OutputPin, StatefulOutputPin, ToggleableOutputPin}, |
11 | | - ErrorType, |
| 9 | + ErrorType, InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin, |
12 | 10 | }; |
13 | 11 |
|
14 | | -fn into_state(state: PinState) -> super::PinState { |
15 | | - match state { |
16 | | - PinState::Low => super::PinState::Low, |
17 | | - PinState::High => super::PinState::High, |
18 | | - } |
19 | | -} |
20 | | - |
21 | 12 | // Implementations for `Pin` |
22 | 13 | impl<const P: char, const N: u8, MODE> ErrorType for Pin<P, N, MODE> { |
23 | 14 | type Error = Infallible; |
|
72 | 63 | } |
73 | 64 | } |
74 | 65 |
|
75 | | -impl<const P: char, const N: u8> IoPin<Self, Self> for Pin<P, N, Output<OpenDrain>> { |
76 | | - type Error = Infallible; |
77 | | - fn into_input_pin(self) -> Result<Self, Self::Error> { |
78 | | - Ok(self) |
79 | | - } |
80 | | - fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> { |
81 | | - self.set_state(into_state(state)); |
82 | | - Ok(self) |
83 | | - } |
84 | | -} |
85 | | - |
86 | | -impl<const P: char, const N: u8, Otype> IoPin<Pin<P, N, Input>, Self> for Pin<P, N, Output<Otype>> |
87 | | -where |
88 | | - Output<Otype>: PinMode, |
89 | | -{ |
90 | | - type Error = Infallible; |
91 | | - fn into_input_pin(self) -> Result<Pin<P, N, Input>, Self::Error> { |
92 | | - Ok(self.into_input()) |
93 | | - } |
94 | | - fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> { |
95 | | - self.set_state(into_state(state)); |
96 | | - Ok(self) |
97 | | - } |
98 | | -} |
99 | | - |
100 | | -impl<const P: char, const N: u8, Otype> IoPin<Self, Pin<P, N, Output<Otype>>> for Pin<P, N, Input> |
101 | | -where |
102 | | - Output<Otype>: PinMode, |
103 | | -{ |
104 | | - type Error = Infallible; |
105 | | - fn into_input_pin(self) -> Result<Self, Self::Error> { |
106 | | - Ok(self) |
107 | | - } |
108 | | - fn into_output_pin(mut self, state: PinState) -> Result<Pin<P, N, Output<Otype>>, Self::Error> { |
109 | | - self._set_state(into_state(state)); |
110 | | - Ok(self.into_mode()) |
111 | | - } |
112 | | -} |
113 | | - |
114 | 66 | // Implementations for `ErasedPin` |
115 | 67 | impl<MODE> ErrorType for ErasedPin<MODE> { |
116 | 68 | type Error = core::convert::Infallible; |
|
0 commit comments