<?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>How can i add a iic device to nrf_desktop?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67359/how-can-i-add-a-iic-device-to-nrf_desktop</link><description>Now i want to add a iic device(pct1336) to nrf_desktop keyboard project, how can i do it?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 20 Oct 2020 13:12:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67359/how-can-i-add-a-iic-device-to-nrf_desktop" /><item><title>RE: How can i add a iic device to nrf_desktop?</title><link>https://devzone.nordicsemi.com/thread/275940?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 13:12:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00143657-26ac-4c05-b5ae-1c9393579850</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;You enable the TWIMx peripheral, but remember that this is a shared peripheral on the nRF devices, as shown here in the instantiation list in the PS for nRF52833:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/memory.html?cp=4_1_0_3_1_3#topic"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52833/memory.html?cp=4_1_0_3_1_3#topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The peripherals with the same address space are shared, meaning that you cannot enable both SPIM0 and TWIM0 simultaneously.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you look at the CMakeLists.txt file for nrf_desktop, there&amp;#39;s a specific setting here for the overlay:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if (EXISTS &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/dts.overlay&amp;quot;)
  set(DTC_OVERLAY_FILE &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/dts.overlay&amp;quot;)
endif()
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the case that I configure for board nrf52kbd_nrf52832, it will therefore load the file ../configuration/nrf52kbd_nrf52832/dts.overlay.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s what it should contain if you want to enable i2c0 (change the sda-pin and scl-pin to your wanted GPIOs):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c0 {
        compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
        status = &amp;quot;okay&amp;quot;;
        clock-frequency = &amp;lt;I2C_BITRATE_STANDARD&amp;gt;;
        sda-pin = &amp;lt;MY_SDA_PIN&amp;gt;;
        scl-pin = &amp;lt;MY_SCL_PIN&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In addition, you need to add these configurations to the prj.conf. nrf_desktop has several configuration files, as described here:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.2/nrf/applications/nrf_desktop/README.html#nrf-desktop-build-types"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.2/nrf/applications/nrf_desktop/README.html#nrf-desktop-build-types&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For this case, the kconfig prj files are dependent on the build configuration, as shown in the .conf files here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/master/applications/nrf_desktop/configuration/nrf52kbd_nrf52832"&gt;https://github.com/nrfconnect/sdk-nrf/tree/master/applications/nrf_desktop/configuration/nrf52kbd_nrf52832&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can select the build configuration as per the documentation here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.2/nrf/applications/nrf_desktop/README.html#selecting-a-build-type"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.2/nrf/applications/nrf_desktop/README.html#selecting-a-build-type&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;app_ZDebug.conf and app_ZRelease.conf is likely the targets you&amp;#39;re interested in, where you can enable I2C:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_I2C=y
CONFIG_I2C_0=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Are you planning on using the i2c driver directly, or interfacing a already present zephyr sensor driver?&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>