Skip to content

Commit

Permalink
Use as_ptr() to retrieve pointer to register
Browse files Browse the repository at this point in the history
This is slightly less error prone than `as *const _`.
  • Loading branch information
jannic committed Feb 24, 2024
1 parent c11fed9 commit c0679ca
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rp2040-hal/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Word> {
DmaReadTarget(self.adc.device.fifo() as *const _ as u32, PhantomData)
DmaReadTarget(self.adc.device.fifo().as_ptr() as u32, PhantomData)
}
}

Expand Down
4 changes: 2 additions & 2 deletions rp2040-hal/src/pio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ unsafe impl<SM: ValidStateMachine> ReadTarget for Rx<SM> {

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,
)
}
Expand Down Expand Up @@ -1626,7 +1626,7 @@ unsafe impl<SM: ValidStateMachine> WriteTarget for Tx<SM> {

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,
)
}
Expand Down
4 changes: 2 additions & 2 deletions rp2040-hal/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Expand All @@ -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,
)
}
Expand Down
2 changes: 1 addition & 1 deletion rp2040-hal/src/uart/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ unsafe impl<D: UartDevice, P: ValidUartPinout<D>> ReadTarget for Reader<D, P> {
}

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 {
Expand Down
2 changes: 1 addition & 1 deletion rp2040-hal/src/uart/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ unsafe impl<D: UartDevice, P: ValidUartPinout<D>> WriteTarget for Writer<D, P> {
}

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 {
Expand Down

0 comments on commit c0679ca

Please sign in to comment.