Skip to content

Commit

Permalink
Fix build error that assigning to &T is undefined behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Chien Wong <[email protected]>
  • Loading branch information
ivq committed Nov 25, 2023
1 parent fdb0685 commit 42ba992
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
//! let received = block!(rx.read()).unwrap();
//! ```

use core::cell::UnsafeCell;
use core::marker::PhantomData;
use core::ptr;

Expand Down Expand Up @@ -419,7 +420,7 @@ impl<USART: UsartX> crate::hal::serial::Write<u8> for Tx<USART> {
// NOTE(unsafe) atomic write to stateless register
// NOTE(write_volatile) 8-bit write that's not possible through the svd2rust API
unsafe {
ptr::write_volatile(&(*USART::ptr()).data as *const _ as *mut _, byte)
ptr::write_volatile(UnsafeCell::raw_get(&(*USART::ptr()).data as *const _ as _), byte);
}
Ok(())
} else {
Expand Down

0 comments on commit 42ba992

Please sign in to comment.