Removed unsafe from uarte

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.
This commit is contained in:
huntc
2021-12-01 09:14:24 +11:00
parent e36e36dab6
commit 469852c667
4 changed files with 32 additions and 41 deletions

View File

@ -24,23 +24,21 @@ async fn main(_spawner: Spawner, p: Peripherals) {
let irq = interrupt::take!(UARTE0_UART0);
let mut state = State::new();
let u = unsafe {
BufferedUarte::new(
&mut state,
p.UARTE0,
p.TIMER0,
p.PPI_CH0,
p.PPI_CH1,
irq,
p.P0_08,
p.P0_06,
NoPin,
NoPin,
config,
&mut rx_buffer,
&mut tx_buffer,
)
};
let u = BufferedUarte::new(
&mut state,
p.UARTE0,
p.TIMER0,
p.PPI_CH0,
p.PPI_CH1,
irq,
p.P0_08,
p.P0_06,
NoPin,
NoPin,
config,
&mut rx_buffer,
&mut tx_buffer,
);
pin_mut!(u);
info!("uarte initialized!");

View File

@ -18,8 +18,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
config.baudrate = uarte::Baudrate::BAUD115200;
let irq = interrupt::take!(UARTE0_UART0);
let mut uart =
unsafe { uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config) };
let mut uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config);
info!("uarte initialized!");