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.
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,