aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-11-29 17:23:48 +0100
committerDario Nieuwenhuis <[email protected]>2023-11-29 17:26:33 +0100
commitc6989dfbca51787146f50270c671af9db434f577 (patch)
tree5974a8ec41c108d5208e4f68027b918d424a2046 /embassy-nrf/src
parent384bad7bfaa1f2415baf2cd3b69ebf36dc0a02d7 (diff)
Remove nightly and unstable-traits features in preparation for 1.75.
Diffstat (limited to 'embassy-nrf/src')
-rw-r--r--embassy-nrf/src/buffered_uarte.rs1
-rw-r--r--embassy-nrf/src/chips/nrf52820.rs1
-rw-r--r--embassy-nrf/src/chips/nrf52833.rs1
-rw-r--r--embassy-nrf/src/chips/nrf52840.rs1
-rw-r--r--embassy-nrf/src/chips/nrf5340_app.rs1
-rw-r--r--embassy-nrf/src/gpio.rs107
-rw-r--r--embassy-nrf/src/gpiote.rs88
-rw-r--r--embassy-nrf/src/lib.rs4
-rw-r--r--embassy-nrf/src/qspi.rs1
-rw-r--r--embassy-nrf/src/spim.rs91
-rw-r--r--embassy-nrf/src/twim.rs115
11 files changed, 184 insertions, 227 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs
index e4b556f06..4ac622d34 100644
--- a/embassy-nrf/src/buffered_uarte.rs
+++ b/embassy-nrf/src/buffered_uarte.rs
@@ -607,7 +607,6 @@ impl<'u, 'd, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'u, 'd, U, T> {
607 } 607 }
608} 608}
609 609
610#[cfg(feature = "nightly")]
611mod _embedded_io { 610mod _embedded_io {
612 use super::*; 611 use super::*;
613 612
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs
index 0ecddaf31..85184d48c 100644
--- a/embassy-nrf/src/chips/nrf52820.rs
+++ b/embassy-nrf/src/chips/nrf52820.rs
@@ -131,7 +131,6 @@ embassy_hal_internal::peripherals! {
131 QDEC, 131 QDEC,
132} 132}
133 133
134#[cfg(feature = "nightly")]
135impl_usb!(USBD, USBD, USBD); 134impl_usb!(USBD, USBD, USBD);
136 135
137impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); 136impl_uarte!(UARTE0, UARTE0, UARTE0_UART0);
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs
index b8830b338..342ae8b15 100644
--- a/embassy-nrf/src/chips/nrf52833.rs
+++ b/embassy-nrf/src/chips/nrf52833.rs
@@ -171,7 +171,6 @@ embassy_hal_internal::peripherals! {
171 I2S, 171 I2S,
172} 172}
173 173
174#[cfg(feature = "nightly")]
175impl_usb!(USBD, USBD, USBD); 174impl_usb!(USBD, USBD, USBD);
176 175
177impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); 176impl_uarte!(UARTE0, UARTE0, UARTE0_UART0);
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs
index a490cb079..a5cbd798a 100644
--- a/embassy-nrf/src/chips/nrf52840.rs
+++ b/embassy-nrf/src/chips/nrf52840.rs
@@ -174,7 +174,6 @@ embassy_hal_internal::peripherals! {
174 I2S, 174 I2S,
175} 175}
176 176
177#[cfg(feature = "nightly")]
178impl_usb!(USBD, USBD, USBD); 177impl_usb!(USBD, USBD, USBD);
179 178
180impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); 179impl_uarte!(UARTE0, UARTE0, UARTE0_UART0);
diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs
index 5e9a8ed05..62c74bb6f 100644
--- a/embassy-nrf/src/chips/nrf5340_app.rs
+++ b/embassy-nrf/src/chips/nrf5340_app.rs
@@ -382,7 +382,6 @@ embassy_hal_internal::peripherals! {
382 P1_15, 382 P1_15,
383} 383}
384 384
385#[cfg(feature = "nightly")]
386impl_usb!(USBD, USBD, USBD); 385impl_usb!(USBD, USBD, USBD);
387 386
388impl_uarte!(SERIAL0, UARTE0, SERIAL0); 387impl_uarte!(SERIAL0, UARTE0, SERIAL0);
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs
index ea2b76096..cf6225282 100644
--- a/embassy-nrf/src/gpio.rs
+++ b/embassy-nrf/src/gpio.rs
@@ -566,82 +566,77 @@ mod eh02 {
566 } 566 }
567} 567}
568 568
569#[cfg(feature = "unstable-traits")] 569impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
570mod eh1 { 570 type Error = Infallible;
571 use super::*; 571}
572 572
573 impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { 573impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
574 type Error = Infallible; 574 fn is_high(&self) -> Result<bool, Self::Error> {
575 Ok(self.is_high())
575 } 576 }
576 577
577 impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { 578 fn is_low(&self) -> Result<bool, Self::Error> {
578 fn is_high(&self) -> Result<bool, Self::Error> { 579 Ok(self.is_low())
579 Ok(self.is_high()) 580 }
580 } 581}
581 582
582 fn is_low(&self) -> Result<bool, Self::Error> { 583impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> {
583 Ok(self.is_low()) 584 type Error = Infallible;
584 } 585}
586
587impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
588 fn set_high(&mut self) -> Result<(), Self::Error> {
589 Ok(self.set_high())
585 } 590 }
586 591
587 impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { 592 fn set_low(&mut self) -> Result<(), Self::Error> {
588 type Error = Infallible; 593 Ok(self.set_low())
589 } 594 }
595}
590 596
591 impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { 597impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
592 fn set_high(&mut self) -> Result<(), Self::Error> { 598 fn is_set_high(&self) -> Result<bool, Self::Error> {
593 Ok(self.set_high()) 599 Ok(self.is_set_high())
594 } 600 }
595 601
596 fn set_low(&mut self) -> Result<(), Self::Error> { 602 fn is_set_low(&self) -> Result<bool, Self::Error> {
597 Ok(self.set_low()) 603 Ok(self.is_set_low())
598 }
599 } 604 }
605}
600 606
601 impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { 607impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
602 fn is_set_high(&self) -> Result<bool, Self::Error> { 608 type Error = Infallible;
603 Ok(self.is_set_high()) 609}
604 }
605 610
606 fn is_set_low(&self) -> Result<bool, Self::Error> { 611/// Implement [`InputPin`] for [`Flex`];
607 Ok(self.is_set_low()) 612///
608 } 613/// If the pin is not in input mode the result is unspecified.
614impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
615 fn is_high(&self) -> Result<bool, Self::Error> {
616 Ok(self.is_high())
609 } 617 }
610 618
611 impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { 619 fn is_low(&self) -> Result<bool, Self::Error> {
612 type Error = Infallible; 620 Ok(self.is_low())
613 } 621 }
622}
614 623
615 /// Implement [`InputPin`] for [`Flex`]; 624impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
616 /// 625 fn set_high(&mut self) -> Result<(), Self::Error> {
617 /// If the pin is not in input mode the result is unspecified. 626 Ok(self.set_high())
618 impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
619 fn is_high(&self) -> Result<bool, Self::Error> {
620 Ok(self.is_high())
621 }
622
623 fn is_low(&self) -> Result<bool, Self::Error> {
624 Ok(self.is_low())
625 }
626 } 627 }
627 628
628 impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { 629 fn set_low(&mut self) -> Result<(), Self::Error> {
629 fn set_high(&mut self) -> Result<(), Self::Error> { 630 Ok(self.set_low())
630 Ok(self.set_high())
631 }
632
633 fn set_low(&mut self) -> Result<(), Self::Error> {
634 Ok(self.set_low())
635 }
636 } 631 }
632}
637 633
638 impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { 634impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
639 fn is_set_high(&self) -> Result<bool, Self::Error> { 635 fn is_set_high(&self) -> Result<bool, Self::Error> {
640 Ok(self.is_set_high()) 636 Ok(self.is_set_high())
641 } 637 }
642 638
643 fn is_set_low(&self) -> Result<bool, Self::Error> { 639 fn is_set_low(&self) -> Result<bool, Self::Error> {
644 Ok(self.is_set_low()) 640 Ok(self.is_set_low())
645 }
646 } 641 }
647} 642}
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index d16b4a43b..fd629ea76 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -490,70 +490,60 @@ mod eh02 {
490 } 490 }
491} 491}
492 492
493#[cfg(feature = "unstable-traits")] 493impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> {
494mod eh1 { 494 type Error = Infallible;
495 use super::*; 495}
496 496
497 impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { 497impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> {
498 type Error = Infallible; 498 fn is_high(&self) -> Result<bool, Self::Error> {
499 Ok(self.pin.is_high())
499 } 500 }
500 501
501 impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { 502 fn is_low(&self) -> Result<bool, Self::Error> {
502 fn is_high(&self) -> Result<bool, Self::Error> { 503 Ok(self.pin.is_low())
503 Ok(self.pin.is_high())
504 }
505
506 fn is_low(&self) -> Result<bool, Self::Error> {
507 Ok(self.pin.is_low())
508 }
509 } 504 }
510} 505}
511 506
512#[cfg(all(feature = "unstable-traits", feature = "nightly"))] 507impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
513mod eha { 508 async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
514 use super::*; 509 Ok(self.wait_for_high().await)
515 510 }
516 impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
517 async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
518 Ok(self.wait_for_high().await)
519 }
520 511
521 async fn wait_for_low(&mut self) -> Result<(), Self::Error> { 512 async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
522 Ok(self.wait_for_low().await) 513 Ok(self.wait_for_low().await)
523 } 514 }
524 515
525 async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { 516 async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
526 Ok(self.wait_for_rising_edge().await) 517 Ok(self.wait_for_rising_edge().await)
527 } 518 }
528 519
529 async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { 520 async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
530 Ok(self.wait_for_falling_edge().await) 521 Ok(self.wait_for_falling_edge().await)
531 } 522 }
532 523
533 async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { 524 async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
534 Ok(self.wait_for_any_edge().await) 525 Ok(self.wait_for_any_edge().await)
535 }
536 } 526 }
527}
537 528
538 impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { 529impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> {
539 async fn wait_for_high(&mut self) -> Result<(), Self::Error> { 530 async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
540 Ok(self.wait_for_high().await) 531 Ok(self.wait_for_high().await)
541 } 532 }
542 533
543 async fn wait_for_low(&mut self) -> Result<(), Self::Error> { 534 async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
544 Ok(self.wait_for_low().await) 535 Ok(self.wait_for_low().await)
545 } 536 }
546 537
547 async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { 538 async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
548 Ok(self.wait_for_rising_edge().await) 539 Ok(self.wait_for_rising_edge().await)
549 } 540 }
550 541
551 async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { 542 async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
552 Ok(self.wait_for_falling_edge().await) 543 Ok(self.wait_for_falling_edge().await)
553 } 544 }
554 545
555 async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { 546 async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
556 Ok(self.wait_for_any_edge().await) 547 Ok(self.wait_for_any_edge().await)
557 }
558 } 548 }
559} 549}
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs
index 715281119..ed8aad89b 100644
--- a/embassy-nrf/src/lib.rs
+++ b/embassy-nrf/src/lib.rs
@@ -1,6 +1,5 @@
1#![no_std] 1#![no_std]
2#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] 2#![allow(async_fn_in_trait)]
3#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))]
4#![doc = include_str!("../README.md")] 3#![doc = include_str!("../README.md")]
5#![warn(missing_docs)] 4#![warn(missing_docs)]
6 5
@@ -76,7 +75,6 @@ pub mod uarte;
76 feature = "nrf52833", 75 feature = "nrf52833",
77 feature = "nrf52840" 76 feature = "nrf52840"
78))] 77))]
79#[cfg(feature = "nightly")]
80pub mod usb; 78pub mod usb;
81#[cfg(not(feature = "_nrf5340"))] 79#[cfg(not(feature = "_nrf5340"))]
82pub mod wdt; 80pub mod wdt;
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs
index 36ee33f6d..add093b63 100644
--- a/embassy-nrf/src/qspi.rs
+++ b/embassy-nrf/src/qspi.rs
@@ -585,7 +585,6 @@ impl<'d, T: Instance> NorFlash for Qspi<'d, T> {
585 } 585 }
586} 586}
587 587
588#[cfg(feature = "nightly")]
589mod _eh1 { 588mod _eh1 {
590 use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; 589 use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
591 590
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs
index caf681d99..5d3c3268c 100644
--- a/embassy-nrf/src/spim.rs
+++ b/embassy-nrf/src/spim.rs
@@ -495,72 +495,61 @@ mod eh02 {
495 } 495 }
496} 496}
497 497
498#[cfg(feature = "unstable-traits")] 498impl embedded_hal_1::spi::Error for Error {
499mod eh1 { 499 fn kind(&self) -> embedded_hal_1::spi::ErrorKind {
500 use super::*; 500 match *self {
501 501 Self::TxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other,
502 impl embedded_hal_1::spi::Error for Error { 502 Self::RxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other,
503 fn kind(&self) -> embedded_hal_1::spi::ErrorKind { 503 Self::BufferNotInRAM => embedded_hal_1::spi::ErrorKind::Other,
504 match *self {
505 Self::TxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other,
506 Self::RxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other,
507 Self::BufferNotInRAM => embedded_hal_1::spi::ErrorKind::Other,
508 }
509 } 504 }
510 } 505 }
506}
511 507
512 impl<'d, T: Instance> embedded_hal_1::spi::ErrorType for Spim<'d, T> { 508impl<'d, T: Instance> embedded_hal_1::spi::ErrorType for Spim<'d, T> {
513 type Error = Error; 509 type Error = Error;
514 } 510}
515 511
516 impl<'d, T: Instance> embedded_hal_1::spi::SpiBus<u8> for Spim<'d, T> { 512impl<'d, T: Instance> embedded_hal_1::spi::SpiBus<u8> for Spim<'d, T> {
517 fn flush(&mut self) -> Result<(), Self::Error> { 513 fn flush(&mut self) -> Result<(), Self::Error> {
518 Ok(()) 514 Ok(())
519 } 515 }
520 516
521 fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { 517 fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> {
522 self.blocking_transfer(words, &[]) 518 self.blocking_transfer(words, &[])
523 } 519 }
524 520
525 fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { 521 fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
526 self.blocking_write(words) 522 self.blocking_write(words)
527 } 523 }
528 524
529 fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { 525 fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> {
530 self.blocking_transfer(read, write) 526 self.blocking_transfer(read, write)
531 } 527 }
532 528
533 fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { 529 fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> {
534 self.blocking_transfer_in_place(words) 530 self.blocking_transfer_in_place(words)
535 }
536 } 531 }
537} 532}
538 533
539#[cfg(all(feature = "unstable-traits", feature = "nightly"))] 534impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spim<'d, T> {
540mod eha { 535 async fn flush(&mut self) -> Result<(), Error> {
541 536 Ok(())
542 use super::*; 537 }
543
544 impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spim<'d, T> {
545 async fn flush(&mut self) -> Result<(), Error> {
546 Ok(())
547 }
548 538
549 async fn read(&mut self, words: &mut [u8]) -> Result<(), Error> { 539 async fn read(&mut self, words: &mut [u8]) -> Result<(), Error> {
550 self.read(words).await 540 self.read(words).await
551 } 541 }
552 542
553 async fn write(&mut self, data: &[u8]) -> Result<(), Error> { 543 async fn write(&mut self, data: &[u8]) -> Result<(), Error> {
554 self.write(data).await 544 self.write(data).await
555 } 545 }
556 546
557 async fn transfer(&mut self, rx: &mut [u8], tx: &[u8]) -> Result<(), Error> { 547 async fn transfer(&mut self, rx: &mut [u8], tx: &[u8]) -> Result<(), Error> {
558 self.transfer(rx, tx).await 548 self.transfer(rx, tx).await
559 } 549 }
560 550
561 async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error> { 551 async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error> {
562 self.transfer_in_place(words).await 552 self.transfer_in_place(words).await
563 }
564 } 553 }
565} 554}
566 555
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs
index 919bb4ab2..da8e15d02 100644
--- a/embassy-nrf/src/twim.rs
+++ b/embassy-nrf/src/twim.rs
@@ -810,81 +810,72 @@ mod eh02 {
810 } 810 }
811} 811}
812 812
813#[cfg(feature = "unstable-traits")] 813impl embedded_hal_1::i2c::Error for Error {
814mod eh1 { 814 fn kind(&self) -> embedded_hal_1::i2c::ErrorKind {
815 use super::*; 815 match *self {
816 816 Self::TxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other,
817 impl embedded_hal_1::i2c::Error for Error { 817 Self::RxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other,
818 fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { 818 Self::Transmit => embedded_hal_1::i2c::ErrorKind::Other,
819 match *self { 819 Self::Receive => embedded_hal_1::i2c::ErrorKind::Other,
820 Self::TxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other, 820 Self::BufferNotInRAM => embedded_hal_1::i2c::ErrorKind::Other,
821 Self::RxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other, 821 Self::AddressNack => {
822 Self::Transmit => embedded_hal_1::i2c::ErrorKind::Other, 822 embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Address)
823 Self::Receive => embedded_hal_1::i2c::ErrorKind::Other,
824 Self::BufferNotInRAM => embedded_hal_1::i2c::ErrorKind::Other,
825 Self::AddressNack => {
826 embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Address)
827 }
828 Self::DataNack => {
829 embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Data)
830 }
831 Self::Overrun => embedded_hal_1::i2c::ErrorKind::Overrun,
832 Self::Timeout => embedded_hal_1::i2c::ErrorKind::Other,
833 } 823 }
824 Self::DataNack => {
825 embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Data)
826 }
827 Self::Overrun => embedded_hal_1::i2c::ErrorKind::Overrun,
828 Self::Timeout => embedded_hal_1::i2c::ErrorKind::Other,
834 } 829 }
835 } 830 }
831}
836 832
837 impl<'d, T: Instance> embedded_hal_1::i2c::ErrorType for Twim<'d, T> { 833impl<'d, T: Instance> embedded_hal_1::i2c::ErrorType for Twim<'d, T> {
838 type Error = Error; 834 type Error = Error;
839 } 835}
840 836
841 impl<'d, T: Instance> embedded_hal_1::i2c::I2c for Twim<'d, T> { 837impl<'d, T: Instance> embedded_hal_1::i2c::I2c for Twim<'d, T> {
842 fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { 838 fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
843 self.blocking_read(address, buffer) 839 self.blocking_read(address, buffer)
844 } 840 }
845 841
846 fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Self::Error> { 842 fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Self::Error> {
847 self.blocking_write(address, buffer) 843 self.blocking_write(address, buffer)
848 } 844 }
849 845
850 fn write_read(&mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8]) -> Result<(), Self::Error> { 846 fn write_read(&mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8]) -> Result<(), Self::Error> {
851 self.blocking_write_read(address, wr_buffer, rd_buffer) 847 self.blocking_write_read(address, wr_buffer, rd_buffer)
852 } 848 }
853 849
854 fn transaction<'a>( 850 fn transaction<'a>(
855 &mut self, 851 &mut self,
856 _address: u8, 852 _address: u8,
857 _operations: &mut [embedded_hal_1::i2c::Operation<'a>], 853 _operations: &mut [embedded_hal_1::i2c::Operation<'a>],
858 ) -> Result<(), Self::Error> { 854 ) -> Result<(), Self::Error> {
859 todo!(); 855 todo!();
860 }
861 } 856 }
862} 857}
863 858
864#[cfg(all(feature = "unstable-traits", feature = "nightly"))] 859impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> {
865mod eha { 860 async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> {
866 use super::*; 861 self.read(address, read).await
867 impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { 862 }
868 async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> {
869 self.read(address, read).await
870 }
871 863
872 async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { 864 async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> {
873 self.write(address, write).await 865 self.write(address, write).await
874 } 866 }
875 async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { 867 async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
876 self.write_read(address, write, read).await 868 self.write_read(address, write, read).await
877 } 869 }
878 870
879 async fn transaction( 871 async fn transaction(
880 &mut self, 872 &mut self,
881 address: u8, 873 address: u8,
882 operations: &mut [embedded_hal_1::i2c::Operation<'_>], 874 operations: &mut [embedded_hal_1::i2c::Operation<'_>],
883 ) -> Result<(), Self::Error> { 875 ) -> Result<(), Self::Error> {
884 let _ = address; 876 let _ = address;
885 let _ = operations; 877 let _ = operations;
886 todo!() 878 todo!()
887 }
888 } 879 }
889} 880}
890 881