diff options
23 files changed, 157 insertions, 192 deletions
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs index 54b87662e..d0c9f4907 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs | |||
| @@ -9,7 +9,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 9 | fn main() -> ! { | 9 | fn main() -> ! { |
| 10 | let p = embassy_stm32::init(Default::default()); | 10 | let p = embassy_stm32::init(Default::default()); |
| 11 | let mut led = Output::new(p.PB14, Level::High, Speed::VeryHigh); | 11 | let mut led = Output::new(p.PB14, Level::High, Speed::VeryHigh); |
| 12 | let mut button = Input::new(p.PC13, Pull::Up); | 12 | let button = Input::new(p.PC13, Pull::Up); |
| 13 | 13 | ||
| 14 | loop { | 14 | loop { |
| 15 | if button.is_low() { | 15 | if button.is_low() { |
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index 27c18383f..eabf409dd 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -52,19 +52,19 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 52 | 52 | ||
| 53 | /// Get whether the pin input level is high. | 53 | /// Get whether the pin input level is high. |
| 54 | #[inline] | 54 | #[inline] |
| 55 | pub fn is_high(&mut self) -> bool { | 55 | pub fn is_high(&self) -> bool { |
| 56 | self.pin.is_high() | 56 | self.pin.is_high() |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /// Get whether the pin input level is low. | 59 | /// Get whether the pin input level is low. |
| 60 | #[inline] | 60 | #[inline] |
| 61 | pub fn is_low(&mut self) -> bool { | 61 | pub fn is_low(&self) -> bool { |
| 62 | self.pin.is_low() | 62 | self.pin.is_low() |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /// Get the pin input level. | 65 | /// Get the pin input level. |
| 66 | #[inline] | 66 | #[inline] |
| 67 | pub fn get_level(&mut self) -> Level { | 67 | pub fn get_level(&self) -> Level { |
| 68 | self.pin.get_level() | 68 | self.pin.get_level() |
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| @@ -166,19 +166,19 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 166 | 166 | ||
| 167 | /// Get whether the output level is set to high. | 167 | /// Get whether the output level is set to high. |
| 168 | #[inline] | 168 | #[inline] |
| 169 | pub fn is_set_high(&mut self) -> bool { | 169 | pub fn is_set_high(&self) -> bool { |
| 170 | self.pin.is_set_high() | 170 | self.pin.is_set_high() |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | /// Get whether the output level is set to low. | 173 | /// Get whether the output level is set to low. |
| 174 | #[inline] | 174 | #[inline] |
| 175 | pub fn is_set_low(&mut self) -> bool { | 175 | pub fn is_set_low(&self) -> bool { |
| 176 | self.pin.is_set_low() | 176 | self.pin.is_set_low() |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | /// Get the current output level. | 179 | /// Get the current output level. |
| 180 | #[inline] | 180 | #[inline] |
| 181 | pub fn get_output_level(&mut self) -> Level { | 181 | pub fn get_output_level(&self) -> Level { |
| 182 | self.pin.get_output_level() | 182 | self.pin.get_output_level() |
| 183 | } | 183 | } |
| 184 | } | 184 | } |
| @@ -283,24 +283,19 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 283 | 283 | ||
| 284 | /// Get whether the pin input level is high. | 284 | /// Get whether the pin input level is high. |
| 285 | #[inline] | 285 | #[inline] |
| 286 | pub fn is_high(&mut self) -> bool { | 286 | pub fn is_high(&self) -> bool { |
| 287 | !self.is_low() | 287 | !self.is_low() |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | /// Get whether the pin input level is low. | 290 | /// Get whether the pin input level is low. |
| 291 | #[inline] | 291 | #[inline] |
| 292 | pub fn is_low(&mut self) -> bool { | 292 | pub fn is_low(&self) -> bool { |
| 293 | self.ref_is_low() | ||
| 294 | } | ||
| 295 | |||
| 296 | #[inline] | ||
| 297 | pub(crate) fn ref_is_low(&self) -> bool { | ||
| 298 | self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0 | 293 | self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0 |
| 299 | } | 294 | } |
| 300 | 295 | ||
| 301 | /// Get the pin input level. | 296 | /// Get the pin input level. |
| 302 | #[inline] | 297 | #[inline] |
| 303 | pub fn get_level(&mut self) -> Level { | 298 | pub fn get_level(&self) -> Level { |
| 304 | self.is_high().into() | 299 | self.is_high().into() |
| 305 | } | 300 | } |
| 306 | 301 | ||
| @@ -337,24 +332,19 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 337 | 332 | ||
| 338 | /// Get whether the output level is set to high. | 333 | /// Get whether the output level is set to high. |
| 339 | #[inline] | 334 | #[inline] |
| 340 | pub fn is_set_high(&mut self) -> bool { | 335 | pub fn is_set_high(&self) -> bool { |
| 341 | !self.is_set_low() | 336 | !self.is_set_low() |
| 342 | } | 337 | } |
| 343 | 338 | ||
| 344 | /// Get whether the output level is set to low. | 339 | /// Get whether the output level is set to low. |
| 345 | #[inline] | 340 | #[inline] |
| 346 | pub fn is_set_low(&mut self) -> bool { | 341 | pub fn is_set_low(&self) -> bool { |
| 347 | self.ref_is_set_low() | ||
| 348 | } | ||
| 349 | |||
| 350 | #[inline] | ||
| 351 | pub(crate) fn ref_is_set_low(&self) -> bool { | ||
| 352 | self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0 | 342 | self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0 |
| 353 | } | 343 | } |
| 354 | 344 | ||
| 355 | /// Get the current output level. | 345 | /// Get the current output level. |
| 356 | #[inline] | 346 | #[inline] |
| 357 | pub fn get_output_level(&mut self) -> Level { | 347 | pub fn get_output_level(&self) -> Level { |
| 358 | self.is_set_high().into() | 348 | self.is_set_high().into() |
| 359 | } | 349 | } |
| 360 | } | 350 | } |
| @@ -524,11 +514,11 @@ mod eh02 { | |||
| 524 | type Error = Infallible; | 514 | type Error = Infallible; |
| 525 | 515 | ||
| 526 | fn is_high(&self) -> Result<bool, Self::Error> { | 516 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 527 | Ok(!self.pin.ref_is_low()) | 517 | Ok(self.is_high()) |
| 528 | } | 518 | } |
| 529 | 519 | ||
| 530 | fn is_low(&self) -> Result<bool, Self::Error> { | 520 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 531 | Ok(self.pin.ref_is_low()) | 521 | Ok(self.is_low()) |
| 532 | } | 522 | } |
| 533 | } | 523 | } |
| 534 | 524 | ||
| @@ -546,11 +536,11 @@ mod eh02 { | |||
| 546 | 536 | ||
| 547 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { | 537 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { |
| 548 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 538 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 549 | Ok(!self.pin.ref_is_set_low()) | 539 | Ok(self.is_set_high()) |
| 550 | } | 540 | } |
| 551 | 541 | ||
| 552 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 542 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 553 | Ok(self.pin.ref_is_set_low()) | 543 | Ok(self.is_set_low()) |
| 554 | } | 544 | } |
| 555 | } | 545 | } |
| 556 | 546 | ||
| @@ -570,11 +560,11 @@ mod eh02 { | |||
| 570 | type Error = Infallible; | 560 | type Error = Infallible; |
| 571 | 561 | ||
| 572 | fn is_high(&self) -> Result<bool, Self::Error> { | 562 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 573 | Ok(!self.ref_is_low()) | 563 | Ok(self.is_high()) |
| 574 | } | 564 | } |
| 575 | 565 | ||
| 576 | fn is_low(&self) -> Result<bool, Self::Error> { | 566 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 577 | Ok(self.ref_is_low()) | 567 | Ok(self.is_low()) |
| 578 | } | 568 | } |
| 579 | } | 569 | } |
| 580 | 570 | ||
| @@ -592,11 +582,11 @@ mod eh02 { | |||
| 592 | 582 | ||
| 593 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { | 583 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { |
| 594 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 584 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 595 | Ok(!self.ref_is_set_low()) | 585 | Ok(self.is_set_high()) |
| 596 | } | 586 | } |
| 597 | 587 | ||
| 598 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 588 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 599 | Ok(self.ref_is_set_low()) | 589 | Ok(self.is_set_low()) |
| 600 | } | 590 | } |
| 601 | } | 591 | } |
| 602 | 592 | ||
| @@ -616,11 +606,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | |||
| 616 | 606 | ||
| 617 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 607 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { |
| 618 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 608 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 619 | Ok(self.is_high()) | 609 | Ok((*self).is_high()) |
| 620 | } | 610 | } |
| 621 | 611 | ||
| 622 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 612 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 623 | Ok(self.is_low()) | 613 | Ok((*self).is_low()) |
| 624 | } | 614 | } |
| 625 | } | 615 | } |
| 626 | 616 | ||
| @@ -640,11 +630,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | |||
| 640 | 630 | ||
| 641 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 631 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { |
| 642 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 632 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 643 | Ok(self.is_set_high()) | 633 | Ok((*self).is_set_high()) |
| 644 | } | 634 | } |
| 645 | 635 | ||
| 646 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 636 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 647 | Ok(self.is_set_low()) | 637 | Ok((*self).is_set_low()) |
| 648 | } | 638 | } |
| 649 | } | 639 | } |
| 650 | 640 | ||
| @@ -657,11 +647,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | |||
| 657 | /// If the pin is not in input mode the result is unspecified. | 647 | /// If the pin is not in input mode the result is unspecified. |
| 658 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | 648 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { |
| 659 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 649 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 660 | Ok(self.is_high()) | 650 | Ok((*self).is_high()) |
| 661 | } | 651 | } |
| 662 | 652 | ||
| 663 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 653 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 664 | Ok(self.is_low()) | 654 | Ok((*self).is_low()) |
| 665 | } | 655 | } |
| 666 | } | 656 | } |
| 667 | 657 | ||
| @@ -677,10 +667,10 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | |||
| 677 | 667 | ||
| 678 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 668 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { |
| 679 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 669 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 680 | Ok(self.is_set_high()) | 670 | Ok((*self).is_set_high()) |
| 681 | } | 671 | } |
| 682 | 672 | ||
| 683 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 673 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 684 | Ok(self.is_set_low()) | 674 | Ok((*self).is_set_low()) |
| 685 | } | 675 | } |
| 686 | } | 676 | } |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 07196abf7..8020b8dc2 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -243,7 +243,7 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { | |||
| 243 | 243 | ||
| 244 | impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { | 244 | impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { |
| 245 | /// Create a new GPIOTE output channel driver. | 245 | /// Create a new GPIOTE output channel driver. |
| 246 | pub fn new(ch: impl Peripheral<P = C> + 'd, mut pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { | 246 | pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { |
| 247 | into_ref!(ch); | 247 | into_ref!(ch); |
| 248 | let g = regs(); | 248 | let g = regs(); |
| 249 | let num = ch.number(); | 249 | let num = ch.number(); |
| @@ -481,11 +481,11 @@ mod eh02 { | |||
| 481 | type Error = Infallible; | 481 | type Error = Infallible; |
| 482 | 482 | ||
| 483 | fn is_high(&self) -> Result<bool, Self::Error> { | 483 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 484 | Ok(!self.pin.pin.ref_is_low()) | 484 | Ok(self.pin.is_high()) |
| 485 | } | 485 | } |
| 486 | 486 | ||
| 487 | fn is_low(&self) -> Result<bool, Self::Error> { | 487 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 488 | Ok(self.pin.pin.ref_is_low()) | 488 | Ok(self.pin.is_low()) |
| 489 | } | 489 | } |
| 490 | } | 490 | } |
| 491 | } | 491 | } |
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index d66ec0bfe..7eb57bbe6 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -127,19 +127,19 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 127 | 127 | ||
| 128 | /// Get whether the pin input level is high. | 128 | /// Get whether the pin input level is high. |
| 129 | #[inline] | 129 | #[inline] |
| 130 | pub fn is_high(&mut self) -> bool { | 130 | pub fn is_high(&self) -> bool { |
| 131 | self.pin.is_high() | 131 | self.pin.is_high() |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | /// Get whether the pin input level is low. | 134 | /// Get whether the pin input level is low. |
| 135 | #[inline] | 135 | #[inline] |
| 136 | pub fn is_low(&mut self) -> bool { | 136 | pub fn is_low(&self) -> bool { |
| 137 | self.pin.is_low() | 137 | self.pin.is_low() |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /// Returns current pin level | 140 | /// Returns current pin level |
| 141 | #[inline] | 141 | #[inline] |
| 142 | pub fn get_level(&mut self) -> Level { | 142 | pub fn get_level(&self) -> Level { |
| 143 | self.pin.get_level() | 143 | self.pin.get_level() |
| 144 | } | 144 | } |
| 145 | 145 | ||
| @@ -394,19 +394,19 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 394 | 394 | ||
| 395 | /// Is the output pin set as high? | 395 | /// Is the output pin set as high? |
| 396 | #[inline] | 396 | #[inline] |
| 397 | pub fn is_set_high(&mut self) -> bool { | 397 | pub fn is_set_high(&self) -> bool { |
| 398 | self.pin.is_set_high() | 398 | self.pin.is_set_high() |
| 399 | } | 399 | } |
| 400 | 400 | ||
| 401 | /// Is the output pin set as low? | 401 | /// Is the output pin set as low? |
| 402 | #[inline] | 402 | #[inline] |
| 403 | pub fn is_set_low(&mut self) -> bool { | 403 | pub fn is_set_low(&self) -> bool { |
| 404 | self.pin.is_set_low() | 404 | self.pin.is_set_low() |
| 405 | } | 405 | } |
| 406 | 406 | ||
| 407 | /// What level output is set to | 407 | /// What level output is set to |
| 408 | #[inline] | 408 | #[inline] |
| 409 | pub fn get_output_level(&mut self) -> Level { | 409 | pub fn get_output_level(&self) -> Level { |
| 410 | self.pin.get_output_level() | 410 | self.pin.get_output_level() |
| 411 | } | 411 | } |
| 412 | 412 | ||
| @@ -472,19 +472,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 472 | 472 | ||
| 473 | /// Is the output level high? | 473 | /// Is the output level high? |
| 474 | #[inline] | 474 | #[inline] |
| 475 | pub fn is_set_high(&mut self) -> bool { | 475 | pub fn is_set_high(&self) -> bool { |
| 476 | !self.is_set_low() | 476 | !self.is_set_low() |
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | /// Is the output level low? | 479 | /// Is the output level low? |
| 480 | #[inline] | 480 | #[inline] |
| 481 | pub fn is_set_low(&mut self) -> bool { | 481 | pub fn is_set_low(&self) -> bool { |
| 482 | self.pin.is_set_as_output() | 482 | self.pin.is_set_as_output() |
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | /// What level output is set to | 485 | /// What level output is set to |
| 486 | #[inline] | 486 | #[inline] |
| 487 | pub fn get_output_level(&mut self) -> Level { | 487 | pub fn get_output_level(&self) -> Level { |
| 488 | self.is_set_high().into() | 488 | self.is_set_high().into() |
| 489 | } | 489 | } |
| 490 | 490 | ||
| @@ -496,19 +496,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 496 | 496 | ||
| 497 | /// Get whether the pin input level is high. | 497 | /// Get whether the pin input level is high. |
| 498 | #[inline] | 498 | #[inline] |
| 499 | pub fn is_high(&mut self) -> bool { | 499 | pub fn is_high(&self) -> bool { |
| 500 | self.pin.is_high() | 500 | self.pin.is_high() |
| 501 | } | 501 | } |
| 502 | 502 | ||
| 503 | /// Get whether the pin input level is low. | 503 | /// Get whether the pin input level is low. |
| 504 | #[inline] | 504 | #[inline] |
| 505 | pub fn is_low(&mut self) -> bool { | 505 | pub fn is_low(&self) -> bool { |
| 506 | self.pin.is_low() | 506 | self.pin.is_low() |
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | /// Returns current pin level | 509 | /// Returns current pin level |
| 510 | #[inline] | 510 | #[inline] |
| 511 | pub fn get_level(&mut self) -> Level { | 511 | pub fn get_level(&self) -> Level { |
| 512 | self.is_high().into() | 512 | self.is_high().into() |
| 513 | } | 513 | } |
| 514 | 514 | ||
| @@ -640,12 +640,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 640 | 640 | ||
| 641 | /// Set as output pin. | 641 | /// Set as output pin. |
| 642 | #[inline] | 642 | #[inline] |
| 643 | pub fn is_set_as_output(&mut self) -> bool { | 643 | fn is_set_as_output(&self) -> bool { |
| 644 | self.ref_is_set_as_output() | ||
| 645 | } | ||
| 646 | |||
| 647 | #[inline] | ||
| 648 | pub(crate) fn ref_is_set_as_output(&self) -> bool { | ||
| 649 | (self.pin.sio_oe().value().read() & self.bit()) != 0 | 644 | (self.pin.sio_oe().value().read() & self.bit()) != 0 |
| 650 | } | 645 | } |
| 651 | 646 | ||
| @@ -657,24 +652,19 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 657 | 652 | ||
| 658 | /// Get whether the pin input level is high. | 653 | /// Get whether the pin input level is high. |
| 659 | #[inline] | 654 | #[inline] |
| 660 | pub fn is_high(&mut self) -> bool { | 655 | pub fn is_high(&self) -> bool { |
| 661 | !self.is_low() | 656 | !self.is_low() |
| 662 | } | 657 | } |
| 663 | /// Get whether the pin input level is low. | 658 | /// Get whether the pin input level is low. |
| 664 | 659 | ||
| 665 | #[inline] | 660 | #[inline] |
| 666 | pub fn is_low(&mut self) -> bool { | 661 | pub fn is_low(&self) -> bool { |
| 667 | self.ref_is_low() | ||
| 668 | } | ||
| 669 | |||
| 670 | #[inline] | ||
| 671 | pub(crate) fn ref_is_low(&self) -> bool { | ||
| 672 | self.pin.sio_in().read() & self.bit() == 0 | 662 | self.pin.sio_in().read() & self.bit() == 0 |
| 673 | } | 663 | } |
| 674 | 664 | ||
| 675 | /// Returns current pin level | 665 | /// Returns current pin level |
| 676 | #[inline] | 666 | #[inline] |
| 677 | pub fn get_level(&mut self) -> Level { | 667 | pub fn get_level(&self) -> Level { |
| 678 | self.is_high().into() | 668 | self.is_high().into() |
| 679 | } | 669 | } |
| 680 | 670 | ||
| @@ -701,24 +691,19 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 701 | 691 | ||
| 702 | /// Is the output level high? | 692 | /// Is the output level high? |
| 703 | #[inline] | 693 | #[inline] |
| 704 | pub fn is_set_high(&mut self) -> bool { | 694 | pub fn is_set_high(&self) -> bool { |
| 705 | !self.is_set_low() | 695 | !self.is_set_low() |
| 706 | } | 696 | } |
| 707 | 697 | ||
| 708 | /// Is the output level low? | 698 | /// Is the output level low? |
| 709 | #[inline] | 699 | #[inline] |
| 710 | pub fn is_set_low(&mut self) -> bool { | 700 | pub fn is_set_low(&self) -> bool { |
| 711 | self.ref_is_set_low() | ||
| 712 | } | ||
| 713 | |||
| 714 | #[inline] | ||
| 715 | pub(crate) fn ref_is_set_low(&self) -> bool { | ||
| 716 | (self.pin.sio_out().value().read() & self.bit()) == 0 | 701 | (self.pin.sio_out().value().read() & self.bit()) == 0 |
| 717 | } | 702 | } |
| 718 | 703 | ||
| 719 | /// What level output is set to | 704 | /// What level output is set to |
| 720 | #[inline] | 705 | #[inline] |
| 721 | pub fn get_output_level(&mut self) -> Level { | 706 | pub fn get_output_level(&self) -> Level { |
| 722 | self.is_set_high().into() | 707 | self.is_set_high().into() |
| 723 | } | 708 | } |
| 724 | 709 | ||
| @@ -989,11 +974,11 @@ mod eh02 { | |||
| 989 | type Error = Infallible; | 974 | type Error = Infallible; |
| 990 | 975 | ||
| 991 | fn is_high(&self) -> Result<bool, Self::Error> { | 976 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 992 | Ok(!self.pin.ref_is_low()) | 977 | Ok(self.is_high()) |
| 993 | } | 978 | } |
| 994 | 979 | ||
| 995 | fn is_low(&self) -> Result<bool, Self::Error> { | 980 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 996 | Ok(self.pin.ref_is_low()) | 981 | Ok(self.is_low()) |
| 997 | } | 982 | } |
| 998 | } | 983 | } |
| 999 | 984 | ||
| @@ -1011,11 +996,11 @@ mod eh02 { | |||
| 1011 | 996 | ||
| 1012 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { | 997 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { |
| 1013 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 998 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 1014 | Ok(!self.pin.ref_is_set_low()) | 999 | Ok(self.is_set_high()) |
| 1015 | } | 1000 | } |
| 1016 | 1001 | ||
| 1017 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 1002 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 1018 | Ok(self.pin.ref_is_set_low()) | 1003 | Ok(self.is_set_low()) |
| 1019 | } | 1004 | } |
| 1020 | } | 1005 | } |
| 1021 | 1006 | ||
| @@ -1031,11 +1016,11 @@ mod eh02 { | |||
| 1031 | type Error = Infallible; | 1016 | type Error = Infallible; |
| 1032 | 1017 | ||
| 1033 | fn is_high(&self) -> Result<bool, Self::Error> { | 1018 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 1034 | Ok(!self.pin.ref_is_low()) | 1019 | Ok(self.is_high()) |
| 1035 | } | 1020 | } |
| 1036 | 1021 | ||
| 1037 | fn is_low(&self) -> Result<bool, Self::Error> { | 1022 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 1038 | Ok(self.pin.ref_is_low()) | 1023 | Ok(self.is_low()) |
| 1039 | } | 1024 | } |
| 1040 | } | 1025 | } |
| 1041 | 1026 | ||
| @@ -1055,11 +1040,11 @@ mod eh02 { | |||
| 1055 | 1040 | ||
| 1056 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { | 1041 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { |
| 1057 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 1042 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 1058 | Ok(!self.pin.ref_is_set_as_output()) | 1043 | Ok(self.is_set_high()) |
| 1059 | } | 1044 | } |
| 1060 | 1045 | ||
| 1061 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 1046 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 1062 | Ok(self.pin.ref_is_set_as_output()) | 1047 | Ok(self.is_set_low()) |
| 1063 | } | 1048 | } |
| 1064 | } | 1049 | } |
| 1065 | 1050 | ||
| @@ -1075,11 +1060,11 @@ mod eh02 { | |||
| 1075 | type Error = Infallible; | 1060 | type Error = Infallible; |
| 1076 | 1061 | ||
| 1077 | fn is_high(&self) -> Result<bool, Self::Error> { | 1062 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 1078 | Ok(!self.ref_is_low()) | 1063 | Ok(self.is_high()) |
| 1079 | } | 1064 | } |
| 1080 | 1065 | ||
| 1081 | fn is_low(&self) -> Result<bool, Self::Error> { | 1066 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 1082 | Ok(self.ref_is_low()) | 1067 | Ok(self.is_low()) |
| 1083 | } | 1068 | } |
| 1084 | } | 1069 | } |
| 1085 | 1070 | ||
| @@ -1097,11 +1082,11 @@ mod eh02 { | |||
| 1097 | 1082 | ||
| 1098 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { | 1083 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { |
| 1099 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 1084 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 1100 | Ok(!self.ref_is_set_low()) | 1085 | Ok(self.is_set_high()) |
| 1101 | } | 1086 | } |
| 1102 | 1087 | ||
| 1103 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 1088 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 1104 | Ok(self.ref_is_set_low()) | 1089 | Ok(self.is_set_low()) |
| 1105 | } | 1090 | } |
| 1106 | } | 1091 | } |
| 1107 | 1092 | ||
| @@ -1120,11 +1105,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | |||
| 1120 | 1105 | ||
| 1121 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 1106 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { |
| 1122 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1107 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1123 | Ok(self.is_high()) | 1108 | Ok((*self).is_high()) |
| 1124 | } | 1109 | } |
| 1125 | 1110 | ||
| 1126 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 1111 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 1127 | Ok(self.is_low()) | 1112 | Ok((*self).is_low()) |
| 1128 | } | 1113 | } |
| 1129 | } | 1114 | } |
| 1130 | 1115 | ||
| @@ -1144,11 +1129,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | |||
| 1144 | 1129 | ||
| 1145 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 1130 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { |
| 1146 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1131 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1147 | Ok(self.is_set_high()) | 1132 | Ok((*self).is_set_high()) |
| 1148 | } | 1133 | } |
| 1149 | 1134 | ||
| 1150 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 1135 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 1151 | Ok(self.is_set_low()) | 1136 | Ok((*self).is_set_low()) |
| 1152 | } | 1137 | } |
| 1153 | } | 1138 | } |
| 1154 | 1139 | ||
| @@ -1168,21 +1153,21 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { | |||
| 1168 | 1153 | ||
| 1169 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { | 1154 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { |
| 1170 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1155 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1171 | Ok(self.is_set_high()) | 1156 | Ok((*self).is_set_high()) |
| 1172 | } | 1157 | } |
| 1173 | 1158 | ||
| 1174 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 1159 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 1175 | Ok(self.is_set_low()) | 1160 | Ok((*self).is_set_low()) |
| 1176 | } | 1161 | } |
| 1177 | } | 1162 | } |
| 1178 | 1163 | ||
| 1179 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { | 1164 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { |
| 1180 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1165 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1181 | Ok(self.is_high()) | 1166 | Ok((*self).is_high()) |
| 1182 | } | 1167 | } |
| 1183 | 1168 | ||
| 1184 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 1169 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 1185 | Ok(self.is_low()) | 1170 | Ok((*self).is_low()) |
| 1186 | } | 1171 | } |
| 1187 | } | 1172 | } |
| 1188 | 1173 | ||
| @@ -1192,11 +1177,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | |||
| 1192 | 1177 | ||
| 1193 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | 1178 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { |
| 1194 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1179 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1195 | Ok(self.is_high()) | 1180 | Ok((*self).is_high()) |
| 1196 | } | 1181 | } |
| 1197 | 1182 | ||
| 1198 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 1183 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 1199 | Ok(self.is_low()) | 1184 | Ok((*self).is_low()) |
| 1200 | } | 1185 | } |
| 1201 | } | 1186 | } |
| 1202 | 1187 | ||
| @@ -1212,11 +1197,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | |||
| 1212 | 1197 | ||
| 1213 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 1198 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { |
| 1214 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1199 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1215 | Ok(self.is_set_high()) | 1200 | Ok((*self).is_set_high()) |
| 1216 | } | 1201 | } |
| 1217 | 1202 | ||
| 1218 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 1203 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 1219 | Ok(self.is_set_low()) | 1204 | Ok((*self).is_set_low()) |
| 1220 | } | 1205 | } |
| 1221 | } | 1206 | } |
| 1222 | 1207 | ||
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index f83bae3ff..2821435ef 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -106,17 +106,17 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { | |||
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | /// Get whether the pin is high. | 108 | /// Get whether the pin is high. |
| 109 | pub fn is_high(&mut self) -> bool { | 109 | pub fn is_high(&self) -> bool { |
| 110 | self.pin.is_high() | 110 | self.pin.is_high() |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | /// Get whether the pin is low. | 113 | /// Get whether the pin is low. |
| 114 | pub fn is_low(&mut self) -> bool { | 114 | pub fn is_low(&self) -> bool { |
| 115 | self.pin.is_low() | 115 | self.pin.is_low() |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | /// Get the pin level. | 118 | /// Get the pin level. |
| 119 | pub fn get_level(&mut self) -> Level { | 119 | pub fn get_level(&self) -> Level { |
| 120 | self.pin.get_level() | 120 | self.pin.get_level() |
| 121 | } | 121 | } |
| 122 | 122 | ||
| @@ -166,11 +166,11 @@ impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> | |||
| 166 | type Error = Infallible; | 166 | type Error = Infallible; |
| 167 | 167 | ||
| 168 | fn is_high(&self) -> Result<bool, Self::Error> { | 168 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 169 | Ok(!self.pin.pin.ref_is_low()) | 169 | Ok(self.is_high()) |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | fn is_low(&self) -> Result<bool, Self::Error> { | 172 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 173 | Ok(self.pin.pin.ref_is_low()) | 173 | Ok(self.is_low()) |
| 174 | } | 174 | } |
| 175 | } | 175 | } |
| 176 | 176 | ||
| @@ -180,11 +180,11 @@ impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { | |||
| 180 | 180 | ||
| 181 | impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { | 181 | impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { |
| 182 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 182 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 183 | Ok(self.is_high()) | 183 | Ok((*self).is_high()) |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 186 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 187 | Ok(self.is_low()) | 187 | Ok((*self).is_low()) |
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| 190 | 190 | ||
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index d8677953f..7eb70496f 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -150,49 +150,39 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 150 | 150 | ||
| 151 | /// Get whether the pin input level is high. | 151 | /// Get whether the pin input level is high. |
| 152 | #[inline] | 152 | #[inline] |
| 153 | pub fn is_high(&mut self) -> bool { | 153 | pub fn is_high(&self) -> bool { |
| 154 | !self.ref_is_low() | 154 | !self.is_low() |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | /// Get whether the pin input level is low. | 157 | /// Get whether the pin input level is low. |
| 158 | #[inline] | 158 | #[inline] |
| 159 | pub fn is_low(&mut self) -> bool { | 159 | pub fn is_low(&self) -> bool { |
| 160 | self.ref_is_low() | ||
| 161 | } | ||
| 162 | |||
| 163 | #[inline] | ||
| 164 | pub(crate) fn ref_is_low(&self) -> bool { | ||
| 165 | let state = self.pin.block().idr().read().idr(self.pin.pin() as _); | 160 | let state = self.pin.block().idr().read().idr(self.pin.pin() as _); |
| 166 | state == vals::Idr::LOW | 161 | state == vals::Idr::LOW |
| 167 | } | 162 | } |
| 168 | 163 | ||
| 169 | /// Get the current pin input level. | 164 | /// Get the current pin input level. |
| 170 | #[inline] | 165 | #[inline] |
| 171 | pub fn get_level(&mut self) -> Level { | 166 | pub fn get_level(&self) -> Level { |
| 172 | self.is_high().into() | 167 | self.is_high().into() |
| 173 | } | 168 | } |
| 174 | 169 | ||
| 175 | /// Get whether the output level is set to high. | 170 | /// Get whether the output level is set to high. |
| 176 | #[inline] | 171 | #[inline] |
| 177 | pub fn is_set_high(&mut self) -> bool { | 172 | pub fn is_set_high(&self) -> bool { |
| 178 | !self.ref_is_set_low() | 173 | !self.is_set_low() |
| 179 | } | 174 | } |
| 180 | 175 | ||
| 181 | /// Get whether the output level is set to low. | 176 | /// Get whether the output level is set to low. |
| 182 | #[inline] | 177 | #[inline] |
| 183 | pub fn is_set_low(&mut self) -> bool { | 178 | pub fn is_set_low(&self) -> bool { |
| 184 | self.ref_is_set_low() | ||
| 185 | } | ||
| 186 | |||
| 187 | #[inline] | ||
| 188 | pub(crate) fn ref_is_set_low(&self) -> bool { | ||
| 189 | let state = self.pin.block().odr().read().odr(self.pin.pin() as _); | 179 | let state = self.pin.block().odr().read().odr(self.pin.pin() as _); |
| 190 | state == vals::Odr::LOW | 180 | state == vals::Odr::LOW |
| 191 | } | 181 | } |
| 192 | 182 | ||
| 193 | /// Get the current output level. | 183 | /// Get the current output level. |
| 194 | #[inline] | 184 | #[inline] |
| 195 | pub fn get_output_level(&mut self) -> Level { | 185 | pub fn get_output_level(&self) -> Level { |
| 196 | self.is_set_high().into() | 186 | self.is_set_high().into() |
| 197 | } | 187 | } |
| 198 | 188 | ||
| @@ -346,19 +336,19 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 346 | 336 | ||
| 347 | /// Get whether the pin input level is high. | 337 | /// Get whether the pin input level is high. |
| 348 | #[inline] | 338 | #[inline] |
| 349 | pub fn is_high(&mut self) -> bool { | 339 | pub fn is_high(&self) -> bool { |
| 350 | self.pin.is_high() | 340 | self.pin.is_high() |
| 351 | } | 341 | } |
| 352 | 342 | ||
| 353 | /// Get whether the pin input level is low. | 343 | /// Get whether the pin input level is low. |
| 354 | #[inline] | 344 | #[inline] |
| 355 | pub fn is_low(&mut self) -> bool { | 345 | pub fn is_low(&self) -> bool { |
| 356 | self.pin.is_low() | 346 | self.pin.is_low() |
| 357 | } | 347 | } |
| 358 | 348 | ||
| 359 | /// Get the current pin input level. | 349 | /// Get the current pin input level. |
| 360 | #[inline] | 350 | #[inline] |
| 361 | pub fn get_level(&mut self) -> Level { | 351 | pub fn get_level(&self) -> Level { |
| 362 | self.pin.get_level() | 352 | self.pin.get_level() |
| 363 | } | 353 | } |
| 364 | } | 354 | } |
| @@ -445,19 +435,19 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 445 | 435 | ||
| 446 | /// Is the output pin set as high? | 436 | /// Is the output pin set as high? |
| 447 | #[inline] | 437 | #[inline] |
| 448 | pub fn is_set_high(&mut self) -> bool { | 438 | pub fn is_set_high(&self) -> bool { |
| 449 | self.pin.is_set_high() | 439 | self.pin.is_set_high() |
| 450 | } | 440 | } |
| 451 | 441 | ||
| 452 | /// Is the output pin set as low? | 442 | /// Is the output pin set as low? |
| 453 | #[inline] | 443 | #[inline] |
| 454 | pub fn is_set_low(&mut self) -> bool { | 444 | pub fn is_set_low(&self) -> bool { |
| 455 | self.pin.is_set_low() | 445 | self.pin.is_set_low() |
| 456 | } | 446 | } |
| 457 | 447 | ||
| 458 | /// What level output is set to | 448 | /// What level output is set to |
| 459 | #[inline] | 449 | #[inline] |
| 460 | pub fn get_output_level(&mut self) -> Level { | 450 | pub fn get_output_level(&self) -> Level { |
| 461 | self.pin.get_output_level() | 451 | self.pin.get_output_level() |
| 462 | } | 452 | } |
| 463 | 453 | ||
| @@ -506,19 +496,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 506 | 496 | ||
| 507 | /// Get whether the pin input level is high. | 497 | /// Get whether the pin input level is high. |
| 508 | #[inline] | 498 | #[inline] |
| 509 | pub fn is_high(&mut self) -> bool { | 499 | pub fn is_high(&self) -> bool { |
| 510 | !self.pin.is_low() | 500 | !self.pin.is_low() |
| 511 | } | 501 | } |
| 512 | 502 | ||
| 513 | /// Get whether the pin input level is low. | 503 | /// Get whether the pin input level is low. |
| 514 | #[inline] | 504 | #[inline] |
| 515 | pub fn is_low(&mut self) -> bool { | 505 | pub fn is_low(&self) -> bool { |
| 516 | self.pin.is_low() | 506 | self.pin.is_low() |
| 517 | } | 507 | } |
| 518 | 508 | ||
| 519 | /// Get the current pin input level. | 509 | /// Get the current pin input level. |
| 520 | #[inline] | 510 | #[inline] |
| 521 | pub fn get_level(&mut self) -> Level { | 511 | pub fn get_level(&self) -> Level { |
| 522 | self.pin.get_level() | 512 | self.pin.get_level() |
| 523 | } | 513 | } |
| 524 | 514 | ||
| @@ -542,19 +532,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 542 | 532 | ||
| 543 | /// Get whether the output level is set to high. | 533 | /// Get whether the output level is set to high. |
| 544 | #[inline] | 534 | #[inline] |
| 545 | pub fn is_set_high(&mut self) -> bool { | 535 | pub fn is_set_high(&self) -> bool { |
| 546 | self.pin.is_set_high() | 536 | self.pin.is_set_high() |
| 547 | } | 537 | } |
| 548 | 538 | ||
| 549 | /// Get whether the output level is set to low. | 539 | /// Get whether the output level is set to low. |
| 550 | #[inline] | 540 | #[inline] |
| 551 | pub fn is_set_low(&mut self) -> bool { | 541 | pub fn is_set_low(&self) -> bool { |
| 552 | self.pin.is_set_low() | 542 | self.pin.is_set_low() |
| 553 | } | 543 | } |
| 554 | 544 | ||
| 555 | /// Get the current output level. | 545 | /// Get the current output level. |
| 556 | #[inline] | 546 | #[inline] |
| 557 | pub fn get_output_level(&mut self) -> Level { | 547 | pub fn get_output_level(&self) -> Level { |
| 558 | self.pin.get_output_level() | 548 | self.pin.get_output_level() |
| 559 | } | 549 | } |
| 560 | 550 | ||
| @@ -851,12 +841,12 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { | |||
| 851 | 841 | ||
| 852 | #[inline] | 842 | #[inline] |
| 853 | fn is_high(&self) -> Result<bool, Self::Error> { | 843 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 854 | Ok(!self.pin.ref_is_low()) | 844 | Ok(self.is_high()) |
| 855 | } | 845 | } |
| 856 | 846 | ||
| 857 | #[inline] | 847 | #[inline] |
| 858 | fn is_low(&self) -> Result<bool, Self::Error> { | 848 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 859 | Ok(self.pin.ref_is_low()) | 849 | Ok(self.is_low()) |
| 860 | } | 850 | } |
| 861 | } | 851 | } |
| 862 | 852 | ||
| @@ -879,13 +869,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { | |||
| 879 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { | 869 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { |
| 880 | #[inline] | 870 | #[inline] |
| 881 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 871 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 882 | Ok(!self.pin.ref_is_set_low()) | 872 | Ok(self.is_set_high()) |
| 883 | } | 873 | } |
| 884 | 874 | ||
| 885 | /// Is the output pin set as low? | 875 | /// Is the output pin set as low? |
| 886 | #[inline] | 876 | #[inline] |
| 887 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 877 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 888 | Ok(self.pin.ref_is_set_low()) | 878 | Ok(self.is_set_low()) |
| 889 | } | 879 | } |
| 890 | } | 880 | } |
| 891 | 881 | ||
| @@ -917,13 +907,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, | |||
| 917 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { | 907 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { |
| 918 | #[inline] | 908 | #[inline] |
| 919 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 909 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 920 | Ok(!self.pin.ref_is_set_low()) | 910 | Ok(self.is_set_high()) |
| 921 | } | 911 | } |
| 922 | 912 | ||
| 923 | /// Is the output pin set as low? | 913 | /// Is the output pin set as low? |
| 924 | #[inline] | 914 | #[inline] |
| 925 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 915 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 926 | Ok(self.pin.ref_is_set_low()) | 916 | Ok(self.is_set_low()) |
| 927 | } | 917 | } |
| 928 | } | 918 | } |
| 929 | 919 | ||
| @@ -941,12 +931,12 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { | |||
| 941 | 931 | ||
| 942 | #[inline] | 932 | #[inline] |
| 943 | fn is_high(&self) -> Result<bool, Self::Error> { | 933 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 944 | Ok(!self.ref_is_low()) | 934 | Ok(self.is_high()) |
| 945 | } | 935 | } |
| 946 | 936 | ||
| 947 | #[inline] | 937 | #[inline] |
| 948 | fn is_low(&self) -> Result<bool, Self::Error> { | 938 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 949 | Ok(self.ref_is_low()) | 939 | Ok(self.is_low()) |
| 950 | } | 940 | } |
| 951 | } | 941 | } |
| 952 | 942 | ||
| @@ -969,13 +959,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { | |||
| 969 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { | 959 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { |
| 970 | #[inline] | 960 | #[inline] |
| 971 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 961 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 972 | Ok(!self.ref_is_set_low()) | 962 | Ok(self.is_set_high()) |
| 973 | } | 963 | } |
| 974 | 964 | ||
| 975 | /// Is the output pin set as low? | 965 | /// Is the output pin set as low? |
| 976 | #[inline] | 966 | #[inline] |
| 977 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 967 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 978 | Ok(self.ref_is_set_low()) | 968 | Ok(self.is_set_low()) |
| 979 | } | 969 | } |
| 980 | } | 970 | } |
| 981 | 971 | ||
| @@ -995,12 +985,12 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | |||
| 995 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 985 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { |
| 996 | #[inline] | 986 | #[inline] |
| 997 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 987 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 998 | Ok(self.is_high()) | 988 | Ok((*self).is_high()) |
| 999 | } | 989 | } |
| 1000 | 990 | ||
| 1001 | #[inline] | 991 | #[inline] |
| 1002 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 992 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 1003 | Ok(self.is_low()) | 993 | Ok((*self).is_low()) |
| 1004 | } | 994 | } |
| 1005 | } | 995 | } |
| 1006 | 996 | ||
| @@ -1023,13 +1013,13 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | |||
| 1023 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 1013 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { |
| 1024 | #[inline] | 1014 | #[inline] |
| 1025 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1015 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1026 | Ok(self.is_set_high()) | 1016 | Ok((*self).is_set_high()) |
| 1027 | } | 1017 | } |
| 1028 | 1018 | ||
| 1029 | /// Is the output pin set as low? | 1019 | /// Is the output pin set as low? |
| 1030 | #[inline] | 1020 | #[inline] |
| 1031 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 1021 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 1032 | Ok(self.is_set_low()) | 1022 | Ok((*self).is_set_low()) |
| 1033 | } | 1023 | } |
| 1034 | } | 1024 | } |
| 1035 | 1025 | ||
| @@ -1040,12 +1030,12 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { | |||
| 1040 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { | 1030 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { |
| 1041 | #[inline] | 1031 | #[inline] |
| 1042 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1032 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1043 | Ok(self.is_high()) | 1033 | Ok((*self).is_high()) |
| 1044 | } | 1034 | } |
| 1045 | 1035 | ||
| 1046 | #[inline] | 1036 | #[inline] |
| 1047 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 1037 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 1048 | Ok(self.is_low()) | 1038 | Ok((*self).is_low()) |
| 1049 | } | 1039 | } |
| 1050 | } | 1040 | } |
| 1051 | 1041 | ||
| @@ -1064,25 +1054,25 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { | |||
| 1064 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { | 1054 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { |
| 1065 | #[inline] | 1055 | #[inline] |
| 1066 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1056 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1067 | Ok(self.is_set_high()) | 1057 | Ok((*self).is_set_high()) |
| 1068 | } | 1058 | } |
| 1069 | 1059 | ||
| 1070 | /// Is the output pin set as low? | 1060 | /// Is the output pin set as low? |
| 1071 | #[inline] | 1061 | #[inline] |
| 1072 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 1062 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 1073 | Ok(self.is_set_low()) | 1063 | Ok((*self).is_set_low()) |
| 1074 | } | 1064 | } |
| 1075 | } | 1065 | } |
| 1076 | 1066 | ||
| 1077 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | 1067 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { |
| 1078 | #[inline] | 1068 | #[inline] |
| 1079 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1069 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1080 | Ok(self.is_high()) | 1070 | Ok((*self).is_high()) |
| 1081 | } | 1071 | } |
| 1082 | 1072 | ||
| 1083 | #[inline] | 1073 | #[inline] |
| 1084 | fn is_low(&mut self) -> Result<bool, Self::Error> { | 1074 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 1085 | Ok(self.is_low()) | 1075 | Ok((*self).is_low()) |
| 1086 | } | 1076 | } |
| 1087 | } | 1077 | } |
| 1088 | 1078 | ||
| @@ -1105,13 +1095,13 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | |||
| 1105 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 1095 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { |
| 1106 | #[inline] | 1096 | #[inline] |
| 1107 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1097 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1108 | Ok(self.is_set_high()) | 1098 | Ok((*self).is_set_high()) |
| 1109 | } | 1099 | } |
| 1110 | 1100 | ||
| 1111 | /// Is the output pin set as low? | 1101 | /// Is the output pin set as low? |
| 1112 | #[inline] | 1102 | #[inline] |
| 1113 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { | 1103 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 1114 | Ok(self.is_set_low()) | 1104 | Ok((*self).is_set_low()) |
| 1115 | } | 1105 | } |
| 1116 | } | 1106 | } |
| 1117 | 1107 | ||
diff --git a/embassy-time/CHANGELOG.md b/embassy-time/CHANGELOG.md index 99f6ef7ac..d8c0c7d08 100644 --- a/embassy-time/CHANGELOG.md +++ b/embassy-time/CHANGELOG.md | |||
| @@ -24,8 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 24 | 24 | ||
| 25 | ## 0.1.3 - 2023-08-28 | 25 | ## 0.1.3 - 2023-08-28 |
| 26 | 26 | ||
| 27 | - Update `embedded-hal-async` to `1.0.0-rc.3` | 27 | - Update `embedded-hal-async` to `1.0.0-rc.2` |
| 28 | - Update `embedded-hal v1` to `1.0.0-rc.3` | 28 | - Update `embedded-hal v1` to `1.0.0-rc.2` |
| 29 | 29 | ||
| 30 | ## 0.1.2 - 2023-07-05 | 30 | ## 0.1.2 - 2023-07-05 |
| 31 | 31 | ||
diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index e9054fd48..4ad2ca3b7 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs | |||
| @@ -16,7 +16,7 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | // Use PIN_28, Pin34 on J0 for RP Pico, as a input. | 17 | // Use PIN_28, Pin34 on J0 for RP Pico, as a input. |
| 18 | // You need to add your own button. | 18 | // You need to add your own button. |
| 19 | let mut button = Input::new(p.PIN_28, Pull::Up); | 19 | let button = Input::new(p.PIN_28, Pull::Up); |
| 20 | 20 | ||
| 21 | loop { | 21 | loop { |
| 22 | if button.is_high() { | 22 | if button.is_high() { |
diff --git a/examples/stm32c0/src/bin/button.rs b/examples/stm32c0/src/bin/button.rs index 265200132..8017f0274 100644 --- a/examples/stm32c0/src/bin/button.rs +++ b/examples/stm32c0/src/bin/button.rs | |||
| @@ -12,7 +12,7 @@ fn main() -> ! { | |||
| 12 | 12 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | 14 | ||
| 15 | let mut button = Input::new(p.PC13, Pull::Up); | 15 | let button = Input::new(p.PC13, Pull::Up); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | if button.is_high() { | 18 | if button.is_high() { |
diff --git a/examples/stm32f3/src/bin/button.rs b/examples/stm32f3/src/bin/button.rs index 2cd356787..406730aae 100644 --- a/examples/stm32f3/src/bin/button.rs +++ b/examples/stm32f3/src/bin/button.rs | |||
| @@ -12,7 +12,7 @@ fn main() -> ! { | |||
| 12 | 12 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | 14 | ||
| 15 | let mut button = Input::new(p.PA0, Pull::Down); | 15 | let button = Input::new(p.PA0, Pull::Down); |
| 16 | let mut led1 = Output::new(p.PE9, Level::High, Speed::Low); | 16 | let mut led1 = Output::new(p.PE9, Level::High, Speed::Low); |
| 17 | let mut led2 = Output::new(p.PE15, Level::High, Speed::Low); | 17 | let mut led2 = Output::new(p.PE15, Level::High, Speed::Low); |
| 18 | 18 | ||
diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index ad30a56a2..564908998 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/src/bin/button.rs | |||
| @@ -12,7 +12,7 @@ fn main() -> ! { | |||
| 12 | 12 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | 14 | ||
| 15 | let mut button = Input::new(p.PC13, Pull::Down); | 15 | let button = Input::new(p.PC13, Pull::Down); |
| 16 | let mut led1 = Output::new(p.PB0, Level::High, Speed::Low); | 16 | let mut led1 = Output::new(p.PB0, Level::High, Speed::Low); |
| 17 | let _led2 = Output::new(p.PB7, Level::High, Speed::Low); | 17 | let _led2 = Output::new(p.PB7, Level::High, Speed::Low); |
| 18 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); | 18 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); |
diff --git a/examples/stm32f7/src/bin/button.rs b/examples/stm32f7/src/bin/button.rs index ad30a56a2..564908998 100644 --- a/examples/stm32f7/src/bin/button.rs +++ b/examples/stm32f7/src/bin/button.rs | |||
| @@ -12,7 +12,7 @@ fn main() -> ! { | |||
| 12 | 12 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | 14 | ||
| 15 | let mut button = Input::new(p.PC13, Pull::Down); | 15 | let button = Input::new(p.PC13, Pull::Down); |
| 16 | let mut led1 = Output::new(p.PB0, Level::High, Speed::Low); | 16 | let mut led1 = Output::new(p.PB0, Level::High, Speed::Low); |
| 17 | let _led2 = Output::new(p.PB7, Level::High, Speed::Low); | 17 | let _led2 = Output::new(p.PB7, Level::High, Speed::Low); |
| 18 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); | 18 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); |
diff --git a/examples/stm32g0/src/bin/button.rs b/examples/stm32g0/src/bin/button.rs index 265200132..8017f0274 100644 --- a/examples/stm32g0/src/bin/button.rs +++ b/examples/stm32g0/src/bin/button.rs | |||
| @@ -12,7 +12,7 @@ fn main() -> ! { | |||
| 12 | 12 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | 14 | ||
| 15 | let mut button = Input::new(p.PC13, Pull::Up); | 15 | let button = Input::new(p.PC13, Pull::Up); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | if button.is_high() { | 18 | if button.is_high() { |
diff --git a/examples/stm32g4/src/bin/button.rs b/examples/stm32g4/src/bin/button.rs index 6f3db0819..daebdd04d 100644 --- a/examples/stm32g4/src/bin/button.rs +++ b/examples/stm32g4/src/bin/button.rs | |||
| @@ -12,7 +12,7 @@ fn main() -> ! { | |||
| 12 | 12 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | 14 | ||
| 15 | let mut button = Input::new(p.PC13, Pull::Down); | 15 | let button = Input::new(p.PC13, Pull::Down); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | if button.is_high() { | 18 | if button.is_high() { |
diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index 165a714a5..707486cdc 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs | |||
| @@ -11,7 +11,7 @@ async fn main(_spawner: Spawner) { | |||
| 11 | let p = embassy_stm32::init(Default::default()); | 11 | let p = embassy_stm32::init(Default::default()); |
| 12 | info!("Hello World!"); | 12 | info!("Hello World!"); |
| 13 | 13 | ||
| 14 | let mut button = Input::new(p.PB2, Pull::Up); | 14 | let button = Input::new(p.PB2, Pull::Up); |
| 15 | let mut led1 = Output::new(p.PA5, Level::High, Speed::Low); | 15 | let mut led1 = Output::new(p.PA5, Level::High, Speed::Low); |
| 16 | let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); | 16 | let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); |
| 17 | 17 | ||
diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index 15288c61e..1f3270214 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs | |||
| @@ -11,7 +11,7 @@ fn main() -> ! { | |||
| 11 | 11 | ||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | 13 | ||
| 14 | let mut button = Input::new(p.PC13, Pull::Up); | 14 | let button = Input::new(p.PC13, Pull::Up); |
| 15 | 15 | ||
| 16 | loop { | 16 | loop { |
| 17 | if button.is_high() { | 17 | if button.is_high() { |
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 9565ae168..5b4cdfe5e 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -111,8 +111,8 @@ async fn main(spawner: Spawner) { | |||
| 111 | let led_uc4_blue = Output::new(dp.PG15, Level::High, Speed::Low); | 111 | let led_uc4_blue = Output::new(dp.PG15, Level::High, Speed::Low); |
| 112 | 112 | ||
| 113 | // Read the uc_cfg switches | 113 | // Read the uc_cfg switches |
| 114 | let mut uc_cfg0 = Input::new(dp.PB2, Pull::None); | 114 | let uc_cfg0 = Input::new(dp.PB2, Pull::None); |
| 115 | let mut uc_cfg1 = Input::new(dp.PF11, Pull::None); | 115 | let uc_cfg1 = Input::new(dp.PF11, Pull::None); |
| 116 | let _uc_cfg2 = Input::new(dp.PG6, Pull::None); | 116 | let _uc_cfg2 = Input::new(dp.PG6, Pull::None); |
| 117 | let _uc_cfg3 = Input::new(dp.PG11, Pull::None); | 117 | let _uc_cfg3 = Input::new(dp.PG11, Pull::None); |
| 118 | 118 | ||
| @@ -130,8 +130,8 @@ async fn main(spawner: Spawner) { | |||
| 130 | 130 | ||
| 131 | // Setup IO and SPI for the SPE chip | 131 | // Setup IO and SPI for the SPE chip |
| 132 | let spe_reset_n = Output::new(dp.PC7, Level::Low, Speed::Low); | 132 | let spe_reset_n = Output::new(dp.PC7, Level::Low, Speed::Low); |
| 133 | let mut spe_cfg0 = Input::new(dp.PC8, Pull::None); | 133 | let spe_cfg0 = Input::new(dp.PC8, Pull::None); |
| 134 | let mut spe_cfg1 = Input::new(dp.PC9, Pull::None); | 134 | let spe_cfg1 = Input::new(dp.PC9, Pull::None); |
| 135 | let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); | 135 | let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); |
| 136 | 136 | ||
| 137 | let spe_int = Input::new(dp.PB11, Pull::None); | 137 | let spe_int = Input::new(dp.PB11, Pull::None); |
diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index a989a5a4a..68dbb70ad 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs | |||
| @@ -29,7 +29,7 @@ async fn main(_spawner: Spawner) { | |||
| 29 | let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); | 29 | let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); |
| 30 | let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); | 30 | let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); |
| 31 | let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); | 31 | let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); |
| 32 | let mut ready = Input::new(p.PE1, Pull::Up); | 32 | let ready = Input::new(p.PE1, Pull::Up); |
| 33 | 33 | ||
| 34 | cortex_m::asm::delay(100_000); | 34 | cortex_m::asm::delay(100_000); |
| 35 | reset.set_high(); | 35 | reset.set_high(); |
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index 7922165df..946a759b1 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs | |||
| @@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); | 24 | let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); |
| 25 | let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); | 25 | let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); |
| 26 | let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); | 26 | let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); |
| 27 | let mut ready = Input::new(p.PE1, Pull::Up); | 27 | let ready = Input::new(p.PE1, Pull::Up); |
| 28 | 28 | ||
| 29 | cortex_m::asm::delay(100_000); | 29 | cortex_m::asm::delay(100_000); |
| 30 | reset.set_high(); | 30 | reset.set_high(); |
diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs index 3397e5ba6..eccd211e2 100644 --- a/examples/stm32wl/src/bin/button.rs +++ b/examples/stm32wl/src/bin/button.rs | |||
| @@ -12,7 +12,7 @@ fn main() -> ! { | |||
| 12 | 12 | ||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | 14 | ||
| 15 | let mut button = Input::new(p.PA0, Pull::Up); | 15 | let button = Input::new(p.PA0, Pull::Up); |
| 16 | let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); | 16 | let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); |
| 17 | let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); | 17 | let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); |
| 18 | 18 | ||
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index a57d5d9e8..e0c309887 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs | |||
| @@ -16,10 +16,10 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | // Test initial output | 17 | // Test initial output |
| 18 | { | 18 | { |
| 19 | let mut b = Input::new(&mut b, Pull::None); | 19 | let b = Input::new(&mut b, Pull::None); |
| 20 | 20 | ||
| 21 | { | 21 | { |
| 22 | let mut a = Output::new(&mut a, Level::Low); | 22 | let a = Output::new(&mut a, Level::Low); |
| 23 | delay(); | 23 | delay(); |
| 24 | assert!(b.is_low()); | 24 | assert!(b.is_low()); |
| 25 | assert!(!b.is_high()); | 25 | assert!(!b.is_high()); |
| @@ -64,7 +64,7 @@ async fn main(_spawner: Spawner) { | |||
| 64 | 64 | ||
| 65 | // Test input no pull | 65 | // Test input no pull |
| 66 | { | 66 | { |
| 67 | let mut b = Input::new(&mut b, Pull::None); | 67 | let b = Input::new(&mut b, Pull::None); |
| 68 | // no pull, the status is undefined | 68 | // no pull, the status is undefined |
| 69 | 69 | ||
| 70 | let mut a = Output::new(&mut a, Level::Low); | 70 | let mut a = Output::new(&mut a, Level::Low); |
| @@ -77,7 +77,7 @@ async fn main(_spawner: Spawner) { | |||
| 77 | 77 | ||
| 78 | // Test input pulldown | 78 | // Test input pulldown |
| 79 | { | 79 | { |
| 80 | let mut b = Input::new(&mut b, Pull::Down); | 80 | let b = Input::new(&mut b, Pull::Down); |
| 81 | delay(); | 81 | delay(); |
| 82 | assert!(b.is_low()); | 82 | assert!(b.is_low()); |
| 83 | 83 | ||
| @@ -91,7 +91,7 @@ async fn main(_spawner: Spawner) { | |||
| 91 | 91 | ||
| 92 | // Test input pullup | 92 | // Test input pullup |
| 93 | { | 93 | { |
| 94 | let mut b = Input::new(&mut b, Pull::Up); | 94 | let b = Input::new(&mut b, Pull::Up); |
| 95 | delay(); | 95 | delay(); |
| 96 | assert!(b.is_high()); | 96 | assert!(b.is_high()); |
| 97 | 97 | ||
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs index 3fc0bb2a0..e71d9e610 100644 --- a/tests/rp/src/bin/pwm.rs +++ b/tests/rp/src/bin/pwm.rs | |||
| @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) { | |||
| 45 | 45 | ||
| 46 | // Test output from A | 46 | // Test output from A |
| 47 | { | 47 | { |
| 48 | let mut pin1 = Input::new(&mut p9, Pull::None); | 48 | let pin1 = Input::new(&mut p9, Pull::None); |
| 49 | let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); | 49 | let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); |
| 50 | Timer::after_millis(1).await; | 50 | Timer::after_millis(1).await; |
| 51 | assert_eq!(pin1.is_low(), invert_a); | 51 | assert_eq!(pin1.is_low(), invert_a); |
| @@ -59,7 +59,7 @@ async fn main(_spawner: Spawner) { | |||
| 59 | 59 | ||
| 60 | // Test output from B | 60 | // Test output from B |
| 61 | { | 61 | { |
| 62 | let mut pin2 = Input::new(&mut p11, Pull::None); | 62 | let pin2 = Input::new(&mut p11, Pull::None); |
| 63 | let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); | 63 | let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); |
| 64 | Timer::after_millis(1).await; | 64 | Timer::after_millis(1).await; |
| 65 | assert_ne!(pin2.is_low(), invert_a); | 65 | assert_ne!(pin2.is_low(), invert_a); |
| @@ -73,8 +73,8 @@ async fn main(_spawner: Spawner) { | |||
| 73 | 73 | ||
| 74 | // Test output from A+B | 74 | // Test output from A+B |
| 75 | { | 75 | { |
| 76 | let mut pin1 = Input::new(&mut p9, Pull::None); | 76 | let pin1 = Input::new(&mut p9, Pull::None); |
| 77 | let mut pin2 = Input::new(&mut p11, Pull::None); | 77 | let pin2 = Input::new(&mut p11, Pull::None); |
| 78 | let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); | 78 | let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); |
| 79 | Timer::after_millis(1).await; | 79 | Timer::after_millis(1).await; |
| 80 | assert_eq!(pin1.is_low(), invert_a); | 80 | assert_eq!(pin1.is_low(), invert_a); |
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 9f1993024..c4e2fe161 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs | |||
| @@ -20,10 +20,10 @@ async fn main(_spawner: Spawner) { | |||
| 20 | 20 | ||
| 21 | // Test initial output | 21 | // Test initial output |
| 22 | { | 22 | { |
| 23 | let mut b = Input::new(&mut b, Pull::None); | 23 | let b = Input::new(&mut b, Pull::None); |
| 24 | 24 | ||
| 25 | { | 25 | { |
| 26 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 26 | let a = Output::new(&mut a, Level::Low, Speed::Low); |
| 27 | delay(); | 27 | delay(); |
| 28 | assert!(b.is_low()); | 28 | assert!(b.is_low()); |
| 29 | assert!(!b.is_high()); | 29 | assert!(!b.is_high()); |
| @@ -68,7 +68,7 @@ async fn main(_spawner: Spawner) { | |||
| 68 | 68 | ||
| 69 | // Test input no pull | 69 | // Test input no pull |
| 70 | { | 70 | { |
| 71 | let mut b = Input::new(&mut b, Pull::None); | 71 | let b = Input::new(&mut b, Pull::None); |
| 72 | // no pull, the status is undefined | 72 | // no pull, the status is undefined |
| 73 | 73 | ||
| 74 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 74 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); |
| @@ -81,7 +81,7 @@ async fn main(_spawner: Spawner) { | |||
| 81 | 81 | ||
| 82 | // Test input pulldown | 82 | // Test input pulldown |
| 83 | { | 83 | { |
| 84 | let mut b = Input::new(&mut b, Pull::Down); | 84 | let b = Input::new(&mut b, Pull::Down); |
| 85 | delay(); | 85 | delay(); |
| 86 | assert!(b.is_low()); | 86 | assert!(b.is_low()); |
| 87 | 87 | ||
| @@ -95,7 +95,7 @@ async fn main(_spawner: Spawner) { | |||
| 95 | 95 | ||
| 96 | // Test input pullup | 96 | // Test input pullup |
| 97 | { | 97 | { |
| 98 | let mut b = Input::new(&mut b, Pull::Up); | 98 | let b = Input::new(&mut b, Pull::Up); |
| 99 | delay(); | 99 | delay(); |
| 100 | assert!(b.is_high()); | 100 | assert!(b.is_high()); |
| 101 | 101 | ||
| @@ -109,7 +109,7 @@ async fn main(_spawner: Spawner) { | |||
| 109 | 109 | ||
| 110 | // Test output open drain | 110 | // Test output open drain |
| 111 | { | 111 | { |
| 112 | let mut b = Input::new(&mut b, Pull::Down); | 112 | let b = Input::new(&mut b, Pull::Down); |
| 113 | // no pull, the status is undefined | 113 | // no pull, the status is undefined |
| 114 | 114 | ||
| 115 | let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None); | 115 | let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None); |
