Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpio: Fix GPIO high-speed state inconsistency
There are two valid ways to prepare a high-speed GPIO output: ```rust pub fn configure_led(pad: LedPadType) -> LED { let mut led = hal::gpio::GPIO::new(pad); led.set_fast(true); led.output() } ``` and ```rust pub fn configure_led(pad: LedPadType) -> LED { let mut led = hal::gpio::GPIO::new(pad).output(); led.set_fast(true); led } ``` the former will put the GPIO into high-speed, or 'fast,' mode before setting 'output mode.' The latter will put the GPIO into output mode before fast mode. After transitioning into fast mode, the GPIO will start to reference a different GPIO register block. The issue is that, after entering fast mode, the output / input state of the pin is not maintained. In the second snippet, the set_fast(true) call ends up reverting the GPIO state back to 'input,' since the newly-referenced register block does not maintain the same GPIO input / output configuration. This commit updates the set_fast() method to maintain the GPIO I/O state for the new register block. It makes it so that either of the above patterns work.
- Loading branch information