Cortex-M0 controlled smart battery charger