<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102776/does-zephyr-spi-apis-support-two-chip-select-pins</link><description>I would like to use Zephyr SPI APIs ( docs.zephyrproject.org/.../spi.html) to control external ADCs. Since I need two chip select pins for selection ADC1, ADC2, ADC3, and ADC4. Does Zephyr SPI APIs support two chip select pins?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Sep 2023 14:00:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102776/does-zephyr-spi-apis-support-two-chip-select-pins" /><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/446090?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2023 14:00:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a133bde-c948-4b1b-8cbc-234a7d40d6a8</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/446060?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2023 12:46:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54c717f4-8139-49c8-98f0-c700cede9858</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;That is correct, its well described in the blog from the last post.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I had a look and we don&amp;#39;t have any samples for the adxl362 or adxl372 not using the sensor api. But there are Zephyr samples where they are used togheter with the Sensor API. If you check Zephyr/drivers/sensor/ you will find both the&amp;nbsp;&lt;span&gt;adxl362 or adxl372 that you can have a look at.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Runar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/446047?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2023 11:36:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:528b1982-670a-49b7-9d98-492e34bb1a6e</guid><dc:creator>snowuyl</dc:creator><description>&lt;ol&gt;
&lt;li&gt;Thanks for your reply! I don&amp;#39;t use sensor API in your last post. Do you mean if I access adxl362 or adxl372 device nodes directly, I don&amp;rsquo;t need to worry about SPI chip selection? If the answer is yes, does Nordic provide C samples to access adxl362 or adxl372?&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/446037?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2023 11:12:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56ea26e2-f5b4-4690-856d-d0c99cf1b290</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi, are you using the sensor API I linked in my last post?&amp;nbsp; If not this blog covers how to use spi in zephyr for e generic device&amp;nbsp;&lt;a href="https://blog.golioth.io/how-to-use-generic-spi-devices-with-zephyr/"&gt;https://blog.golioth.io/how-to-use-generic-spi-devices-with-zephyr/&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Anyway you should not have to worry about the chip select&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/446000?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2023 08:54:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:056ba88b-c871-416f-b650-55a9459d1ad8</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply! Which API is used for SPI chip selection?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/445996?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2023 08:29:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e31d8ff-7548-4336-a573-5347fd3082b1</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;If you are using the sensor api it you dont have to worry about it. The API does it for you&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/sensor.html#sensor-api"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/sensor.html#sensor-api&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/445983?ContentTypeID=1</link><pubDate>Thu, 14 Sep 2023 06:22:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc2b5b99-bf08-4bf7-a018-82969ad2bd13</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply! Now I encounter another problem. From sample you provided, there are two SPI chip select pins (gpio0,8 and gpio0,7). How can I control SPI chip select for selecting adxl362 or adxl372?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/440892?ContentTypeID=1</link><pubDate>Fri, 11 Aug 2023 08:28:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e98544a2-a726-4ffe-9582-0bdf1a3f07f1</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;No worries, happy to help. I will just set this case to closed if that is okey with you?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/440887?ContentTypeID=1</link><pubDate>Fri, 11 Aug 2023 08:02:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bdd92d1-ef2d-41e5-aae1-758ba3bd8509</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr SPI APIs support two chip select pins?</title><link>https://devzone.nordicsemi.com/thread/440881?ContentTypeID=1</link><pubDate>Fri, 11 Aug 2023 07:45:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:593848f2-b879-462b-a075-51562c29b674</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;There is no problem with multiple external ADC, you just need to set them up in a overlay.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is described&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/api/bindings/spi/nordic,nrf-spi.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/api/bindings/spi/nordic,nrf-spi.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;An array of chip select GPIOs to use. Each element
in the array specifies a GPIO. The index in the array
corresponds to the child node that the CS gpio controls.

Example:

  spi@... {
          cs-gpios = &amp;lt;&amp;amp;gpio0 23 GPIO_ACTIVE_LOW&amp;gt;,
                        &amp;lt;&amp;amp;gpio1 10 GPIO_ACTIVE_LOW&amp;gt;,
                        ...;

          spi-device@0 {
                  reg = &amp;lt;0&amp;gt;;
                  ...
          };
          spi-device@1 {
                  reg = &amp;lt;1&amp;gt;;
                  ...
          };
          ...
  };

The child node &amp;quot;spi-device@0&amp;quot; specifies a SPI device with
chip select controller gpio0, pin 23, and devicetree
GPIO flags GPIO_ACTIVE_LOW. Similarly, &amp;quot;spi-device@1&amp;quot; has CS GPIO
controller gpio1, pin 10, and flags GPIO_ACTIVE_LOW. Additional
devices can be configured in the same way.

If unsure about the flags cell, GPIO_ACTIVE_LOW is generally a safe
choice for a typical &amp;quot;CSn&amp;quot; pin. GPIO_ACTIVE_HIGH may be used if
intervening hardware inverts the signal to the peripheral device or
the line itself is active high.

If this property is not defined, no chip select GPIOs are set.
SPI controllers with dedicated CS pins do not need to define
the cs-gpios property.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can see below how it was done on the thingy91 with two different accelerometers on the same SPI bus&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi3 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 8 GPIO_ACTIVE_LOW&amp;gt;, &amp;lt;&amp;amp;gpio0 7 GPIO_ACTIVE_LOW&amp;gt;;

	pinctrl-0 = &amp;lt;&amp;amp;spi3_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi3_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	adxl362: adxl362@0 {
		compatible = &amp;quot;adi,adxl362&amp;quot;;
		spi-max-frequency = &amp;lt;8000000&amp;gt;;
		reg = &amp;lt;0&amp;gt;;
		int1-gpios = &amp;lt;&amp;amp;gpio0 9 0&amp;gt;;
	};

	adxl372: adxl372@1 {
		compatible = &amp;quot;adi,adxl372&amp;quot;;
		spi-max-frequency = &amp;lt;8000000&amp;gt;;
		reg = &amp;lt;1&amp;gt;;
		int1-gpios = &amp;lt;&amp;amp;gpio0 6 0&amp;gt;;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>