Skip to content

Conversation

CNLHC
Copy link

@CNLHC CNLHC commented Nov 17, 2024

This PR use the write method to update register in the qspi,spi and usart HAL since the current updating way will cause compiler error like this (using nightly-2021-11-15-aarch64-apple-darwin toolchain)

error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
   --> eco/stm32l4xx-hal/src/spi.rs:271:34
    |
271 |                           unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut u8, byte) }
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
371 | / hal! {
372 | |     SPI2: (spi2, spi2_slave, pclk1),
373 | | }
    | |_- in this macro invocation
    |
    = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
    = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`
    = note: this error originates in the macro `hal` (in Nightly builds, run with -Z macro-backtrace for more info)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant