GPIO set value and get value

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

GPIO set value and get value

2,375件の閲覧回数
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.

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

1,516件の閲覧回数
Rita_Wang
NXP TechSupport
NXP TechSupport

Which board and which version BSP are you using?

0 件の賞賛
返信

1,516件の閲覧回数
cilymo
Contributor I

Hi, 

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

Thanks.

0 件の賞賛
返信

1,516件の閲覧回数
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 件の賞賛
返信