This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_gpio_cfg_output() and GPIO_PIN_CNF_INPUT_Connect

In this function in nrf_gpio.h, why is there a GPIO_PIN_CNF_INPUT_Connect value there?

Shouldn't that be GPIO_PIN_CNF_INPUT_Disconnect, or does it not really matter?

static __INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
{
    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
    NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
                                            | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
                                            | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
                                            | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
                                            | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
}
  • Hi Eliot,

    The field GPIO_PIN_CNF_INPUT_Connect implies that you connect the input buffer for the GPIO. Is this is set to .._Disconnect, then the IO is detached internally. The reset value is that all GPIOs are detached (or disconnected) and if you forget to set this bit, then it will look like a broken connection while debugging your board.

    The reason why you want this functionality is to avoid floating IOs, which may lead to high current consumption while in sleep.

    Best regards Håkon

Related