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 2019/05/09 10:51:13 UTC

[mynewt-core] branch master updated: hw/mcu/dialog: Enable DCDC only when VBAT is OK

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


The following commit(s) were added to refs/heads/master by this push:
     new 2269b4f  hw/mcu/dialog: Enable DCDC only when VBAT is OK
2269b4f is described below

commit 2269b4fe2a6afdbe7c558e7b2a4ffff7fa2d7421
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed May 8 12:09:49 2019 +0200

    hw/mcu/dialog: Enable DCDC only when VBAT is OK
    
    Enabling DCDC converter when battery level is low results
    in instant reboot even when VBUS is present.
    This would make it impossible to charge battery if it drops
    below critical level.
---
 hw/mcu/dialog/da1469x/src/da1469x_prail.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/da1469x_prail.c b/hw/mcu/dialog/da1469x/src/da1469x_prail.c
index 2b528ec..e31909d 100644
--- a/hw/mcu/dialog/da1469x/src/da1469x_prail.c
+++ b/hw/mcu/dialog/da1469x/src/da1469x_prail.c
@@ -122,20 +122,33 @@ da1469x_prail_dcdc_enable(void)
     DCDC->DCDC_V14_REG |= DCDC_DCDC_VDD_REG_DCDC_VDD_ENABLE_HV_Msk;
     DCDC->DCDC_V14_REG |= DCDC_DCDC_VDD_REG_DCDC_VDD_ENABLE_LV_Msk;
 
-    DCDC->DCDC_CTRL1_REG |= DCDC_DCDC_CTRL1_REG_DCDC_ENABLE_Msk;
-
     da1469x_retreg_init(g_mcu_dcdc_config, ARRAY_SIZE(g_mcu_dcdc_config));
     da1469x_retreg_assign(&g_mcu_dcdc_config[0], &DCDC->DCDC_V18_REG);
     da1469x_retreg_assign(&g_mcu_dcdc_config[1], &DCDC->DCDC_V18P_REG);
     da1469x_retreg_assign(&g_mcu_dcdc_config[2], &DCDC->DCDC_VDD_REG);
     da1469x_retreg_assign(&g_mcu_dcdc_config[3], &DCDC->DCDC_V14_REG);
     da1469x_retreg_assign(&g_mcu_dcdc_config[4], &DCDC->DCDC_CTRL1_REG);
+
+    /*
+     * Enabling DCDC while VBAT is below 2.5 V renders system unstable even
+     * if VBUS is available. Enable DCDC only if VBAT is above minimal value.
+     */
+    if (CRG_TOP->ANA_STATUS_REG & CRG_TOP_ANA_STATUS_REG_COMP_VBAT_HIGH_Msk) {
+        DCDC->DCDC_CTRL1_REG |= DCDC_DCDC_CTRL1_REG_DCDC_ENABLE_Msk;
+    }
 }
 
 void
 da1469x_prail_dcdc_restore(void)
 {
-    da1469x_retreg_restore(g_mcu_dcdc_config, ARRAY_SIZE(g_mcu_dcdc_config));
+    /*
+     * Enabling DCDC while VBAT is below 2.5 V renders system unstable even
+     * if VBUS is available. Enable DCDC only if VBAT is above minimal value.
+     */
+    if (CRG_TOP->ANA_STATUS_REG & CRG_TOP_ANA_STATUS_REG_COMP_VBAT_HIGH_Msk) {
+        da1469x_retreg_restore(g_mcu_dcdc_config, ARRAY_SIZE(g_mcu_dcdc_config));
+        DCDC->DCDC_CTRL1_REG |= DCDC_DCDC_CTRL1_REG_DCDC_ENABLE_Msk;
+    }
 }
 #endif