Read CS state SPI interface

hello,

i am having configured SPI0 interface as a slave in a Jetson Xavier NX board.

Would it be possible to read from an application developed in c++ the state of the CS pin of that interface? Is there any example on how to do this?

Thanks

Hi borjabasket14,

Are you using the devkit or custom board for Xavier NX?
What’s your Jetpack in use?

Have you tried to use sysfs to read the state of CS pin?

Hi,

I am using l4t 32.6.1, Jetpack 4.6.

I am using a custom board, with exact same pinning as devkit, only difference in that interface is that it is configured as a slave.

I have not tried, but it actually may work. Can you point me a little bit into the direction on how to use it? I have never really used sysfs

Thanks

Let me take SPI0_CS0 as example.
You could find its pinmux as following in pinmux spreadsheet.


It’s PZ.06 for SPI0_CS0.

You could run the following command to get the gpio number for PZ.06

$ sudo cat /sys/kernel/debug/gpio |grep PZ.06
 gpio-498 (PZ.06               )

You could use 498 to export PZ.06 and control it through echo command

$ sudo su
# echo 498 > /sys/class/gpio/export
# cat /sys/class/gpio/PZ.06/direction
# cat /sys/class/gpio/PZ.06/value
# echo out > /sys/class/gpio/PZ.06/direction
# echo 1 > /sys/class/gpio/PZ.06/value

Thanks,

That will do the job. Is it possible to run those commands without being the superuser?

You would need su permission for these operations.
Or you could refer to the following thread with using gpiod to control GPIO.
Unable to access GPIO in the latest L4T 35.3.1 - #23 by lhoang

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.