diff options
Diffstat (limited to 'embassy-nrf/src/spim.rs')
| -rw-r--r-- | embassy-nrf/src/spim.rs | 91 |
1 files changed, 40 insertions, 51 deletions
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")] | 498 | impl embedded_hal_1::spi::Error for Error { |
| 499 | mod 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> { | 508 | impl<'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> { | 512 | impl<'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"))] | 534 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spim<'d, T> { |
| 540 | mod 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 | ||
