How to toggle a GPIO Pin in I.Mx8mmini

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

How to toggle a GPIO Pin in I.Mx8mmini

2,940 Views
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 Kudos
3 Replies

2,519 Views
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 Kudos

2,519 Views
santhosh2
Contributor IV

Hi.,

Attachment is missing

0 Kudos

2,519 Views
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 Kudos