On the use of TX2 's J21gpio pin

I’m a newbie.
How can I get a value from a GPIO pin if I want to set up a program that uses a TX2 j21 GPIO pin to get the sensor value?

hello p17023pp,

may I have more details about “what’s” sensor values your would like to gather?
also, you could refer to kernel sources for gpio macros. thanks


Hello JerryChang,

Thank you for your reply.
Sorry for the delay in reply.

I would like to use a GPIO sensor, an accelerometer sensor (MPU-9250), a sensor such as a switch, and an ultrasound sensor (HC-SR04).

The MPU-9250 can speak I2C or SPI. You can talk to that using the level-shifted bus interface, and using the Linux driver for I2C or SPI. (In general, bandwidth is higher with SPI, integration is easier with I2C.)

For the switch and ultrasonic, you will need to talk to the GPIO pins.
Check out this post (and the ZIP archive it contains) for ideas: