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 3e34962 hw/mcu/dialog: Fix pd_com handling in hal_uart
3e34962 is described below
commit 3e3496233ee44c4e3eb545ad5af0a9c4eaec711b
Author: Andrzej Kaczmarek <[email protected]>
AuthorDate: Thu Jul 16 15:46:30 2020 +0200
hw/mcu/dialog: Fix pd_com handling in hal_uart
This ensures PD_COM is acquired only when UART is configured (i.e.
opened) and released when closed.
---
hw/mcu/dialog/da1469x/src/hal_uart.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/hw/mcu/dialog/da1469x/src/hal_uart.c
b/hw/mcu/dialog/da1469x/src/hal_uart.c
index 29730bd..49afdc3 100644
--- a/hw/mcu/dialog/da1469x/src/hal_uart.c
+++ b/hw/mcu/dialog/da1469x/src/hal_uart.c
@@ -425,8 +425,6 @@ hal_uart_init(int port, void *arg)
mcu_gpio_set_pin_function(cfg->pin_cts, MCU_GPIO_MODE_INPUT,
gpiofunc[3]);
}
- da1469x_pd_acquire(MCU_PD_DOMAIN_COM);
-
NVIC_DisableIRQ(irqn);
NVIC_SetPriority(irqn, (1 << __NVIC_PRIO_BITS) - 1);
NVIC_SetVector(irqn, (uint32_t)isr);
@@ -556,6 +554,15 @@ hal_uart_config(int port, int32_t baudrate, uint8_t
databits, uint8_t stopbits,
da1469x_uart_rx_intr_enable(uart);
+ /*
+ * We can acquire PD_COM here to be sure it's acquired only if everything
is
+ * set properly. It's ok to setup UART without acquiring that domain
earlier
+ * explicitly because hal_uart_config shall only be called after
hal_uart_init
+ * and the latter configures GPIOs. Since at least one GPIO is configured,
we
+ * can assume PD_COM is enabled while in active mode.
+ */
+ da1469x_pd_acquire(MCU_PD_DOMAIN_COM);
+
return 0;
}
@@ -593,5 +600,7 @@ hal_uart_close(int port)
uart->rx_pin_func);
}
+ da1469x_pd_release(MCU_PD_DOMAIN_COM);
+
return 0;
}