lpc-rs / lpc8xx-hal

Hardware Abstraction Layer (HAL) for NXP LPC800 series of microcontrollers, written in the Rust programming language
BSD Zero Clause License
31 stars 8 forks source link

Add DynamicPin #297

Closed Lotterleben closed 3 years ago

Lotterleben commented 3 years ago

This PR adds a `DynamicPin which can change direction at runtime. I've also taken the liberty to refactor some duplicate code into helpers.

Also adds an example that demonstrates how to use these.

The current limitation is that the pin id is still baked into a DynamicPin's type, which makes it difficult to e.g. pass a bunch of these around in a collection to pick and reconfigure them at runtime. I'm working on a solution for this that's probably a breaking change to this PR, but am only ~halfway there.

hannobraun commented 3 years ago

Everything's ready to go now. Thanks again, @Lotterleben!