nrf-rs / nrf-hal

A Rust HAL for the nRF family of devices
Apache License 2.0
499 stars 139 forks source link

Add method for controlling GPIO push-pull output drive #424

Closed BartMassey closed 6 months ago

BartMassey commented 1 year ago

The nRF GPIO output pins support a "high drive" mode for low and high push-pull outputs individually. A high-drive output can source more current, and thus has a faster transition than "standard drive". I needed this for experimenting with the MicroBit v2 speaker output pin.

Right now, this crate supports only "standard drive" push-pull outputs. This non-breaking pull request add an .into_push_pull_output_drive() method to pins, with an extra configuration argument DriveConfig. This is kind of gross, but was chosen to avoid changing .into_push_pull_output().

I would be happy to add tests, but would need some tutoring to understand exactly how. Bikeshedding is also quite welcome.