<?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 GPIO initialization before HW drivers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78658/zephyr-gpio-initialization-before-hw-drivers</link><description>Hi 
 
 I am working on a nRF52840 using Zephyr as OS. 
 I have setup some control GPIO pins in the device tree (se below). This works fine from the application. I can access the definitions and set GPIOs in the states I want. 
 
 My issue is that I need</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 Aug 2021 06:49:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78658/zephyr-gpio-initialization-before-hw-drivers" /><item><title>RE: Zephyr GPIO initialization before HW drivers</title><link>https://devzone.nordicsemi.com/thread/325397?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 06:49:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:106878be-8acf-4aab-b036-48de0d95b805</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Glad to hear that, Morten!&lt;/p&gt;
&lt;p&gt;Let me know if you run into any issues.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr GPIO initialization before HW drivers</title><link>https://devzone.nordicsemi.com/thread/325394?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 06:29:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ce7e803-bf3c-4de5-b13c-63a9ff80cc8e</guid><dc:creator>Morten Sabinsky</dc:creator><description>&lt;p&gt;Thanks this is what i needed&lt;/p&gt;
&lt;p&gt;Morten&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr GPIO initialization before HW drivers</title><link>https://devzone.nordicsemi.com/thread/325335?ContentTypeID=1</link><pubDate>Tue, 17 Aug 2021 13:47:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84d8928a-cb77-45f1-b48a-4abd8f67a290</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;GPIOs that needs to be set prior to initialization&amp;nbsp;usually gets placed in a PRE_KERNEL system init, like done here for the nrf9160dk_nrf52840 board.c file:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/boards/arm/nrf9160dk_nrf52840/board.c#L217-L240"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/master/boards/arm/nrf9160dk_nrf52840/board.c#L217-L240&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem with setting a gpio before the &amp;quot;zephyr gpio&amp;quot; driver is initialized is that you cannot use the zephyr driver instance to set it, so you need to use the nrf_gpio.h (or other bare metal implementations) to configure/set. It isn&amp;#39;t clear if this is a restriction in your case, or if you want to set these before communicating with an external IC or similar.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you require setting this with a higher priority than another module (ie.&amp;nbsp;in a situation where zephyr&amp;#39;s gpio is already inited), you can look at the sys_init() macro for the module in question, and setup one that happens before it:&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/latest/reference/drivers/index.html#c.SYS_INIT"&gt;https://docs.zephyrproject.org/latest/reference/drivers/index.html#c.SYS_INIT&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>