You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2019/09/05 16:40:44 UTC
[mynewt-core] branch master updated: hw/mcu/dialog: Add option to
have GPIOs always enabled
This is an automated email from the ASF dual-hosted git repository.
andk 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 359ede4 hw/mcu/dialog: Add option to have GPIOs always enabled
359ede4 is described below
commit 359ede4aa0d7502abff3ebe4d4ce407f6f89c2b1
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Aug 26 12:05:23 2019 +0200
hw/mcu/dialog: Add option to have GPIOs always enabled
This adds option to disable retaining of GPIO pins state and simply have
PD_COM always enabled, even if deep sleep is enabled. Such mode is
enabled if number of retained GPIO pins is set to negative value.
---
hw/mcu/dialog/da1469x/src/hal_gpio.c | 21 +++++++++++++++------
hw/mcu/dialog/da1469x/syscfg.yml | 5 ++++-
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/hw/mcu/dialog/da1469x/src/hal_gpio.c b/hw/mcu/dialog/da1469x/src/hal_gpio.c
index 3bd8243..b3f98ac 100644
--- a/hw/mcu/dialog/da1469x/src/hal_gpio.c
+++ b/hw/mcu/dialog/da1469x/src/hal_gpio.c
@@ -86,10 +86,11 @@ struct hal_gpio_irq {
static struct hal_gpio_irq hal_gpio_irqs[HAL_GPIO_MAX_IRQ];
-static uint32_t hal_gpio_latch_state[2];
-
+#if MYNEWT_VAL(MCU_GPIO_RETAINABLE_NUM) >= 0
+static uint32_t g_mcu_gpio_latch_state[2];
static uint8_t g_mcu_gpio_retained_num;
static struct da1469x_retreg g_mcu_gpio_retained[MYNEWT_VAL(MCU_GPIO_RETAINABLE_NUM)];
+#endif
/*
* We assume that any latched pin has default configuration, i.e. was either
@@ -109,6 +110,7 @@ static struct da1469x_retreg g_mcu_gpio_retained[MYNEWT_VAL(MCU_GPIO_RETAINABLE_
* calling mcu_gpio_latch().
*/
+#if MYNEWT_VAL(MCU_GPIO_RETAINABLE_NUM) >= 0
static void
mcu_gpio_retained_add_port(uint32_t latch_val, volatile uint32_t *base_reg)
{
@@ -129,14 +131,17 @@ mcu_gpio_retained_add_port(uint32_t latch_val, volatile uint32_t *base_reg)
retreg++;
}
}
+#endif
static void
mcu_gpio_retained_refresh(void)
{
+#if MYNEWT_VAL(MCU_GPIO_RETAINABLE_NUM) >= 0
g_mcu_gpio_retained_num = 0;
mcu_gpio_retained_add_port(CRG_TOP->P0_PAD_LATCH_REG, &GPIO->P0_00_MODE_REG);
mcu_gpio_retained_add_port(CRG_TOP->P1_PAD_LATCH_REG, &GPIO->P1_00_MODE_REG);
+#endif
}
static inline void
@@ -435,12 +440,13 @@ mcu_gpio_set_pin_function(int pin, int mode, mcu_gpio_func func)
void
mcu_gpio_enter_sleep(void)
{
+#if MYNEWT_VAL(MCU_GPIO_RETAINABLE_NUM) >= 0
if (g_mcu_gpio_retained_num == 0) {
return;
}
- hal_gpio_latch_state[0] = CRG_TOP->P0_PAD_LATCH_REG;
- hal_gpio_latch_state[1] = CRG_TOP->P1_PAD_LATCH_REG;
+ g_mcu_gpio_latch_state[0] = CRG_TOP->P0_PAD_LATCH_REG;
+ g_mcu_gpio_latch_state[1] = CRG_TOP->P1_PAD_LATCH_REG;
da1469x_retreg_update(g_mcu_gpio_retained, g_mcu_gpio_retained_num);
@@ -448,11 +454,13 @@ mcu_gpio_enter_sleep(void)
CRG_TOP->P1_RESET_PAD_LATCH_REG = CRG_TOP_P1_PAD_LATCH_REG_P1_LATCH_EN_Msk;
da1469x_pd_release(MCU_PD_DOMAIN_COM);
+#endif
}
void
mcu_gpio_exit_sleep(void)
{
+#if MYNEWT_VAL(MCU_GPIO_RETAINABLE_NUM) >= 0
if (g_mcu_gpio_retained_num == 0) {
return;
}
@@ -465,6 +473,7 @@ mcu_gpio_exit_sleep(void)
GPIO->P0_DATA_REG = GPIO->P0_DATA_REG;
GPIO->P1_DATA_REG = GPIO->P1_DATA_REG;
- CRG_TOP->P0_PAD_LATCH_REG = hal_gpio_latch_state[0];
- CRG_TOP->P1_PAD_LATCH_REG = hal_gpio_latch_state[1];
+ CRG_TOP->P0_PAD_LATCH_REG = g_mcu_gpio_latch_state[0];
+ CRG_TOP->P1_PAD_LATCH_REG = g_mcu_gpio_latch_state[1];
+#endif
}
diff --git a/hw/mcu/dialog/da1469x/syscfg.yml b/hw/mcu/dialog/da1469x/syscfg.yml
index e75c066..f65c264 100644
--- a/hw/mcu/dialog/da1469x/syscfg.yml
+++ b/hw/mcu/dialog/da1469x/syscfg.yml
@@ -31,13 +31,16 @@ syscfg.defs:
description: >
Specifies whether or not to enable SIMO DC-DC Converter.
value: 0
-
+
MCU_GPIO_RETAINABLE_NUM:
description: >
Number of GPIO pins which can have its state retained in
deep sleep. This applies only if deep sleep is enabled since
PD_COM will be disabled before entering deep sleep and thus
state of any configured GPIO has to be retained and restored.
+ If set to -1, power domain which controls GPIO pins will be
+ always active and thus retaining and restoring of GPIO pins
+ state is disabled.
value: 4
MCU_GPIO_MAX_IRQ:
desriptin: >