<?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>Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110875/devicetree-spi-node-interrupt-asserts</link><description>Hi, 
 I want to connect X-NUCLEO-NFC08A1 with ST25R3916B to nRF5340 board by adding a SPI node to device-tree source. After compiling and flashing the board, triggering interrupt causes an assertion. 
 For tests, I trigger interrupt manually with a wire</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 22 May 2024 11:42:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110875/devicetree-spi-node-interrupt-asserts" /><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/485385?ContentTypeID=1</link><pubDate>Wed, 22 May 2024 11:42:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e02d4e4-aafc-46f6-b520-357424fd03c7</guid><dc:creator>kahlenberg</dc:creator><description>&lt;p&gt;I think I found the problem. It is not about SPI or device-tree. In ISR I am calling a function whihch calls&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;k_ticks_to_ms_ceil64&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;sys_clock_tick_get&lt;/span&gt;&lt;span&gt;()) to get the system tick count. Normaly, sys_clock_tick_get() works in main function, but when I move it to anohter file it produces error. Anyway, it is another topic and I am opening another topic now.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/485204?ContentTypeID=1</link><pubDate>Tue, 21 May 2024 17:01:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6e361de-6715-4690-9744-c6c69716d6da</guid><dc:creator>kahlenberg</dc:creator><description>&lt;p&gt;Error is coming from kernel. I am posting the code.&lt;br /&gt;&lt;br /&gt;Device-Tree overlay:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;
&amp;amp;pinctrl {
	spi1_default_alt: spi1_default_alt {
		group1 {
			psels = &amp;lt;NRF_PSEL(SPIM_SCK, 1, 15)&amp;gt;,
					&amp;lt;NRF_PSEL(SPIM_MOSI, 1, 13)&amp;gt;,
					&amp;lt;NRF_PSEL(SPIM_MISO, 1, 14)&amp;gt;;
		};
	};

	spi1_sleep_alt: spi1_sleep_alt {
		group1 {
			psels = &amp;lt;NRF_PSEL(SPIM_SCK, 1, 15)&amp;gt;,
					&amp;lt;NRF_PSEL(SPIM_MOSI, 1, 13)&amp;gt;,
					&amp;lt;NRF_PSEL(SPIM_MISO, 1, 14)&amp;gt;;
			low-power-enable;
		};
	};
};

spi_master: &amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;gpio1 12 GPIO_ACTIVE_LOW&amp;gt;;
	pinctrl-0 = &amp;lt;&amp;amp;spi1_default_alt&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep_alt&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	st25r3916b:st25r3916b@0 {
		reg = &amp;lt;0&amp;gt;;
	};
};

/{
	leds {
		led_tv: led_tv {
			gpios = &amp;lt;&amp;amp;gpio0 25 GPIO_ACTIVE_HIGH&amp;gt;;
			label = &amp;quot;Green LED TV&amp;quot;;
		};
		
		led_ap2p: led_ap2p {
			gpios = &amp;lt;&amp;amp;gpio0 26 GPIO_ACTIVE_HIGH&amp;gt;;
			label = &amp;quot;Green LED AP2P&amp;quot;;
		};
			irq_gpio: irq_gpio {
			gpios = &amp;lt;&amp;amp;gpio0 4 GPIO_ACTIVE_HIGH&amp;gt;;
			label = &amp;quot;Interrupt line&amp;quot;;
		}; 
	};
		
	aliases {
		led-tv = &amp;amp;led_tv;
		led-ap2p = &amp;amp;led_ap2p;
		irq-gpio = &amp;amp;irq_gpio;
	};
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_LOG=y
CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_DEBUG_THREAD_INFO=y
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=8192&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SPI_MASTER_NODE DT_NODELABEL(spi_master)

const struct device *spi_dev = DEVICE_DT_GET(SPI_MASTER_NODE);

#define INT_NODE DT_ALIAS(irq_gpio)
static const struct gpio_dt_spec irq_gpio = GPIO_DT_SPEC_GET_OR(INT_NODE, gpios, {0});

struct spi_config spi_cfg = {
    .operation = (SPI_OP_MODE_MASTER | SPI_WORD_SET(8) |
                  SPI_TRANSFER_MSB | SPI_LINES_SINGLE |
                  SPI_MODE_CPHA),
     .frequency = 400000,
    .slave = DT_REG_ADDR(DT_NODELABEL(st25r3916b)),
    .cs = {
        .gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(st25r3916b)),
        .delay = T_NCS_SCLK
    }
};
static struct gpio_callback gpio_cb;

st25r3916Isr() {
 /* SPI communication for reading INT registers*/    
}


static void irq_pin_cb(const struct device *gpiob, struct gpio_callback *cb, uint32_t pins) {
    //LOG_DBG(&amp;quot;Received interrupt %s pin %d\n&amp;quot;, gpiob-&amp;gt;name, pins);
    st25r3916Isr();
}

int main() {

if(!device_is_ready(irq_gpio.port) || !device_is_ready(spi_dev) || !device_is_ready(spi_cfg.cs.gpio.port)) {
    //error log
}
int err = gpio_pin_configure_dt(&amp;amp;irq_gpio, GPIO_INPUT);
if (err) { /*error log */}
gpio_init_callback(&amp;amp;gpio_cb, irq_pin_cb, BIT(irq_gpio.pin));
err = gpio_add_callback(irq_gpio.port, &amp;amp;gpio_cb);
if (err) { /*error log */}
gpio_pin_interrupt_configure_dt(&amp;amp;irq_gpio, GPIO_INT_EDGE_TO_ACTIVE);
while(true) {}
return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/485062?ContentTypeID=1</link><pubDate>Tue, 21 May 2024 11:21:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c453a1a-efb3-4a65-b7c8-f4acd93916cb</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;You need to debug where the error is coming from.&lt;/p&gt;
&lt;p&gt;Looks like you have changed the overlay, and the error might be actually coming from the sensor (driver).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/484778?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 19:35:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcd1da8c-0bf7-414f-b563-1347d3398566</guid><dc:creator>kahlenberg</dc:creator><description>&lt;p&gt;Actually, the problem exists still. Compiling device-tree and flashing work, but as you can see in the logs, I am still getting spinlock error &amp;quot;&amp;nbsp;during interrupt handling&amp;quot;.&lt;br /&gt;What can the problem be? I don&amp;#39;t use any spinlock or mutex for interrupt service routine? Should I use a spinlock or mutex for interrupt? If yes, how?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/484711?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 13:33:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4c5de24-3386-4ed1-a707-b8c2fde43272</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;It should be okay as long as it is getting compiled correctly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/483102?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 14:59:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bce3a537-9089-46d3-8f32-08100921c2fe</guid><dc:creator>kahlenberg</dc:creator><description>&lt;p&gt;Ok, in device-tree, can a node&amp;nbsp; be added to spi instance only with reg = &amp;lt;0&amp;gt; (chisp-select) property? I tried and built it. But before building it, my intellisense in VSCode&amp;nbsp;shows always an error, that a node must have &amp;quot;compatible&amp;quot; property. But anyway, it compiles well :)&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/too1/ncs-spi-master-slave-example/blob/master/boards/nrf5340dk_nrf5340_cpuapp.overlay#L46"&gt;github.com/.../nrf5340dk_nrf5340_cpuapp.overlay&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/483030?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 12:08:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d83ccaf7-b403-4925-830f-dc440c7b1188</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;You can get the spi instance from the DT using zephyr&amp;nbsp;Device api, e.g using DEVICE_DT_GET.&lt;/p&gt;
&lt;p&gt;Maybe, this example could be relevant to your use-case:&amp;nbsp;&lt;a href="https://github.com/too1/ncs-spi-master-slave-example/tree/master"&gt;SPI Master Slave Sample NCS&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please look into the overlays and the source code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/482383?ContentTypeID=1</link><pubDate>Tue, 07 May 2024 20:06:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c983c4a4-2337-423a-865a-27a362e9696b</guid><dc:creator>kahlenberg</dc:creator><description>&lt;p&gt;You are right, there was no driver for&amp;nbsp;&lt;span&gt;st25r3916b, I copied the driver for&amp;nbsp;st25r3911b and modified (renamed files, modified Kconfig...) it for&amp;nbsp;st25r3916b. But the problem is that I should not use the zephyr driver in device tree, because driver is already implemented in STM library. I want to use STM library.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So, I need to use SPI without any device driver.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now my question is changed to: How can I use SPI without device-tree node?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree SPI node interrupt asserts</title><link>https://devzone.nordicsemi.com/thread/482171?ContentTypeID=1</link><pubDate>Tue, 07 May 2024 07:04:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6572339-6ce7-4a8b-9244-7c9189c95383</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Is the ST driver available in zephyr?&lt;/p&gt;
&lt;p&gt;I can not see &amp;quot;st,st25r3916b&amp;quot; in the zephyr dt-binding list.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>