How to toggle a GPIO Pin in I.Mx8mmini

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to toggle a GPIO Pin in I.Mx8mmini

3,452 次查看
santhosh2
Contributor IV

Hi,

I want to  toggle a GPIO Pin in I.Mx8mmini to control read write operation. How to write a simple application code to do this

Regards

Santhosh Kumar S

0 项奖励
回复
3 回复数

3,031 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Santhosh

one can refer to sect.2.1.6 General Purpose Input/Output (GPIO)

attached Linux Manual.

Best regards
igor

0 项奖励
回复

3,031 次查看
santhosh2
Contributor IV

Hi.,

Attachment is missing

0 项奖励
回复

3,031 次查看
peter_tian
NXP Employee
NXP Employee

Hello Santhosh Kumar S,

You can try the way as following:

1. Make sure the pad mux is GPIO ALT in dts.

2. Linux Userspace Naming Conversion

Linux gpio number = (gpio_bank - 1) * 32 + gpio_bit

For example, for gpiom_n, num=32 * (m-1) + n.

3. Input command to your Linux console

/* export gpio */

echo num > /sys/class/gpio/export

/* set the direction of gpio as output */

echo out > /sys/class/gpio/gpio[num]/direction

/* output low level */

echo 0 > /sys/class/gpio/gpio[num]/value

/* output high level */

echo 1 > /sys/class/gpio/gpio[num]/value

Best Regards,

Peter

0 项奖励
回复