How to connect multiple SPI devices to the same Instance?

I'm trying to connect the same SPI instance to multiple devices in parallel(besides CS GPIO of course) - however, I tried multiple combinations without great success.

I'm using NCS v2.2.0, nRF52840 / nRF5340 as my main target MCUs

@Karl Ylvisaker

Parents
  • Hello,

    As Rune mentions: could you please clarify whether you mean to have multiple secondary devices on the same SPI bus (communicating with each one in series with the other), or are you looking to communicate in parallel with all the devices?
    Based on the wording of your post I will assume the former. 
    If you are using the SPIM driver then you will need to control the SS gpio yourself, since this is not done by the driver directly.
    I.e asserting the SS gpio for the specific device you are looking to communicate to, before starting the transfer.

    however, I tried multiple combinations without great success.

    Could you elaborate on what you have tried, and what the results have been?

    Best regards,
    Karl

  • This is a good illustration of my desired use case .

    Could you elaborate on what you have tried, and what the results have been?

    I tried to do something like this:

    &spi1 {
        status = "okay";
        pinctrl-0 = <&spi1_pins>;
        #address-cells = <1>;
        #size-cells = <0>;
    
        adg731_1: adg731_1@0 {
            compatible = "adi,adg731";
            reg = <0>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_1";
            cs-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;
        };
    
        adg731_2: adg731_2@1 {
            compatible = "adi,adg731";
            reg = <1>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_2";
            cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
        };
    
        adg731_3: adg731_3@2 {
            compatible = "adi,adg731";
            reg = <2>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_3";
            cs-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
        };
    
        adg731_4: adg731_4@3 {
            compatible = "adi,adg731";
            reg = <3>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_4";
            cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
        };
    };
    
    
    
    
    
    
    

Reply
  • This is a good illustration of my desired use case .

    Could you elaborate on what you have tried, and what the results have been?

    I tried to do something like this:

    &spi1 {
        status = "okay";
        pinctrl-0 = <&spi1_pins>;
        #address-cells = <1>;
        #size-cells = <0>;
    
        adg731_1: adg731_1@0 {
            compatible = "adi,adg731";
            reg = <0>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_1";
            cs-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;
        };
    
        adg731_2: adg731_2@1 {
            compatible = "adi,adg731";
            reg = <1>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_2";
            cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
        };
    
        adg731_3: adg731_3@2 {
            compatible = "adi,adg731";
            reg = <2>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_3";
            cs-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
        };
    
        adg731_4: adg731_4@3 {
            compatible = "adi,adg731";
            reg = <3>;
            spi-max-frequency = <DT_FREQ_KHZ(1000)>;
            label = "ADG731_4";
            cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
        };
    };
    
    
    
    
    
    
    

Children
Related