diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-12-14 16:01:51 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-12-14 16:19:32 +0100 |
| commit | d81395fab3c4e336650b0481790ecdab7d7aa13f (patch) | |
| tree | 449a894b8564dde713fff1e83cd717d263327b96 /embassy-nrf | |
| parent | 2c3d3992200939f71708c8b47d839328dcb12098 (diff) | |
Update embedded-hal to 1.0.0-rc.3
Diffstat (limited to 'embassy-nrf')
| -rw-r--r-- | embassy-nrf/Cargo.toml | 5 | ||||
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 67 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 10 |
3 files changed, 46 insertions, 36 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index a7f3cb35d..6d7440519 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -94,8 +94,8 @@ embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } | |||
| 94 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } | 94 | embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } |
| 95 | 95 | ||
| 96 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } | 96 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } |
| 97 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } | 97 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } |
| 98 | embedded-hal-async = { version = "=1.0.0-rc.2" } | 98 | embedded-hal-async = { version = "=1.0.0-rc.3" } |
| 99 | embedded-io = { version = "0.6.0" } | 99 | embedded-io = { version = "0.6.0" } |
| 100 | embedded-io-async = { version = "0.6.1" } | 100 | embedded-io-async = { version = "0.6.1" } |
| 101 | 101 | ||
| @@ -120,4 +120,3 @@ nrf52840-pac = { version = "0.12.0", optional = true } | |||
| 120 | nrf5340-app-pac = { version = "0.12.0", optional = true } | 120 | nrf5340-app-pac = { version = "0.12.0", optional = true } |
| 121 | nrf5340-net-pac = { version = "0.12.0", optional = true } | 121 | nrf5340-net-pac = { version = "0.12.0", optional = true } |
| 122 | nrf9160-pac = { version = "0.12.0", optional = true } | 122 | nrf9160-pac = { version = "0.12.0", optional = true } |
| 123 | |||
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index cf6225282..85977a804 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 | /// Test if current pin level is high. | 53 | /// Test if current pin level is high. |
| 54 | #[inline] | 54 | #[inline] |
| 55 | pub fn is_high(&self) -> bool { | 55 | pub fn is_high(&mut self) -> bool { |
| 56 | self.pin.is_high() | 56 | self.pin.is_high() |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /// Test if current pin level is low. | 59 | /// Test if current pin level is low. |
| 60 | #[inline] | 60 | #[inline] |
| 61 | pub fn is_low(&self) -> bool { | 61 | pub fn is_low(&mut self) -> bool { |
| 62 | self.pin.is_low() | 62 | self.pin.is_low() |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /// Returns current pin level | 65 | /// Returns current pin level |
| 66 | #[inline] | 66 | #[inline] |
| 67 | pub fn get_level(&self) -> Level { | 67 | pub fn get_level(&mut self) -> Level { |
| 68 | self.pin.get_level() | 68 | self.pin.get_level() |
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| @@ -160,19 +160,19 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 160 | 160 | ||
| 161 | /// Is the output pin set as high? | 161 | /// Is the output pin set as high? |
| 162 | #[inline] | 162 | #[inline] |
| 163 | pub fn is_set_high(&self) -> bool { | 163 | pub fn is_set_high(&mut self) -> bool { |
| 164 | self.pin.is_set_high() | 164 | self.pin.is_set_high() |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | /// Is the output pin set as low? | 167 | /// Is the output pin set as low? |
| 168 | #[inline] | 168 | #[inline] |
| 169 | pub fn is_set_low(&self) -> bool { | 169 | pub fn is_set_low(&mut self) -> bool { |
| 170 | self.pin.is_set_low() | 170 | self.pin.is_set_low() |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | /// What level output is set to | 173 | /// What level output is set to |
| 174 | #[inline] | 174 | #[inline] |
| 175 | pub fn get_output_level(&self) -> Level { | 175 | pub fn get_output_level(&mut self) -> Level { |
| 176 | self.pin.get_output_level() | 176 | self.pin.get_output_level() |
| 177 | } | 177 | } |
| 178 | } | 178 | } |
| @@ -277,19 +277,24 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 277 | 277 | ||
| 278 | /// Test if current pin level is high. | 278 | /// Test if current pin level is high. |
| 279 | #[inline] | 279 | #[inline] |
| 280 | pub fn is_high(&self) -> bool { | 280 | pub fn is_high(&mut self) -> bool { |
| 281 | !self.is_low() | 281 | !self.is_low() |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | /// Test if current pin level is low. | 284 | /// Test if current pin level is low. |
| 285 | #[inline] | 285 | #[inline] |
| 286 | pub fn is_low(&self) -> bool { | 286 | pub fn is_low(&mut self) -> bool { |
| 287 | self.ref_is_low() | ||
| 288 | } | ||
| 289 | |||
| 290 | #[inline] | ||
| 291 | pub(crate) fn ref_is_low(&self) -> bool { | ||
| 287 | self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0 | 292 | self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0 |
| 288 | } | 293 | } |
| 289 | 294 | ||
| 290 | /// Returns current pin level | 295 | /// Returns current pin level |
| 291 | #[inline] | 296 | #[inline] |
| 292 | pub fn get_level(&self) -> Level { | 297 | pub fn get_level(&mut self) -> Level { |
| 293 | self.is_high().into() | 298 | self.is_high().into() |
| 294 | } | 299 | } |
| 295 | 300 | ||
| @@ -316,19 +321,25 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 316 | 321 | ||
| 317 | /// Is the output pin set as high? | 322 | /// Is the output pin set as high? |
| 318 | #[inline] | 323 | #[inline] |
| 319 | pub fn is_set_high(&self) -> bool { | 324 | pub fn is_set_high(&mut self) -> bool { |
| 320 | !self.is_set_low() | 325 | !self.is_set_low() |
| 321 | } | 326 | } |
| 322 | 327 | ||
| 323 | /// Is the output pin set as low? | 328 | /// Is the output pin set as low? |
| 324 | #[inline] | 329 | #[inline] |
| 325 | pub fn is_set_low(&self) -> bool { | 330 | pub fn is_set_low(&mut self) -> bool { |
| 331 | self.ref_is_set_low() | ||
| 332 | } | ||
| 333 | |||
| 334 | /// Is the output pin set as low? | ||
| 335 | #[inline] | ||
| 336 | pub(crate) fn ref_is_set_low(&self) -> bool { | ||
| 326 | self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0 | 337 | self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0 |
| 327 | } | 338 | } |
| 328 | 339 | ||
| 329 | /// What level output is set to | 340 | /// What level output is set to |
| 330 | #[inline] | 341 | #[inline] |
| 331 | pub fn get_output_level(&self) -> Level { | 342 | pub fn get_output_level(&mut self) -> Level { |
| 332 | self.is_set_high().into() | 343 | self.is_set_high().into() |
| 333 | } | 344 | } |
| 334 | } | 345 | } |
| @@ -498,11 +509,11 @@ mod eh02 { | |||
| 498 | type Error = Infallible; | 509 | type Error = Infallible; |
| 499 | 510 | ||
| 500 | fn is_high(&self) -> Result<bool, Self::Error> { | 511 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 501 | Ok(self.is_high()) | 512 | Ok(!self.pin.ref_is_low()) |
| 502 | } | 513 | } |
| 503 | 514 | ||
| 504 | fn is_low(&self) -> Result<bool, Self::Error> { | 515 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 505 | Ok(self.is_low()) | 516 | Ok(self.pin.ref_is_low()) |
| 506 | } | 517 | } |
| 507 | } | 518 | } |
| 508 | 519 | ||
| @@ -520,11 +531,11 @@ mod eh02 { | |||
| 520 | 531 | ||
| 521 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { | 532 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { |
| 522 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 533 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 523 | Ok(self.is_set_high()) | 534 | Ok(!self.pin.ref_is_set_low()) |
| 524 | } | 535 | } |
| 525 | 536 | ||
| 526 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 537 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 527 | Ok(self.is_set_low()) | 538 | Ok(self.pin.ref_is_set_low()) |
| 528 | } | 539 | } |
| 529 | } | 540 | } |
| 530 | 541 | ||
| @@ -535,11 +546,11 @@ mod eh02 { | |||
| 535 | type Error = Infallible; | 546 | type Error = Infallible; |
| 536 | 547 | ||
| 537 | fn is_high(&self) -> Result<bool, Self::Error> { | 548 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 538 | Ok(self.is_high()) | 549 | Ok(!self.ref_is_low()) |
| 539 | } | 550 | } |
| 540 | 551 | ||
| 541 | fn is_low(&self) -> Result<bool, Self::Error> { | 552 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 542 | Ok(self.is_low()) | 553 | Ok(self.ref_is_low()) |
| 543 | } | 554 | } |
| 544 | } | 555 | } |
| 545 | 556 | ||
| @@ -557,11 +568,11 @@ mod eh02 { | |||
| 557 | 568 | ||
| 558 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { | 569 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { |
| 559 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 570 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 560 | Ok(self.is_set_high()) | 571 | Ok(!self.ref_is_set_low()) |
| 561 | } | 572 | } |
| 562 | 573 | ||
| 563 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 574 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 564 | Ok(self.is_set_low()) | 575 | Ok(self.ref_is_set_low()) |
| 565 | } | 576 | } |
| 566 | } | 577 | } |
| 567 | } | 578 | } |
| @@ -571,11 +582,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | |||
| 571 | } | 582 | } |
| 572 | 583 | ||
| 573 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 584 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { |
| 574 | fn is_high(&self) -> Result<bool, Self::Error> { | 585 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 575 | Ok(self.is_high()) | 586 | Ok(self.is_high()) |
| 576 | } | 587 | } |
| 577 | 588 | ||
| 578 | fn is_low(&self) -> Result<bool, Self::Error> { | 589 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 579 | Ok(self.is_low()) | 590 | Ok(self.is_low()) |
| 580 | } | 591 | } |
| 581 | } | 592 | } |
| @@ -595,11 +606,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | |||
| 595 | } | 606 | } |
| 596 | 607 | ||
| 597 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 608 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { |
| 598 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 609 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 599 | Ok(self.is_set_high()) | 610 | Ok(self.is_set_high()) |
| 600 | } | 611 | } |
| 601 | 612 | ||
| 602 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 613 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 603 | Ok(self.is_set_low()) | 614 | Ok(self.is_set_low()) |
| 604 | } | 615 | } |
| 605 | } | 616 | } |
| @@ -612,11 +623,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | |||
| 612 | /// | 623 | /// |
| 613 | /// If the pin is not in input mode the result is unspecified. | 624 | /// If the pin is not in input mode the result is unspecified. |
| 614 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | 625 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { |
| 615 | fn is_high(&self) -> Result<bool, Self::Error> { | 626 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 616 | Ok(self.is_high()) | 627 | Ok(self.is_high()) |
| 617 | } | 628 | } |
| 618 | 629 | ||
| 619 | fn is_low(&self) -> Result<bool, Self::Error> { | 630 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 620 | Ok(self.is_low()) | 631 | Ok(self.is_low()) |
| 621 | } | 632 | } |
| 622 | } | 633 | } |
| @@ -632,11 +643,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | |||
| 632 | } | 643 | } |
| 633 | 644 | ||
| 634 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 645 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { |
| 635 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 646 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 636 | Ok(self.is_set_high()) | 647 | Ok(self.is_set_high()) |
| 637 | } | 648 | } |
| 638 | 649 | ||
| 639 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 650 | fn is_set_low(&mut self) -> Result<bool, Self::Error> { |
| 640 | Ok(self.is_set_low()) | 651 | Ok(self.is_set_low()) |
| 641 | } | 652 | } |
| 642 | } | 653 | } |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index fd629ea76..07196abf7 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, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { | 246 | pub fn new(ch: impl Peripheral<P = C> + 'd, mut 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.is_high()) | 484 | Ok(!self.pin.pin.ref_is_low()) |
| 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.is_low()) | 488 | Ok(self.pin.pin.ref_is_low()) |
| 489 | } | 489 | } |
| 490 | } | 490 | } |
| 491 | } | 491 | } |
| @@ -495,11 +495,11 @@ impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputCha | |||
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { | 497 | impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { |
| 498 | fn is_high(&self) -> Result<bool, Self::Error> { | 498 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 499 | Ok(self.pin.is_high()) | 499 | Ok(self.pin.is_high()) |
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | fn is_low(&self) -> Result<bool, Self::Error> { | 502 | fn is_low(&mut self) -> Result<bool, Self::Error> { |
| 503 | Ok(self.pin.is_low()) | 503 | Ok(self.pin.is_low()) |
| 504 | } | 504 | } |
| 505 | } | 505 | } |
