diff options
| author | chemicstry <[email protected]> | 2022-07-13 02:45:37 +0300 |
|---|---|---|
| committer | chemicstry <[email protected]> | 2022-07-13 02:45:37 +0300 |
| commit | 53e40860c17b2525ad4a8d25d6d0aa7fe4da789b (patch) | |
| tree | cfd70f1d698277e98422185e3e7c73e596d6176c | |
| parent | a335589f345c32cd74c00af63366fc197ca410ab (diff) | |
Move all gpio logic to Flex
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 9 | ||||
| -rw-r--r-- | embassy-rp/src/gpio.rs | 9 | ||||
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 20 |
3 files changed, 13 insertions, 25 deletions
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index 3e3e14b5b..fd4ae2ec3 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -59,7 +59,7 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 59 | /// Returns current pin level | 59 | /// Returns current pin level |
| 60 | #[inline] | 60 | #[inline] |
| 61 | pub fn get_level(&self) -> Level { | 61 | pub fn get_level(&self) -> Level { |
| 62 | self.pin.is_high().into() | 62 | self.pin.get_level() |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 | ||
| @@ -145,10 +145,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 145 | /// Set the output level. | 145 | /// Set the output level. |
| 146 | #[inline] | 146 | #[inline] |
| 147 | pub fn set_level(&mut self, level: Level) { | 147 | pub fn set_level(&mut self, level: Level) { |
| 148 | match level { | 148 | self.pin.set_level(level) |
| 149 | Level::Low => self.pin.set_low(), | ||
| 150 | Level::High => self.pin.set_high(), | ||
| 151 | } | ||
| 152 | } | 149 | } |
| 153 | 150 | ||
| 154 | /// Is the output pin set as high? | 151 | /// Is the output pin set as high? |
| @@ -166,7 +163,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 166 | /// What level output is set to | 163 | /// What level output is set to |
| 167 | #[inline] | 164 | #[inline] |
| 168 | pub fn get_output_level(&self) -> Level { | 165 | pub fn get_output_level(&self) -> Level { |
| 169 | self.pin.is_set_high().into() | 166 | self.pin.get_output_level() |
| 170 | } | 167 | } |
| 171 | } | 168 | } |
| 172 | 169 | ||
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index aa1508e9f..c6dbb3d48 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -73,7 +73,7 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 73 | /// Returns current pin level | 73 | /// Returns current pin level |
| 74 | #[inline] | 74 | #[inline] |
| 75 | pub fn get_level(&self) -> Level { | 75 | pub fn get_level(&self) -> Level { |
| 76 | self.pin.is_high().into() | 76 | self.pin.get_level() |
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | 79 | ||
| @@ -109,10 +109,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 109 | /// Set the output level. | 109 | /// Set the output level. |
| 110 | #[inline] | 110 | #[inline] |
| 111 | pub fn set_level(&mut self, level: Level) { | 111 | pub fn set_level(&mut self, level: Level) { |
| 112 | match level { | 112 | self.pin.set_level(level) |
| 113 | Level::Low => self.pin.set_low(), | ||
| 114 | Level::High => self.pin.set_high(), | ||
| 115 | } | ||
| 116 | } | 113 | } |
| 117 | 114 | ||
| 118 | /// Is the output pin set as high? | 115 | /// Is the output pin set as high? |
| @@ -130,7 +127,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 130 | /// What level output is set to | 127 | /// What level output is set to |
| 131 | #[inline] | 128 | #[inline] |
| 132 | pub fn get_output_level(&self) -> Level { | 129 | pub fn get_output_level(&self) -> Level { |
| 133 | self.pin.is_set_high().into() | 130 | self.pin.get_output_level() |
| 134 | } | 131 | } |
| 135 | 132 | ||
| 136 | /// Toggle pin output | 133 | /// Toggle pin output |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 1ba481e6e..1059ebf86 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -303,7 +303,7 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 303 | 303 | ||
| 304 | #[inline] | 304 | #[inline] |
| 305 | pub fn get_level(&self) -> Level { | 305 | pub fn get_level(&self) -> Level { |
| 306 | self.pin.is_high().into() | 306 | self.pin.get_level() |
| 307 | } | 307 | } |
| 308 | } | 308 | } |
| 309 | 309 | ||
| @@ -365,10 +365,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 365 | /// Set the output level. | 365 | /// Set the output level. |
| 366 | #[inline] | 366 | #[inline] |
| 367 | pub fn set_level(&mut self, level: Level) { | 367 | pub fn set_level(&mut self, level: Level) { |
| 368 | match level { | 368 | self.pin.set_level(level) |
| 369 | Level::Low => self.pin.set_low(), | ||
| 370 | Level::High => self.pin.set_high(), | ||
| 371 | } | ||
| 372 | } | 369 | } |
| 373 | 370 | ||
| 374 | /// Is the output pin set as high? | 371 | /// Is the output pin set as high? |
| @@ -386,7 +383,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 386 | /// What level output is set to | 383 | /// What level output is set to |
| 387 | #[inline] | 384 | #[inline] |
| 388 | pub fn get_output_level(&self) -> Level { | 385 | pub fn get_output_level(&self) -> Level { |
| 389 | self.pin.is_set_high().into() | 386 | self.pin.get_output_level() |
| 390 | } | 387 | } |
| 391 | 388 | ||
| 392 | /// Toggle pin output | 389 | /// Toggle pin output |
| @@ -428,7 +425,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 428 | /// Returns current pin level | 425 | /// Returns current pin level |
| 429 | #[inline] | 426 | #[inline] |
| 430 | pub fn get_level(&self) -> Level { | 427 | pub fn get_level(&self) -> Level { |
| 431 | self.pin.is_high().into() | 428 | self.pin.get_level() |
| 432 | } | 429 | } |
| 433 | 430 | ||
| 434 | /// Set the output as high. | 431 | /// Set the output as high. |
| @@ -446,16 +443,13 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 446 | /// Set the output level. | 443 | /// Set the output level. |
| 447 | #[inline] | 444 | #[inline] |
| 448 | pub fn set_level(&mut self, level: Level) { | 445 | pub fn set_level(&mut self, level: Level) { |
| 449 | match level { | 446 | self.pin.set_level(level); |
| 450 | Level::Low => self.pin.set_low(), | ||
| 451 | Level::High => self.pin.set_high(), | ||
| 452 | } | ||
| 453 | } | 447 | } |
| 454 | 448 | ||
| 455 | /// Is the output pin set as high? | 449 | /// Is the output pin set as high? |
| 456 | #[inline] | 450 | #[inline] |
| 457 | pub fn is_set_high(&self) -> bool { | 451 | pub fn is_set_high(&self) -> bool { |
| 458 | !self.is_set_low() | 452 | self.pin.is_set_high() |
| 459 | } | 453 | } |
| 460 | 454 | ||
| 461 | /// Is the output pin set as low? | 455 | /// Is the output pin set as low? |
| @@ -467,7 +461,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 467 | /// What level output is set to | 461 | /// What level output is set to |
| 468 | #[inline] | 462 | #[inline] |
| 469 | pub fn get_output_level(&self) -> Level { | 463 | pub fn get_output_level(&self) -> Level { |
| 470 | self.pin.is_set_high().into() | 464 | self.pin.get_output_level() |
| 471 | } | 465 | } |
| 472 | 466 | ||
| 473 | /// Toggle pin output | 467 | /// Toggle pin output |
