<?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>connect sdk twi startup problems</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71061/connect-sdk-twi-startup-problems</link><description>I have connected a BM680 sensor on a BL654 (NRF52840) via I2C. I have connected the power to the BME680 on a switchable power rail. I need to power this rail with a GPIO pin on the NRF52. Also the I2C pins are connected to a GPIO pin of the NRF52840 to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Feb 2021 10:14:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71061/connect-sdk-twi-startup-problems" /><item><title>RE: connect sdk twi startup problems</title><link>https://devzone.nordicsemi.com/thread/292169?ContentTypeID=1</link><pubDate>Mon, 01 Feb 2021 10:14:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34edf4af-76c0-420a-9c15-9d7151e71af6</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;One way of going about this is to use the SYS_INIT macro, to get code executed before main. Here are some examples how to go about it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For a certain board:&amp;nbsp;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/3f1d1f5773ddafa6cdf99499aaecb94f545059a4/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c#L89"&gt;zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/21046b8cdb4eac989c6b17bb21ffc8196be3d5e4/boards/arm/nrf52840dongle_nrf52840/board.c#L45"&gt;zephyr/boards/arm/nrf52840dongle_nrf52840/board.c&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Example of SYS_INIT in the hci_driver for the SoftDevice controller:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/b6c3d61e7274e1a653e449d8693ad387d5e42a09/subsys/bluetooth/controller/hci_driver.c#L592"&gt;nrf/subsys/bluetooth/controller/hci_driver.c&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;Everything in SYS_INIT gets placed in linker sections that the startup code runs at certain points, PRE_KERNEL, POST_KERNEL, etc.: &lt;a title="https://github.com/nrfconnect/sdk-zephyr/blob/master/include/init.h#l135" href="https://github.com/nrfconnect/sdk-zephyr/blob/master/include/init.h#L135" rel="noopener noreferrer" target="_blank"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/master/include/init.h#L135&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;Note that if you use SYS_INIT with PRE_KERNEL priority you will not have access to zephyr&amp;#39;s GPIO driver; you may want to use different priority (to make sure GPIO driver is up that would be APPLICATION I think) or use nrfx directly (easiest option).&lt;/div&gt;
&lt;div&gt;&lt;hr /&gt;&lt;/div&gt;
&lt;div&gt;In upstream Zephyr, you could use the regulator devices to do this:&lt;/div&gt;
&lt;div&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/bbc563f5ac1cfc507c469ae944b14e75871a79fd/boards/arm/thingy52_nrf52832/thingy52_nrf52832.dts#L69"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/bbc563f5ac1cfc507c469ae944b14e75871a79fd/boards/arm/thingy52_nrf52832/thingy52_nrf52832.dts#L69&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;Also check out:&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/latest/reference/peripherals/regulators.html"&gt;docs.zephyrproject.org/.../regulators.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Simon&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: connect sdk twi startup problems</title><link>https://devzone.nordicsemi.com/thread/292062?ContentTypeID=1</link><pubDate>Sat, 30 Jan 2021 16:23:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf725aa0-498a-499c-90a7-edc8eaf64dcd</guid><dc:creator>bossssie</dc:creator><description>&lt;p&gt;Just an update, for now I seem to have &amp;quot;solved&amp;quot; this issue by adding a bit of code to the BME680 to write the GPIO pins high. But this is clearly not the way to go. Does anyone have an idea to make a driver or a piece of code that will run before the sensor startup?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int pwr_ctrl_init()
{
	const struct device *gpio;
	const char *port = DT_LABEL(DT_NODELABEL(gpio0));
	gpio = device_get_binding(port);
	if (!gpio) {
		printk(&amp;quot;Could not bind device \&amp;quot;%s\&amp;quot;\n&amp;quot;, port);
		return -ENODEV;
	}

	gpio_pin_configure(gpio, VDD_PWR_CTRL_GPIO_PIN, GPIO_OUTPUT_HIGH);
	gpio_pin_configure(gpio, VDD_PWR_PULLUP_GPIO_PIN, GPIO_OUTPUT_HIGH);

	k_sleep(K_MSEC(10)); /* Wait for the rail to come up and stabilize */

	return 0;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>