diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-07-23 15:13:47 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-07-23 15:13:47 +0200 |
| commit | 709df0dc1dfff577fb79bbc2f67ea84670072456 (patch) | |
| tree | 4a54aee47c0d3881b9e0bc809e075728cee8eeae /embassy-nrf/src/buffered_uarte.rs | |
| parent | 19d1ef0e29fdd0bf0407cbe37c388e8a87e7ddfe (diff) | |
nrf: replace PhantomData usages with PeripheralRef.
Diffstat (limited to 'embassy-nrf/src/buffered_uarte.rs')
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 036af3804..89c1ba908 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -15,14 +15,13 @@ | |||
| 15 | 15 | ||
| 16 | use core::cmp::min; | 16 | use core::cmp::min; |
| 17 | use core::future::Future; | 17 | use core::future::Future; |
| 18 | use core::marker::PhantomData; | ||
| 19 | use core::sync::atomic::{compiler_fence, Ordering}; | 18 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 20 | use core::task::Poll; | 19 | use core::task::Poll; |
| 21 | 20 | ||
| 22 | use embassy::waitqueue::WakerRegistration; | 21 | use embassy::waitqueue::WakerRegistration; |
| 23 | use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; | 22 | use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; |
| 24 | use embassy_hal_common::ring_buffer::RingBuffer; | 23 | use embassy_hal_common::ring_buffer::RingBuffer; |
| 25 | use embassy_hal_common::{into_ref, low_power_wait_until}; | 24 | use embassy_hal_common::{into_ref, low_power_wait_until, PeripheralRef}; |
| 26 | use futures::future::poll_fn; | 25 | use futures::future::poll_fn; |
| 27 | // Re-export SVD variants to allow user to directly set values | 26 | // Re-export SVD variants to allow user to directly set values |
| 28 | pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; | 27 | pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; |
| @@ -54,7 +53,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> State<'d, U, T> { | |||
| 54 | } | 53 | } |
| 55 | 54 | ||
| 56 | struct StateInner<'d, U: UarteInstance, T: TimerInstance> { | 55 | struct StateInner<'d, U: UarteInstance, T: TimerInstance> { |
| 57 | phantom: PhantomData<&'d mut U>, | 56 | _peri: PeripheralRef<'d, U>, |
| 58 | timer: Timer<'d, T>, | 57 | timer: Timer<'d, T>, |
| 59 | _ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>, | 58 | _ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>, |
| 60 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>, | 59 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>, |
| @@ -78,7 +77,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> Unpin for BufferedUarte<'d, U, T> { | |||
| 78 | impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | 77 | impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { |
| 79 | pub fn new( | 78 | pub fn new( |
| 80 | state: &'d mut State<'d, U, T>, | 79 | state: &'d mut State<'d, U, T>, |
| 81 | _uarte: impl Peripheral<P = U> + 'd, | 80 | peri: impl Peripheral<P = U> + 'd, |
| 82 | timer: impl Peripheral<P = T> + 'd, | 81 | timer: impl Peripheral<P = T> + 'd, |
| 83 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, | 82 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, |
| 84 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, | 83 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, |
| @@ -91,7 +90,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 91 | rx_buffer: &'d mut [u8], | 90 | rx_buffer: &'d mut [u8], |
| 92 | tx_buffer: &'d mut [u8], | 91 | tx_buffer: &'d mut [u8], |
| 93 | ) -> Self { | 92 | ) -> Self { |
| 94 | into_ref!(ppi_ch1, ppi_ch2, irq, rxd, txd, cts, rts); | 93 | into_ref!(peri, ppi_ch1, ppi_ch2, irq, rxd, txd, cts, rts); |
| 95 | 94 | ||
| 96 | let r = U::regs(); | 95 | let r = U::regs(); |
| 97 | 96 | ||
| @@ -163,7 +162,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 163 | 162 | ||
| 164 | Self { | 163 | Self { |
| 165 | inner: PeripheralMutex::new(irq, &mut state.0, move || StateInner { | 164 | inner: PeripheralMutex::new(irq, &mut state.0, move || StateInner { |
| 166 | phantom: PhantomData, | 165 | _peri: peri, |
| 167 | timer, | 166 | timer, |
| 168 | _ppi_ch1: ppi_ch1, | 167 | _ppi_ch1: ppi_ch1, |
| 169 | _ppi_ch2: ppi_ch2, | 168 | _ppi_ch2: ppi_ch2, |
