@@ -379,7 +379,7 @@ where
379379 fn read_data_reg ( & mut self ) -> FrameSize {
380380 // NOTE(read_volatile) read only 1 byte (the svd2rust API only allows
381381 // 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 ) }
383383 }
384384
385385 fn write_data_reg ( & mut self , data : FrameSize ) {
@@ -807,10 +807,8 @@ macro_rules! spi_dma {
807807 // NOTE(unsafe) We own the buffer now and we won't call other `&mut` on it
808808 // until the end of the transfer.
809809 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 ) ;
814812 self . channel. set_memory_address( ptr as u32 , true ) ;
815813 self . channel. set_transfer_length( len) ;
816814
@@ -844,10 +842,8 @@ macro_rules! spi_dma {
844842 // NOTE(unsafe) We own the buffer now and we won't call other `&mut` on it
845843 // until the end of the transfer.
846844 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 ) ;
851847 self . channel. set_memory_address( ptr as u32 , true ) ;
852848 self . channel. set_transfer_length( len) ;
853849
@@ -892,17 +888,13 @@ macro_rules! spi_dma {
892888 panic!( "receive and send buffer lengths do not match!" ) ;
893889 }
894890
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 ) ;
899893 self . rxchannel. set_memory_address( rxptr as u32 , true ) ;
900894 self . rxchannel. set_transfer_length( rxlen) ;
901895
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 ) ;
906898 self . txchannel. set_memory_address( txptr as u32 , true ) ;
907899 self . txchannel. set_transfer_length( txlen) ;
908900
0 commit comments