This is an automated email from the ASF dual-hosted git repository.
janc 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 66cb55495 hw/mcu/dialog: GPIO configuration with single value (#3339)
66cb55495 is described below
commit 66cb554957ea0771f4556c7e2107e840032b724c
Author: Peter Csaszar <[email protected]>
AuthorDate: Tue Nov 12 23:56:42 2024 -0800
hw/mcu/dialog: GPIO configuration with single value (#3339)
* hw/mcu/dialog: GPIO configuration with single value
Add API to support GPIO configuration using a combined mode / I/O properties
value.
---
hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h | 19 +++++++++++++++++++
hw/mcu/dialog/da1469x/src/hal_gpio.c | 23 ++++++++++++++++-------
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
b/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
index 2d0a17dc7..2008efb47 100755
--- a/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
+++ b/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
@@ -94,6 +94,25 @@ const struct qspi_flash_config
*da1469x_qspi_get_config(void);
*/
void hal_os_tick_calc_params(uint32_t cycles_per_sec);
+/**
+ * Configure GPIO using a single value.
+ *
+ * @param pin GPIO ID
+ * @param raw_mode Combined mode / I/O properties value
+ * Mode: Selected feed in the GPIO matrix (see MCU_GPIO_FUNC_*)
+ * I/O propeties: Input [bare/PU/PD] or output [PP/OD] (see
MCU_GPIO_MODE_*)
+ */
+void mcu_gpio_set_pin_function_raw(int pin, uint32_t raw_mode);
+
+/**
+ * Query GPIO mode as a single value.
+ *
+ * @param pin GPIO ID
+ *
+ * @return Combined mode / I/O properties value
+ */
+uint32_t mcu_gpio_get_pin_function_raw(int pin);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/mcu/dialog/da1469x/src/hal_gpio.c
b/hw/mcu/dialog/da1469x/src/hal_gpio.c
index ca394aeaf..164b15ac6 100644
--- a/hw/mcu/dialog/da1469x/src/hal_gpio.c
+++ b/hw/mcu/dialog/da1469x/src/hal_gpio.c
@@ -475,22 +475,31 @@ hal_gpio_irq_disable(int pin)
}
void
-mcu_gpio_set_pin_function(int pin, int mode, mcu_gpio_func func)
+mcu_gpio_set_pin_function_raw(int pin, uint32_t raw_mode)
{
uint32_t primask;
__HAL_DISABLE_INTERRUPTS(primask);
-
mcu_gpio_unlatch_prepare(pin);
-
- GPIO_PIN_MODE_REG(pin) = (func & GPIO_P0_00_MODE_REG_PID_Msk) |
- (mode & (GPIO_P0_00_MODE_REG_PUPD_Msk | GPIO_P0_00_MODE_REG_PPOD_Msk));
-
+ GPIO_PIN_MODE_REG(pin) = raw_mode;
mcu_gpio_unlatch(pin);
-
__HAL_ENABLE_INTERRUPTS(primask);
}
+uint32_t
+mcu_gpio_get_pin_function_raw(int pin)
+{
+ return GPIO_PIN_MODE_REG(pin);
+}
+
+void
+mcu_gpio_set_pin_function(int pin, int mode, mcu_gpio_func func)
+{
+ mcu_gpio_set_pin_function_raw(pin, (func & GPIO_P0_00_MODE_REG_PID_Msk) |
+ (mode &
+ (GPIO_P0_00_MODE_REG_PUPD_Msk |
GPIO_P0_00_MODE_REG_PPOD_Msk)));
+}
+
void
mcu_gpio_enter_sleep(void)
{