golemparts / rppal

A Rust library that provides access to the Raspberry Pi's GPIO, I2C, PWM, SPI and UART peripherals.
MIT License
1.21k stars 96 forks source link

Fix NULL FUNCSEL handling on Raspberry Pi 5 #143

Closed lukeburong closed 5 months ago

lukeburong commented 5 months ago

Fixes #142

This introduces a new variant to gpio::Mode called Null (though something like Disabled may be more appropriate - I just stuck with the datasheet).

After implementing this, the example code from #142 gives the following results on a Raspberry Pi 5:

pinctrl 25 before:

25: no    pn | -- // GPIO25 = none

pinctrl 25 after:

25: ip    pn | lo // GPIO25 = input

And with set_reset_on_drop(true), the pin mode is restored correctly on drop:

pinctrl 25 before:

25: no    pn | -- // GPIO25 = none

pinctrl 25 after:

25: no    pn | -- // GPIO25 = none

The new variant shouldn't affect anything not using the RP1 (much like Alt6 - Alt8 which are also only used in rp1.rs)