Skip to content

Commit

Permalink
nrf_gpio: Add function for reading pin pull mode
Browse files Browse the repository at this point in the history
This patch adds a new function to read the pull mode
configuration of a pin.
  • Loading branch information
aykevl authored and kl-cruz committed Aug 6, 2018
1 parent 8492302 commit 3ab39a9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions hal/nrf_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,15 @@ __STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number)
*/
__STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number);

/**
* @brief Function for reading the pull configuration of a GPIO pin.
*
* @param pin_number Specifies the pin number to read.
*
* @retval Pull configuration.
*/
__STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number);

/**
* @brief Function for setting output direction on selected pins on a given port.
*
Expand Down Expand Up @@ -683,6 +692,15 @@ __STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number)
}


__STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number)
{
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);

return (nrf_gpio_pin_pull_t)((reg->PIN_CNF[pin_number] &
GPIO_PIN_CNF_PULL_Msk) >> GPIO_PIN_CNF_PULL_Pos);
}


__STATIC_INLINE void nrf_gpio_port_dir_output_set(NRF_GPIO_Type * p_reg, uint32_t out_mask)
{
p_reg->DIRSET = out_mask;
Expand Down

0 comments on commit 3ab39a9

Please sign in to comment.