gpio configured as GPIO_OUTPUT_INACTIVE gives same physical read for both logical levels

hello Nordic

i am working with nrf52832, ncs v2.1.0

in my device tree i configure a pgio like so :

and on my app i have an init function and an uiinit function which configure this gpio 

init function : 
{....
 nrfx_err_t result = nrfx_spim_init(&dev_config->spim,
                                       &dev_config->def_config,
                                       spim_handler,
                                       (void *)spi_data);
    if (result != NRFX_SUCCESS)
    {
        LOG_ERR("Failed to initialize nrfx_spim_init. result = %d", result);
        return -EBUSY;
    }

    if (spi_data->cs_set)
    {
        spi_data->cs_gpio_data.gpio_dev = spi_data->cs_cntl.gpio.port;
        spi_data->cs_gpio_data.gpio_pin = spi_data->cs_cntl.gpio.pin;

        int ret = gpio_pin_configure(spi_data->cs_cntl.gpio.port, spi_data->cs_cntl.gpio.pin,
                                     spi_data->cs_cntl.gpio.dt_flags | GPIO_OUTPUT_INACTIVE);
        if (0 != ret)
        {
            LOG_ERR("failed to gpio_pin_configure");
            return ret;
        }
        int val_raw = gpio_pin_get_raw(spi_data->cs_cntl.gpio.port, spi_data->cs_cntl.gpio.pin);
        int val = gpio_pin_get(spi_data->cs_cntl.gpio.port, spi_data->cs_cntl.gpio.pin);
        LOG_INF("augu_spi_init cs configure, gpio phys val %d log val = %d", val_raw, val);
    }
...}

uninit function :
{...
   nrfx_spim_uninit(&dev_config->spim);

    if (true == spi_data->cs_set)
    {
        spi_data->cs_gpio_data.gpio_dev = spi_data->cs_cntl.gpio.port;
        spi_data->cs_gpio_data.gpio_pin = spi_data->cs_cntl.gpio.pin;

        int ret = gpio_pin_configure(spi_data->cs_cntl.gpio.port,
                                     spi_data->cs_cntl.gpio.pin,
                                     GPIO_OUTPUT_INACTIVE);

        int val_raw = gpio_pin_get_raw(spi_data->cs_cntl.gpio.port, spi_data->cs_cntl.gpio.pin);
        int val = gpio_pin_get(spi_data->cs_cntl.gpio.port, spi_data->cs_cntl.gpio.pin);
        LOG_INF("augu_spi_uninit cs configure, gpio phys val %d log val = %d", val_raw, val);

... }

in the log i get this :

"augu_spi_init cs configure, gpio phys val 0 log val = 1"

and  "augu_spi_uninit cs configure, gpio phys val 0 log val = 0"

1. any idea why i get physical level 0 for both logical states ?

2. if i change the uninit function to "GPIO_OUTPUT_ACTIVE" then i get the same logs.

according to this from my ncs  

/** Configures GPIO pin as output and initializes it to a logic 0. */
#define GPIO_OUTPUT_INACTIVE    (GPIO_OUTPUT |			\
				 GPIO_OUTPUT_INIT_LOW |		\
				 GPIO_OUTPUT_INIT_LOGICAL)
/** Configures GPIO pin as output and initializes it to a logic 1. */
#define GPIO_OUTPUT_ACTIVE      (GPIO_OUTPUT |			\
				 GPIO_OUTPUT_INIT_HIGH |	\
				 GPIO_OUTPUT_INIT_LOGICAL)

and also according to https://docs.zephyrproject.org/latest/hardware/peripherals/gpio.html

it does not make sense, what am i missing ?

hope to read you soon

best regardsd 

Ziv

Parents Reply Children
No Data
Related