<?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>Zephyr CustomBoard with NRF52840 and MCP23S17</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66454/zephyr-customboard-with-nrf52840-and-mcp23s17</link><description>Hello folks I have been struggling for some time with the driver for the MCP23S17 in Zephyr. I have already tried this code: https://devzone.nordicsemi.com/f/nordic-q-a/64024/sample-mcp23s17-driver 
 But for me its not working! 
 I receive the following</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Oct 2020 14:51:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66454/zephyr-customboard-with-nrf52840-and-mcp23s17" /><item><title>RE: Zephyr CustomBoard with NRF52840 and MCP23S17</title><link>https://devzone.nordicsemi.com/thread/273291?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 14:51:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55738a27-cecb-4381-9021-8f589c76ef08</guid><dc:creator>trug</dc:creator><description>&lt;p&gt;Ok I found my problems:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1.&amp;nbsp; Custom board error&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Between the Zephyr version 2.1.0 and version 2.4.0 are some differences.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.1 In XXX_defconfig&lt;/strong&gt; the following configs aren&amp;#39;t supported anymore:&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ff0000;"&gt;CONFIG_ARM=y&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color:#ff0000;"&gt;CONFIG_SOC_FAMILY_NRF=y&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.2 In XXX.dts&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ff0000;color:#000000;"&gt;compatible = &amp;quot;nordic,nrf52840-qiaa&amp;quot;;&lt;/span&gt; is not working!&lt;/p&gt;
&lt;p&gt;I use &lt;span style="background-color:#00ff00;"&gt;compatible = &amp;quot;nordic,nrf52840-dk-nrf52840&amp;quot;&lt;/span&gt;; instead.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. MCP23S17 pins&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The gpio expander mcp23s17 uses low active reset (nReset) and low active chip select (nCS).&lt;/p&gt;
&lt;p&gt;In my&lt;strong&gt; XYZ.overlay&lt;/strong&gt; file I have to set the CS Pin to 1&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ff0000;"&gt;Wrong:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cs-gpios = &amp;lt;&amp;amp;gpio1 1 &lt;span style="background-color:#ff0000;"&gt;0&lt;/span&gt;&amp;gt;;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#00ff00;"&gt;Correct:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cs-gpios = &amp;lt;&amp;amp;gpio1 1 &lt;span style="background-color:#00ff00;"&gt;1&lt;/span&gt;&amp;gt;;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. My solution&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;3.1 Here my .overlay file&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
/* GPIO Expander */
&amp;amp;spi2 {
    label=&amp;quot;SPI2&amp;quot;;
    status = &amp;quot;okay&amp;quot;;
    sck-pin = &amp;lt;36&amp;gt;;
    mosi-pin = &amp;lt;37&amp;gt;;
    miso-pin = &amp;lt;38&amp;gt;;
    cs-gpios = &amp;lt;&amp;amp;gpio1 1 1&amp;gt;;

    spi2gpio: gpio@0 {	
    	label=&amp;quot;mcp23s17&amp;quot;;
	compatible = &amp;quot;microchip,mcp23s17&amp;quot;;
        gpio-controller;
        #gpio-cells = &amp;lt;2&amp;gt;;
        spi-max-frequency = &amp;lt;800000&amp;gt;;
        reg = &amp;lt;0&amp;gt;;
	ngpios = &amp;lt;16&amp;gt;;
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3.2 Here my main.c for testing&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;devicetree.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;


#include &amp;quot;CustomBoard.h&amp;quot;


#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;logging/log.h&amp;gt;
LOG_MODULE_REGISTER(blinky_logging, LOG_LEVEL_DBG);

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS   1000

/* The devicetree node identifier for the &amp;quot;led0&amp;quot; alias. */
#define LED0_NODE DT_ALIAS(led0)

#if DT_NODE_HAS_STATUS(LED0_NODE, okay)
#define LED0		DT_GPIO_LABEL(LED0_NODE, gpios)
#define PIN_LED0	DT_GPIO_PIN(LED0_NODE, gpios)
#define FLAGS_LED0	DT_GPIO_FLAGS(LED0_NODE, gpios)
#else
/* A build error here means your board isn&amp;#39;t set up to blink an LED. */
#error &amp;quot;Unsupported board: led0 devicetree alias is not defined&amp;quot;
#define LED0		&amp;quot;&amp;quot;
#define PIN_LED0	0
#define FLAGS_LED0	0
#endif



/* The devicetree node identifier for the &amp;quot;led1&amp;quot; alias. */
#define LED1_NODE DT_ALIAS(led1)

#if DT_NODE_HAS_STATUS(LED1_NODE, okay)
#define LED1		DT_GPIO_LABEL(LED1_NODE, gpios)
#define PIN_LED1	DT_GPIO_PIN(LED1_NODE, gpios)
#define FLAGS_LED1	DT_GPIO_FLAGS(LED1_NODE, gpios)
#else
/* A build error here means your board isn&amp;#39;t set up to blink an LED. */
#error &amp;quot;Unsupported board: led0 devicetree alias is not defined&amp;quot;
#define LED0		&amp;quot;&amp;quot;
#define PIN_LED1	1
#define FLAGS_LED1	1
#endif



#define	MCP23S17_DEV_NAME	DT_LABEL(DT_NODELABEL(spi2gpio))


void main(void)
{

	k_msleep(1000);
	LOG_INF(&amp;quot;&amp;gt;&amp;gt;&amp;gt; [main]: Test Application &amp;lt;&amp;lt;&amp;lt;&amp;quot;);
	
	const struct device *dev_led_0,*dev_led_1;
	const struct device *mcp23s17_dev,*gpio_port0_dev;
	bool led_is_on = true;
	int ret,i;
	
	//-------------------------------------------------------------------------------
	// MCP23S17
	//-------------------------------------------------------------------------------
	LOG_INF(&amp;quot;[main]: MCP23S17_Init&amp;quot;);
	mcp23s17_dev = device_get_binding(MCP23S17_DEV_NAME);
	
	if (!mcp23s17_dev) {
		LOG_INF(&amp;quot;Cannot find mcp23s17!\n&amp;quot;);
		return;
	}

	for(i=0; i&amp;lt;16; i++){
		ret = gpio_pin_configure(mcp23s17_dev, i, GPIO_OUTPUT_ACTIVE);
		if (ret &amp;lt; 0) {
			return;
		}
	}


	//-------------------------------------------------------------------------------
	// GPIO Port_0
	//-------------------------------------------------------------------------------
	LOG_INF(&amp;quot;[main]: GPIO_Port0_Init&amp;quot;);
	gpio_port0_dev = device_get_binding(CONFIG_GPIO_PORT_0);
	if (gpio_port0_dev == NULL) {
		return;
	}
	ret = gpio_pin_configure(gpio_port0_dev, GPIO_EXP_RST, GPIO_OUTPUT_ACTIVE);
	if (ret &amp;lt; 0) {
		return;
	}
	gpio_pin_set(gpio_port0_dev, GPIO_EXP_RST, (int)true);
	
		
	//-------------------------------------------------------------------------------
	// LED
	//-------------------------------------------------------------------------------
	LOG_INF(&amp;quot;[main]: LED_Init&amp;quot;);
	dev_led_0 = device_get_binding(LED0);
	dev_led_1 = device_get_binding(LED1);
	if (dev_led_0 == NULL &amp;amp;&amp;amp; dev_led_1 == NULL) {
		LOG_INF(&amp;quot;LEDs not found!\n&amp;quot;);
		return;
	}

	ret = gpio_pin_configure(dev_led_0, PIN_LED0, GPIO_OUTPUT_ACTIVE | FLAGS_LED0);
	if (ret &amp;lt; 0) {
		return;
	}

	ret = gpio_pin_configure(dev_led_1, PIN_LED1, GPIO_OUTPUT_ACTIVE | FLAGS_LED1);
	if (ret &amp;lt; 0) {
		return;
	}

	//-------------------------------------------------------------------------------
	// While
	//-------------------------------------------------------------------------------
	LOG_INF(&amp;quot;[main]: while&amp;quot;);
	while (1) {
		gpio_pin_set(dev_led_0, PIN_LED0, (int)led_is_on);
		
		for(i=0; i&amp;lt;16; i++){
			//LOG_INF(&amp;quot;&amp;gt;&amp;gt;&amp;gt; [main:while]: gpio[%i]=[%i]  &amp;lt;&amp;lt;&amp;lt;&amp;quot;,i,(int)led_is_on);
			gpio_pin_set(mcp23s17_dev, i, (int)led_is_on);
		}
		LOG_INF(&amp;quot;[main:while]: gpio[XYZ]=[%i]&amp;quot;,i,(int)led_is_on);
		
		led_is_on = !led_is_on;
		k_msleep(SLEEP_TIME_MS);
		
		gpio_pin_set(dev_led_1, PIN_LED1, (int)led_is_on);
		k_msleep(SLEEP_TIME_MS);

	}
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr CustomBoard with NRF52840 and MCP23S17</title><link>https://devzone.nordicsemi.com/thread/272346?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 13:51:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f87f7d62-9ad7-443f-8f79-6955523dc890</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you upload your board folder in zipped format, then I can test it myself? Have you seen &lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-3-ncs-v1-3-0#h113sk0f71cly1ckwgkkxioblcbcsge6"&gt;this guide&lt;/a&gt;? Try following that when creating your board folder.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr CustomBoard with NRF52840 and MCP23S17</title><link>https://devzone.nordicsemi.com/thread/272215?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 09:18:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc2ce3d7-f1ad-4c58-85e6-7d6fbe76bcb5</guid><dc:creator>trug</dc:creator><description>&lt;p&gt;Since the Zephyr version of Nordic is lagging behind, I use the latest version of Zephyr (2.4). I use some drivers on my customboard that are not yet included in the NCS. &lt;/p&gt;
&lt;p&gt;Do you think this could also lead to further problems?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr CustomBoard with NRF52840 and MCP23S17</title><link>https://devzone.nordicsemi.com/thread/272213?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 09:14:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e066753f-e6c3-46af-96be-860db7cf3e84</guid><dc:creator>trug</dc:creator><description>&lt;p&gt;Thanks Simon&lt;/p&gt;
&lt;p&gt;I tried to build the firmware as nrf52840dk_nrf52840 and it worked fine.&lt;br /&gt;But it does not work with my customboard.&lt;br /&gt;&lt;br /&gt;Since my customboard is not in the Zephyr directory, it could be a CMake problem?!&lt;br /&gt;&lt;br /&gt;I will check it and as soon as I find a solution, I will post it here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr CustomBoard with NRF52840 and MCP23S17</title><link>https://devzone.nordicsemi.com/thread/272098?ContentTypeID=1</link><pubDate>Tue, 29 Sep 2020 14:25:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa63eced-b179-4c11-a6ea-beda435ce70e</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;What tag are you using? I tested your sample with NCS v1.3.0 and it built without any errors. The only change I made was to swap &lt;em&gt;#ngpios&lt;/em&gt; with &lt;em&gt;ngpios&lt;/em&gt; in the overlay file.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>