Multiple devices on same SPI bus
Im using this To set up a SPI device on the bus
insmod spi-gpio-custom bus0=1,11,5,4,0,100000,18
Then in C I use
So what if i have 3 devices on the same SPI bus with 3 different chip select pins.
Do i need to do insmod command three times with three different chip select pins? Then do fopen on the three resulting devices in /dev?
Anybody have examples of that?
luz last edited by
Do i need to do insmod command three times with three different chip select pins?
No, you can't
insmodthe same kernel module multiple times.
But you can just append another three numbers for each additional CS you need, the first being the mode, the second the speed, and the third the GPIO for the CS.
Like this, which adds a second CS with SPI mode=0, speed=100kHz on GPIO19, and a third on GPIO44:
insmod spi-gpio-custom bus0=1,11,5,4,0,100000,18,0,100000,19,0,100000,44
You can repeat that up to a total of 8 CS lines!
Then do fopen on the three resulting devices in /dev?
Yes, these will be named
BTW: if you need multiple buses, i.e. another set of SCK,MISO,MOSI plus some CS, you can append
bus1=2,...to the same command line, separated with a space. Up to 4 buses are supported.