Retrieving a GPIO's direction (input/output)

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

Retrieving a GPIO's direction (input/output)

2,465件の閲覧回数
nadavintel
Contributor I

Hello friends,

During run-time, I want to get the direction (input/output) of a GPIO pin.

I was expecting something like: gpio_pin_direction_t F(GPIO_Type *base, uint32_t port).

Was searching fsl_gpio.hReference Manual: GPIO. No such method is found :[

Is there any way to retrieve a GPIO pin direction during run-time?

Thank you.

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

2,411件の閲覧回数
Julián_AragónM
NXP TechSupport
NXP TechSupport

Currently there is no API function that specifically reads the direction from a GPIO pin;

The GDIR register functions as direction control when the IOMUXC is in GPIO mode. Each bit specifies the direction of a one-bit signal.

Julin_AragnM_0-1664814421548.pngJulin_AragnM_0-1664814421548.png
Julin_AragnM_1-1664814421549.pngJulin_AragnM_1-1664814421549.png

The GDIR register is a read/write register which you can read during run-time to store or obtain the direction (input/output) of a GPIO pin.  The example you provided (gpio_pin_direction_t F(GPIO_Type *base, uint32_t port)) is a good way of implementing this function.

I hope you find this helpful! If you have any doubts about the register do not hesitate to ask.

Best regards, Julian

0 件の賞賛
返信

2,449件の閲覧回数
carstengroen
Senior Contributor II

Look in the users manual for the chip or look in the fsl_gpio.c file ? There is no guarantee that there is a function in the SDK for every single use of the registers.
Hint: look at GDIR register for the specific port.....