diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-30 22:39:18 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-30 22:39:18 +0000 |
| commit | 9500c8c17b7bace2dcdaadcbbd99ba62be46daa0 (patch) | |
| tree | 4430bea845de53e8551f3732844ebc74c666403a /examples | |
| parent | e36e36dab6b19ae90c6f78b1cdd2233e295bd171 (diff) | |
| parent | 496ad4ed43ab3b0948553d371709771c010de565 (diff) | |
Merge #509
509: Remove unsafe from nRF uarte and improve doco with rationale r=Dirbaio a=huntc
The constructors themselves are not strictly unsafe. Interactions with DMA can be generally unsafe if a future is dropped, but that's a separate issue. It is important that we use the `unsafe` keyword diligently as it can lead to confusion otherwise.
I've also provided some rationale re. the usage of [Uarte] vs [BufferedUarte].
Co-authored-by: huntc <[email protected]>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/buffered_uart.rs | 32 | ||||
| -rw-r--r-- | examples/nrf/src/bin/uart.rs | 3 |
2 files changed, 16 insertions, 19 deletions
diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index 90d288780..5d9075edf 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs | |||
| @@ -24,23 +24,21 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 24 | 24 | ||
| 25 | let irq = interrupt::take!(UARTE0_UART0); | 25 | let irq = interrupt::take!(UARTE0_UART0); |
| 26 | let mut state = State::new(); | 26 | let mut state = State::new(); |
| 27 | let u = unsafe { | 27 | let u = BufferedUarte::new( |
| 28 | BufferedUarte::new( | 28 | &mut state, |
| 29 | &mut state, | 29 | p.UARTE0, |
| 30 | p.UARTE0, | 30 | p.TIMER0, |
| 31 | p.TIMER0, | 31 | p.PPI_CH0, |
| 32 | p.PPI_CH0, | 32 | p.PPI_CH1, |
| 33 | p.PPI_CH1, | 33 | irq, |
| 34 | irq, | 34 | p.P0_08, |
| 35 | p.P0_08, | 35 | p.P0_06, |
| 36 | p.P0_06, | 36 | NoPin, |
| 37 | NoPin, | 37 | NoPin, |
| 38 | NoPin, | 38 | config, |
| 39 | config, | 39 | &mut rx_buffer, |
| 40 | &mut rx_buffer, | 40 | &mut tx_buffer, |
| 41 | &mut tx_buffer, | 41 | ); |
| 42 | ) | ||
| 43 | }; | ||
| 44 | pin_mut!(u); | 42 | pin_mut!(u); |
| 45 | 43 | ||
| 46 | info!("uarte initialized!"); | 44 | info!("uarte initialized!"); |
diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 6b89e083d..208961c8b 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs | |||
| @@ -18,8 +18,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 18 | config.baudrate = uarte::Baudrate::BAUD115200; | 18 | config.baudrate = uarte::Baudrate::BAUD115200; |
| 19 | 19 | ||
| 20 | let irq = interrupt::take!(UARTE0_UART0); | 20 | let irq = interrupt::take!(UARTE0_UART0); |
| 21 | let mut uart = | 21 | let mut uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config); |
| 22 | unsafe { uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config) }; | ||
| 23 | 22 | ||
| 24 | info!("uarte initialized!"); | 23 | info!("uarte initialized!"); |
| 25 | 24 | ||
