@@ -379,7 +379,7 @@ where
379
379
fn read_data_reg ( & mut self ) -> FrameSize {
380
380
// NOTE(read_volatile) read only 1 byte (the svd2rust API only allows
381
381
// reading a half-word)
382
- unsafe { ptr:: read_volatile ( & self . spi . dr as * const _ as * const FrameSize ) }
382
+ unsafe { ptr:: read_volatile ( ptr :: addr_of! ( self . spi. dr) as * const FrameSize ) }
383
383
}
384
384
385
385
fn write_data_reg ( & mut self , data : FrameSize ) {
@@ -807,10 +807,8 @@ macro_rules! spi_dma {
807
807
// NOTE(unsafe) We own the buffer now and we won't call other `&mut` on it
808
808
// until the end of the transfer.
809
809
let ( ptr, len) = unsafe { buffer. write_buffer( ) } ;
810
- self . channel. set_peripheral_address(
811
- unsafe { & ( * <$SPIi>:: ptr( ) ) . dr as * const _ as u32 } ,
812
- false ,
813
- ) ;
810
+ self . channel
811
+ . set_peripheral_address( unsafe { ( * <$SPIi>:: ptr( ) ) . dr. as_ptr( ) as u32 } , false ) ;
814
812
self . channel. set_memory_address( ptr as u32 , true ) ;
815
813
self . channel. set_transfer_length( len) ;
816
814
@@ -844,10 +842,8 @@ macro_rules! spi_dma {
844
842
// NOTE(unsafe) We own the buffer now and we won't call other `&mut` on it
845
843
// until the end of the transfer.
846
844
let ( ptr, len) = unsafe { buffer. read_buffer( ) } ;
847
- self . channel. set_peripheral_address(
848
- unsafe { & ( * <$SPIi>:: ptr( ) ) . dr as * const _ as u32 } ,
849
- false ,
850
- ) ;
845
+ self . channel
846
+ . set_peripheral_address( unsafe { ( * <$SPIi>:: ptr( ) ) . dr. as_ptr( ) as u32 } , false ) ;
851
847
self . channel. set_memory_address( ptr as u32 , true ) ;
852
848
self . channel. set_transfer_length( len) ;
853
849
@@ -892,17 +888,13 @@ macro_rules! spi_dma {
892
888
panic!( "receive and send buffer lengths do not match!" ) ;
893
889
}
894
890
895
- self . rxchannel. set_peripheral_address(
896
- unsafe { & ( * <$SPIi>:: ptr( ) ) . dr as * const _ as u32 } ,
897
- false ,
898
- ) ;
891
+ self . rxchannel
892
+ . set_peripheral_address( unsafe { ( * <$SPIi>:: ptr( ) ) . dr. as_ptr( ) as u32 } , false ) ;
899
893
self . rxchannel. set_memory_address( rxptr as u32 , true ) ;
900
894
self . rxchannel. set_transfer_length( rxlen) ;
901
895
902
- self . txchannel. set_peripheral_address(
903
- unsafe { & ( * <$SPIi>:: ptr( ) ) . dr as * const _ as u32 } ,
904
- false ,
905
- ) ;
896
+ self . txchannel
897
+ . set_peripheral_address( unsafe { ( * <$SPIi>:: ptr( ) ) . dr. as_ptr( ) as u32 } , false ) ;
906
898
self . txchannel. set_memory_address( txptr as u32 , true ) ;
907
899
self . txchannel. set_transfer_length( txlen) ;
908
900
0 commit comments