GPIO set value and get value

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GPIO set value and get value

1,953 Views
cilymo
Contributor I

Hi:

     I'm confused for the gpio control. Here is my step:

       1:    int pin_num = of_get_named_gpio(np, "345-en,fsl", 0);   //GPIO2 IO03  pin_num = 35;

       2:    gpio_direction_output(pin_num, 1);   //Voltage high

      3:    gpiod_get_value(gpio_to_desc(pin_num));   //get "0"

       4:    gpiod_set_value(gpio_to_desc(pin_num),0);   //voltage low

       5:    gpiod_get_value(gpio_to_desc(pin_num));  //get "0"

       6:   gpiod_set_value(gpio_to_desc(pin_num),1);  //voltage high

      7:   gpiod_get_value(gpio_to_desc(pin_num)); //get "0"

       Every time I get the gpio value is "0",  but the pin voltage is the same(high/low) what I set.  how can i get the GPIO value after i set.

Labels (1)
0 Kudos
3 Replies

1,094 Views
Rita_Wang
NXP TechSupport
NXP TechSupport

Which board and which version BSP are you using?

0 Kudos

1,094 Views
cilymo
Contributor I

Hi, 

   I use imx6dl, and BSP version is 4.1.15_2.0.1.

Thanks.

0 Kudos

1,094 Views
Rita_Wang
NXP TechSupport
NXP TechSupport

The GPIO module provides general-purpose pins that can be configured as either inputs
or outputs.
When configured as an output, the pin state (high or low) can be controlled by writing to
an internal register. When configured as an input, the pin input state can be read from an
internal register.

If a pin is configured as GPIO by the IOMUX, the state of the pin should also be set since
it is not initialized by a dedicated hardware module. Setting the pad pull-up, pull-down,
slew rate and so on, with the pad control function may be required as well.
Detail you can refer to the i.MX_Linux_Reference_Manual.pdf,

0 Kudos