Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program panics when accessing the SPI device #158

Open
f-bro opened this issue Feb 7, 2025 · 0 comments
Open

Program panics when accessing the SPI device #158

f-bro opened this issue Feb 7, 2025 · 0 comments

Comments

@f-bro
Copy link

f-bro commented Feb 7, 2025

Hi,

I want to change the SPI clock speed after initialization but the method access_spi panics:

thread 'main' panicked at core/src/panicking.rs:223:5:
attempted to zero-initialize type `embedded_hal_bus::spi::exclusive::ExclusiveDevice<rppal::spi::Spi, rppal::gpio::pin::OutputPin, rppal::hal::Delay>`, which is invalid

The panic occurs while zero-initializing the SPI device:

let spi = core::mem::zeroed();

I'm on a Raspberry Pi using rppal as embedded-hal implementation and embedded-hal-bus as SpiDevice implementation.

I would suggest wrapping the SPI device in an Option<SPI>. This also allows the unsafe block to be removed. I will open a pull request for it.

f-bro added a commit to f-bro/dw1000-rs that referenced this issue Feb 7, 2025
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

No branches or pull requests

1 participant