<?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>nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69098/nrf9160-spi-and-spi_cs_control</link><description>Hi, 
 I got SPI working when writing to the CS pins directly. I thought however it might shorten the SPI acces when using spi_cs_control. When executing the code I will however get an error on the first spi_transceive: 
 
 Here is my code: 
 #include</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Dec 2020 11:26:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69098/nrf9160-spi-and-spi_cs_control" /><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/285593?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2020 11:26:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bcb0f7c5-9ab4-4883-bc6e-5626c6678965</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello Dirk,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I&amp;#39;m glad that you have a work around for the moment. It seems that a complete driver must be in place in order for you to implement my previous suggestion.&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/284577?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 14:37:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3b52a8c-9091-471d-9603-656955d5c1a4</guid><dc:creator>dhandzic</dc:creator><description>&lt;p&gt;Hi &amp;Ouml;yvind,&lt;/p&gt;
&lt;p&gt;I have added the cs-gpios to my devicetree .dts file as you can see but I dont have written a complete driver for the MC33879 and I am not sure how to add a child node without being able to refer to a driver module.like in the Thingy example &amp;quot;compatible=adi,adx1362&amp;quot;.&lt;/p&gt;
&lt;p&gt;Never mind it is working with calling gpio_pin_set as I do now too.&lt;/p&gt;
&lt;p&gt;Have a nice Friday!&lt;br /&gt;Dirk&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/284540?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 13:20:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5219b342-e7d0-4002-bc27-7f4d7dc038ec</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Hello,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:inherit;"&gt;I&amp;#39;ve discussed the topic with our R&amp;amp;D team.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;You need to add the SPI devices as a childe node to your SPI instance in the .dts file. What SPI device are you using? Have a look at the &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/adf0ce9020b2b66f7582fbe617969886690c61d9/boards%2Farm%2Fthingy91_nrf9160%2Fthingy91_nrf9160_common.dts#L128-L151"&gt;common dts file for e.g. Thingy:91&lt;/a&gt;&amp;nbsp;on how to add a child node. Based on this information, you can add the SPI CS pin.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;Then using &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/devicetree/api.html?highlight=dt_spi_dev_cs_gpios_flags#c.DT_SPI_DEV_CS_GPIOS_FLAGS"&gt;DT_SPI_DEV_CS_GPIOS_FLAGS()&lt;/a&gt;&amp;nbsp;you use the child node from above. For example from the Thingy:91 you should be able to use DT_SPI_DEV_CS_GPIOS_FLAGS(DT_LABEL(adxl362)).&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;I have unfortunately not been able to test this, as my setup is working with me on this Friday.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:inherit;"&gt;-Øyvind&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/284261?ContentTypeID=1</link><pubDate>Thu, 10 Dec 2020 09:12:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c327f831-6630-4b39-9e9e-8b8d055c99dd</guid><dc:creator>dhandzic</dc:creator><description>&lt;p&gt;Hi &amp;Ouml;yvind,&lt;/p&gt;
&lt;p&gt;great you could reproduce the issue. I have tried to follow all the documentation regarding the device tree for custom boards.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Dirk&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/284250?ContentTypeID=1</link><pubDate>Thu, 10 Dec 2020 08:44:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad5a147e-f7e1-4143-8974-37fc7d2412c4</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hi Dirk,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I can confirm the issue using the project provided in ticket&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/support-private/support/260408"&gt;#260408&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The issue seems to be related to device tree configurations, please &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/dts/howtos.html#devicetree-howtos"&gt;see DeviceTree HOWTOs for more information&lt;/a&gt;.&amp;nbsp;Unfortunately, I have not work with Devicetree configurations and will need to confer with a colleague in R&amp;amp;D.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;More information on this topic can also be found in &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/include/devicetree.h"&gt;&amp;quot;Devicetree main header&amp;quot;&lt;/a&gt;&amp;nbsp;(&lt;em&gt;zephyr\include\devicetree.h&lt;/em&gt;) and&amp;nbsp;the &amp;quot;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/include/devicetree/spi.h"&gt;SPI&amp;nbsp;Devicetree&amp;nbsp;macro&amp;nbsp;public&amp;nbsp;API&amp;nbsp;header&amp;nbsp;file&lt;/a&gt;&amp;quot; (&lt;em&gt;zephyr\include\devicetree\spi.h&lt;/em&gt;).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Øyvind&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/283593?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2020 14:38:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6287f7b8-d808-4dac-9e5b-486a3d699661</guid><dc:creator>dhandzic</dc:creator><description>&lt;p&gt;Hi &amp;Ouml;yvind,&lt;/p&gt;
&lt;p&gt;I am configuring spi in the board files. Carl Rchard Steen Fosse has received both device tree and project files in a private ticket. &lt;span class="attribute-value"&gt;Case ID: 260408 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the&amp;nbsp; code I have removed the cs part and toggle CS directly in my code which works for the MC33879 I need to control. If you just change it in qlocx_digio.c you will get the error back. Carl Richard Steen Fosse has one of our boards, in case you need a board.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Dirk&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/283578?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2020 14:14:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69319088-34b7-441f-be07-2d54095005ae</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Are you configuring anything in you application? Or is it just in your board files?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not able to reproduce the error with the board files alone.&lt;/p&gt;
&lt;p&gt;-Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/283312?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 13:11:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d3770ec-65fc-4d59-98f9-5a1eed63def6</guid><dc:creator>dhandzic</dc:creator><description>&lt;p&gt;Hi &amp;Ouml;yvind,&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1607087393096v1.png" /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Q3IoT_5F00_201204.zip"&gt;devzone.nordicsemi.com/.../Q3IoT_5F00_201204.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Even after adding the cs definitions to our board_common.dts I get similar errors. I attach our board definition files.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Dirk&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI and spi_cs_control</title><link>https://devzone.nordicsemi.com/thread/283297?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 11:39:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c86905d-b1a6-4a8a-b5b9-e9a9081426b7</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hi Dirk,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;From the top of output log you have provided, it states:&lt;br /&gt;&lt;strong&gt;devicetree and spi_context CS levels are not equal&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Have you configured SPI in your devicetree?&lt;/p&gt;
&lt;p&gt;We have a simple (a little outdated) &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/spi/src/main.c"&gt;sample on SPI here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The gpio_dt_flags are GPIO devicetree flags:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief SPI Chip Select control structure
 *
 * This can be used to control a CS line via a GPIO line, instead of
 * using the controller inner CS logic.
 *
 * @param gpio_dev is a valid pointer to an actual GPIO device. A NULL pointer
 *        can be provided to full inhibit CS control if necessary.
 * @param gpio_pin is a number representing the gpio PIN that will be used
 *    to act as a CS line
 * @param delay is a delay in microseconds to wait before starting the
 *    transmission and before releasing the CS line
 * @param gpio_dt_flags is the devicetree flags corresponding to how the CS
 *    line should be driven. GPIO_ACTIVE_LOW/GPIO_ACTIVE_HIGH should be
 *    equivalent to SPI_CS_ACTIVE_HIGH/SPI_CS_ACTIVE_LOW options in struct
 *    spi_config.
 */
struct spi_cs_control {
	const struct device	*gpio_dev;
	uint32_t		delay;
	gpio_pin_t		gpio_pin;
	gpio_dt_flags_t		gpio_dt_flags;
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There are several examples of the usage in NCS, i.e.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.0/zephyr/guides/dts/index.html#devicetree-guide"&gt;More information on Device Tree can be found here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;E.g. from &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/6660081992fcdf3cffd99537dbe700e83684d0dc/boards/arm/thingy91_nrf9160/thingy91_nrf9160_common.dts#L128-L151"&gt;nrf\boards\arm\thingy91_nrf9160\thingy91_nrf9160_common.dts&lt;/a&gt;&amp;nbsp;you can see how the Thingy:91 has configured SPI3 CS pin.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>