You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/02/18 11:57:05 UTC

[mynewt-core] 02/02: drivers/da1469x_charger: Keep DCDC off when VBUS is on

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 3b5962962b2c3a52084aaca1cf760b296465a882
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Tue Feb 16 16:12:04 2021 +0100

    drivers/da1469x_charger: Keep DCDC off when VBUS is on
    
    When VBUS is present turn DCDC off, this will allow to
    increase charge current when battery is not full.
    It will also keep battery from partially discharging when its full.
---
 hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c b/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c
index 3107b2a..e1d7b64 100644
--- a/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c
+++ b/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c
@@ -27,6 +27,7 @@
 #include <bsp/bsp.h>
 #if MYNEWT_VAL(DA1469X_CHARGER_USE_CHARGE_CONTROL)
 #include <charge-control/charge_control.h>
+#include <mcu/da1469x_prail.h>
 #endif
 
 int
@@ -127,6 +128,18 @@ static void
 da1469x_vbus_state_changed_event_cb(struct os_event *ev)
 {
     assert(ev);
+#if MYNEWT_VAL(MCU_DCDC_ENABLE)
+    /*
+     * If VBUS is present turn off DCDC so charging current is higher.
+     * When devices is fully charged as long as VBUS is present battery will
+     * no be used to power DCDC so it will not deplete.
+     */
+    if ((CRG_TOP->ANA_STATUS_REG & CRG_TOP_ANA_STATUS_REG_VBUS_AVAILABLE_Msk) != 0) {
+        da1469x_prail_dcdc_disable();
+    } else {
+        da1469x_prail_dcdc_restore();
+    }
+#endif
     NVIC_SetPendingIRQ(CHARGER_STATE_IRQn);
 }