From c0679ca582ea355181db5daf5145d1dd1de5ac2b Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Sat, 24 Feb 2024 11:36:19 +0000 Subject: [PATCH] Use as_ptr() to retrieve pointer to register This is slightly less error prone than `as *const _`. --- rp2040-hal/src/adc.rs | 2 +- rp2040-hal/src/pio.rs | 4 ++-- rp2040-hal/src/spi.rs | 4 ++-- rp2040-hal/src/uart/reader.rs | 2 +- rp2040-hal/src/uart/writer.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rp2040-hal/src/adc.rs b/rp2040-hal/src/adc.rs index 3894bcc41..d12a748d8 100644 --- a/rp2040-hal/src/adc.rs +++ b/rp2040-hal/src/adc.rs @@ -694,7 +694,7 @@ impl<'a, Word> AdcFifo<'a, Word> { /// The [`DmaReadTarget`] returned by this function can be used to initiate DMA transfers /// reading from the ADC. pub fn dma_read_target(&self) -> DmaReadTarget { - DmaReadTarget(self.adc.device.fifo() as *const _ as u32, PhantomData) + DmaReadTarget(self.adc.device.fifo().as_ptr() as u32, PhantomData) } } diff --git a/rp2040-hal/src/pio.rs b/rp2040-hal/src/pio.rs index c38e7ddf0..b54840ad7 100644 --- a/rp2040-hal/src/pio.rs +++ b/rp2040-hal/src/pio.rs @@ -1432,7 +1432,7 @@ unsafe impl ReadTarget for Rx { fn rx_address_count(&self) -> (u32, u32) { ( - unsafe { &*self.block }.rxf(SM::id()) as *const _ as u32, + unsafe { &*self.block }.rxf(SM::id()).as_ptr() as u32, u32::MAX, ) } @@ -1626,7 +1626,7 @@ unsafe impl WriteTarget for Tx { fn tx_address_count(&mut self) -> (u32, u32) { ( - unsafe { &*self.block }.txf(SM::id()) as *const _ as u32, + unsafe { &*self.block }.txf(SM::id()).as_ptr() as u32, u32::MAX, ) } diff --git a/rp2040-hal/src/spi.rs b/rp2040-hal/src/spi.rs index 4da1abc90..8ba70adbb 100644 --- a/rp2040-hal/src/spi.rs +++ b/rp2040-hal/src/spi.rs @@ -518,7 +518,7 @@ macro_rules! impl_write { fn rx_address_count(&self) -> (u32, u32) { ( - self.device.sspdr() as *const _ as u32, + self.device.sspdr().as_ptr() as u32, u32::MAX, ) } @@ -541,7 +541,7 @@ macro_rules! impl_write { fn tx_address_count(&mut self) -> (u32, u32) { ( - self.device.sspdr() as *const _ as u32, + self.device.sspdr().as_ptr() as u32, u32::MAX, ) } diff --git a/rp2040-hal/src/uart/reader.rs b/rp2040-hal/src/uart/reader.rs index 0a86431b9..3a321213f 100644 --- a/rp2040-hal/src/uart/reader.rs +++ b/rp2040-hal/src/uart/reader.rs @@ -244,7 +244,7 @@ unsafe impl> ReadTarget for Reader { } fn rx_address_count(&self) -> (u32, u32) { - (self.device.uartdr() as *const _ as u32, u32::MAX) + (self.device.uartdr().as_ptr() as u32, u32::MAX) } fn rx_increment(&self) -> bool { diff --git a/rp2040-hal/src/uart/writer.rs b/rp2040-hal/src/uart/writer.rs index 505468474..d90072a59 100644 --- a/rp2040-hal/src/uart/writer.rs +++ b/rp2040-hal/src/uart/writer.rs @@ -200,7 +200,7 @@ unsafe impl> WriteTarget for Writer { } fn tx_address_count(&mut self) -> (u32, u32) { - (self.device.uartdr() as *const _ as u32, u32::MAX) + (self.device.uartdr().as_ptr() as u32, u32::MAX) } fn tx_increment(&self) -> bool {