Power management is usually something very dependent on the target MCU however ChibiOS can be optimized for power usage.
The HAL component abstracts some mechanisms related to power management. Most high level drivers in the HAL component follows a common pattern for some important APIs, two functions appear on most drivers:
xxxStart() activates and configure a driver, the function
xxxStop() deactivates the driver. The exact behavior of those functions is implementation-dependent but usually you may expect the following actions.
Starting a driver involves the following logical steps:
Steps performed when stopping a driver:
Stopping a peripheral clock can save a significant amount of power, an intelligent use of the start/stop functions can help reduce the overall consumption. Some suggestions:
There are several optimizations you can implement in the HAL usage:
The kernel automatically puts the CPU in an architecture-dependent lower power “wait for interrupts” state when there is no code to execute but there are two considerations:
CH_CFG_TIME_QUANTUMto zero, see the article “Round Robin scheduling explained”, this reduces the kernel-related overhead and thus power consumption.