diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-01-13 21:15:27 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-01-13 23:56:39 +0100 |
| commit | 3ca01cba8d2ffbd6f7479b436f4384f002a381eb (patch) | |
| tree | 04e957d55050acea5dd4d0c2becc6a0c77c7d72e | |
| parent | ecb4f8fb00e8e1c220cfb24252e562b80f8de457 (diff) | |
nrf/gpio: Rename FlexPin to Flex.
FlexPin sounds like it's an owned pin singleton, like AnyPin or NoPin.
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 24 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 8 |
2 files changed, 16 insertions, 16 deletions
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index ddc84cf5d..8a3e8a1b0 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -37,12 +37,12 @@ pub enum Pull { | |||
| 37 | 37 | ||
| 38 | /// GPIO input driver. | 38 | /// GPIO input driver. |
| 39 | pub struct Input<'d, T: Pin> { | 39 | pub struct Input<'d, T: Pin> { |
| 40 | pub(crate) pin: FlexPin<'d, T>, | 40 | pub(crate) pin: Flex<'d, T>, |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | impl<'d, T: Pin> Input<'d, T> { | 43 | impl<'d, T: Pin> Input<'d, T> { |
| 44 | pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self { | 44 | pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self { |
| 45 | let mut pin = FlexPin::new(pin); | 45 | let mut pin = Flex::new(pin); |
| 46 | pin.set_as_input(pull); | 46 | pin.set_as_input(pull); |
| 47 | 47 | ||
| 48 | Self { pin } | 48 | Self { pin } |
| @@ -102,7 +102,7 @@ pub enum OutputDrive { | |||
| 102 | 102 | ||
| 103 | /// GPIO output driver. | 103 | /// GPIO output driver. |
| 104 | pub struct Output<'d, T: Pin> { | 104 | pub struct Output<'d, T: Pin> { |
| 105 | pub(crate) pin: FlexPin<'d, T>, | 105 | pub(crate) pin: Flex<'d, T>, |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | impl<'d, T: Pin> Output<'d, T> { | 108 | impl<'d, T: Pin> Output<'d, T> { |
| @@ -111,7 +111,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 111 | initial_output: Level, | 111 | initial_output: Level, |
| 112 | drive: OutputDrive, | 112 | drive: OutputDrive, |
| 113 | ) -> Self { | 113 | ) -> Self { |
| 114 | let mut pin = FlexPin::new(pin); | 114 | let mut pin = Flex::new(pin); |
| 115 | match initial_output { | 115 | match initial_output { |
| 116 | Level::High => pin.set_high(), | 116 | Level::High => pin.set_high(), |
| 117 | Level::Low => pin.set_low(), | 117 | Level::Low => pin.set_low(), |
| @@ -169,13 +169,13 @@ impl<'d, T: Pin> StatefulOutputPin for Output<'d, T> { | |||
| 169 | /// This pin can either be a disconnected, input, or output pin. The level register bit will remain | 169 | /// This pin can either be a disconnected, input, or output pin. The level register bit will remain |
| 170 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output | 170 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output |
| 171 | /// mode. | 171 | /// mode. |
| 172 | pub struct FlexPin<'d, T: Pin> { | 172 | pub struct Flex<'d, T: Pin> { |
| 173 | pub(crate) pin: T, | 173 | pub(crate) pin: T, |
| 174 | phantom: PhantomData<&'d mut T>, | 174 | phantom: PhantomData<&'d mut T>, |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | impl<'d, T: Pin> FlexPin<'d, T> { | 177 | impl<'d, T: Pin> Flex<'d, T> { |
| 178 | /// Wrap the pin in a `FlexPin`. | 178 | /// Wrap the pin in a `Flex`. |
| 179 | /// | 179 | /// |
| 180 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed | 180 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed |
| 181 | /// before the pin is put into output mode. | 181 | /// before the pin is put into output mode. |
| @@ -270,16 +270,16 @@ impl<'d, T: Pin> FlexPin<'d, T> { | |||
| 270 | } | 270 | } |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | impl<'d, T: Pin> Drop for FlexPin<'d, T> { | 273 | impl<'d, T: Pin> Drop for Flex<'d, T> { |
| 274 | fn drop(&mut self) { | 274 | fn drop(&mut self) { |
| 275 | self.pin.conf().reset(); | 275 | self.pin.conf().reset(); |
| 276 | } | 276 | } |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | /// Implement [`InputPin`] for [`FlexPin`]; | 279 | /// Implement [`InputPin`] for [`Flex`]; |
| 280 | /// | 280 | /// |
| 281 | /// If the pin is not in input mode the result is unspecified. | 281 | /// If the pin is not in input mode the result is unspecified. |
| 282 | impl<'d, T: Pin> InputPin for FlexPin<'d, T> { | 282 | impl<'d, T: Pin> InputPin for Flex<'d, T> { |
| 283 | type Error = Infallible; | 283 | type Error = Infallible; |
| 284 | 284 | ||
| 285 | fn is_high(&self) -> Result<bool, Self::Error> { | 285 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -291,7 +291,7 @@ impl<'d, T: Pin> InputPin for FlexPin<'d, T> { | |||
| 291 | } | 291 | } |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | impl<'d, T: Pin> OutputPin for FlexPin<'d, T> { | 294 | impl<'d, T: Pin> OutputPin for Flex<'d, T> { |
| 295 | type Error = Infallible; | 295 | type Error = Infallible; |
| 296 | 296 | ||
| 297 | fn set_high(&mut self) -> Result<(), Self::Error> { | 297 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| @@ -303,7 +303,7 @@ impl<'d, T: Pin> OutputPin for FlexPin<'d, T> { | |||
| 303 | } | 303 | } |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | impl<'d, T: Pin> StatefulOutputPin for FlexPin<'d, T> { | 306 | impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { |
| 307 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 307 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 308 | Ok(self.is_set_high()) | 308 | Ok(self.is_set_high()) |
| 309 | } | 309 | } |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 99dfd1ebd..8e7af2666 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -9,7 +9,7 @@ use embedded_hal::digital::v2::InputPin; | |||
| 9 | use futures::future::poll_fn; | 9 | use futures::future::poll_fn; |
| 10 | 10 | ||
| 11 | use crate::gpio::sealed::Pin as _; | 11 | use crate::gpio::sealed::Pin as _; |
| 12 | use crate::gpio::{AnyPin, FlexPin, Input, Output, Pin as GpioPin}; | 12 | use crate::gpio::{AnyPin, Flex, Input, Output, Pin as GpioPin}; |
| 13 | use crate::pac; | 13 | use crate::pac; |
| 14 | use crate::ppi::{Event, Task}; | 14 | use crate::ppi::{Event, Task}; |
| 15 | use crate::{interrupt, peripherals}; | 15 | use crate::{interrupt, peripherals}; |
| @@ -375,7 +375,7 @@ impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for Input<'d, T> { | |||
| 375 | } | 375 | } |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for FlexPin<'d, T> { | 378 | impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for Flex<'d, T> { |
| 379 | type Future<'a> | 379 | type Future<'a> |
| 380 | where | 380 | where |
| 381 | Self: 'a, | 381 | Self: 'a, |
| @@ -391,7 +391,7 @@ impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for FlexPin<'d, T> { | |||
| 391 | } | 391 | } |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for FlexPin<'d, T> { | 394 | impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for Flex<'d, T> { |
| 395 | type Future<'a> | 395 | type Future<'a> |
| 396 | where | 396 | where |
| 397 | Self: 'a, | 397 | Self: 'a, |
| @@ -407,7 +407,7 @@ impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for FlexPin<'d, T> { | |||
| 407 | } | 407 | } |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for FlexPin<'d, T> { | 410 | impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for Flex<'d, T> { |
| 411 | type Future<'a> | 411 | type Future<'a> |
| 412 | where | 412 | where |
| 413 | Self: 'a, | 413 | Self: 'a, |
