We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Multiple devices on same SPI bus



  • Hello,

    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

    FILE spi1=fopen("/dev/spidev1.0",O_RDWR);

    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?

    Thanks



  • @nsmith said in Multiple devices on same SPI bus:

    Do i need to do insmod command three times with three different chip select pins?

    No, you can't insmod the 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 /dev/spidev1.0, /dev/spidev1.1 and /dev/spidev1.2, resp.

    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.


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.