Skip to content

Commit

Permalink
hw/mcu/dialog: GPIO configuration with single value
Browse files Browse the repository at this point in the history
Addressed reviewer comments.
  • Loading branch information
apc067 committed Nov 8, 2024
1 parent 24f7147 commit 6bc9246
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 2 additions & 0 deletions hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void hal_os_tick_calc_params(uint32_t cycles_per_sec);
*
* @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);

Expand Down
24 changes: 7 additions & 17 deletions hw/mcu/dialog/da1469x/src/hal_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,23 +474,6 @@ hal_gpio_irq_disable(int pin)
WKUP_CLEAR_PX(pin);
}

void
mcu_gpio_set_pin_function(int pin, int mode, mcu_gpio_func func)
{
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));

mcu_gpio_unlatch(pin);

__HAL_ENABLE_INTERRUPTS(primask);
}

void
mcu_gpio_set_pin_function_raw(int pin, uint32_t raw_mode)
{
Expand All @@ -509,6 +492,13 @@ 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)
{
Expand Down

0 comments on commit 6bc9246

Please sign in to comment.