Skip to content

Commit b50e52c

Browse files
authored
Fix ADC data register address for DMA (#196)
* Fix ADC data register address for DMA * SPI: Dont take references to references to make invalid addresses * USART: Dont take references to references to make invalid addresses
1 parent 661368d commit b50e52c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/adc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ macro_rules! adc {
18631863
/// Returns the address of the ADC data register. Primarily useful for configuring DMA.
18641864
#[inline(always)]
18651865
pub fn data_register_address(&self) -> u32 {
1866-
&self.adc_reg.dr() as *const _ as u32
1866+
self.adc_reg.dr() as *const _ as u32
18671867
}
18681868

18691869
/// Calibrate the adc for <Input Type>

src/serial/usart.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ macro_rules! uart_shared {
501501
#[inline(always)]
502502
fn address(&self) -> u32 {
503503
// unsafe: only the Tx part accesses the Tx register
504-
&unsafe { &*<$USARTX>::ptr() }.tdr() as *const _ as u32
504+
unsafe { &*<$USARTX>::ptr() }.tdr() as *const _ as u32
505505
}
506506

507507
type MemSize = u8;
@@ -513,7 +513,7 @@ macro_rules! uart_shared {
513513
#[inline(always)]
514514
fn address(&self) -> u32 {
515515
// unsafe: only the Rx part accesses the Rx register
516-
&unsafe { &*<$USARTX>::ptr() }.rdr() as *const _ as u32
516+
unsafe { &*<$USARTX>::ptr() }.rdr() as *const _ as u32
517517
}
518518

519519
type MemSize = u8;

src/spi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ macro_rules! spi {
213213
// NOTE(read_volatile) read only 1 byte (the svd2rust API only allows
214214
// reading a half-word)
215215
return Ok(unsafe {
216-
ptr::read_volatile(&self.spi.dr() as *const _ as *const W)
216+
ptr::read_volatile(self.spi.dr() as *const _ as *const W)
217217
});
218218
} else {
219219
nb::Error::WouldBlock
@@ -360,7 +360,7 @@ macro_rules! spi {
360360
#[inline(always)]
361361
fn address(&self) -> u32 {
362362
// unsafe: only the Tx part accesses the Tx register
363-
&unsafe { &*<$SPIX>::ptr() }.dr() as *const _ as u32
363+
unsafe { &*<$SPIX>::ptr() }.dr() as *const _ as u32
364364
}
365365

366366
type MemSize = u8;

0 commit comments

Comments
 (0)