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

Improve API for switching to low-power modes #3

Open hannobraun opened 6 years ago

hannobraun commented 6 years ago

The current Pmu API only support switching to sleep mode. All other low-power modes should be supported as well.

I think there's also some potential for embedded-hal here. I'd like to expore the possibility of creating a trait, PowerMode, and implementing this trait for each supported power mode.

That trait could live in embedded-hal. The sleep module could be updated to depend on PowerMode instead of depending on Pmu directly.

hannobraun commented 6 years ago

~There's a problem with LowPowerClock: It starts with clock::state::Disabled, but that may be wrong, as we can't know what happened before the HAL was initialized.~

~I'm not sure if that leads to any actual problems, but it's at the very least misleading. Maybe it would be best to add a third clock state, Unknown, and start with that.~

Edit: This comment has been resolved in the meantime.

hannobraun commented 6 years ago

I've added support for additional low-power modes in #106.

hannobraun commented 6 years ago

Before trying to design anything that can be submitted to embedded-hal, at least #108, #109, and #110 should be resolved.