<?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 to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66230/how-to-add-new-i2c-based-sensor-device-to-ncs-v1-3-0-zephyr-drivers-sensor</link><description>How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor. 
 Can you suggest any tutorial to do so as i want to use sensor subsystem which in turn uses i2c driver. 
 Thanks 
 Chandra</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Nov 2020 15:00:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66230/how-to-add-new-i2c-based-sensor-device-to-ncs-v1-3-0-zephyr-drivers-sensor" /><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/278486?ContentTypeID=1</link><pubDate>Wed, 04 Nov 2020 15:00:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbb8193f-cbf4-4eea-923d-646c82f2552c</guid><dc:creator>ChandraSR K</dc:creator><description>&lt;p&gt;OK thanks for all the clarifications. Thank you very much.&lt;/p&gt;
&lt;p&gt;I could succeed with &lt;span&gt;DT_ANY_INST_ON_BUS_STATUS_OKAY &lt;/span&gt;, could communicate with sensor.&lt;/p&gt;
&lt;p&gt;Need to improve sensor driver.&lt;/p&gt;
&lt;p&gt;for now I am going to close this ticket.&lt;/p&gt;
&lt;p&gt;Thanks&lt;br /&gt;Chandra&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/278391?ContentTypeID=1</link><pubDate>Wed, 04 Nov 2020 09:48:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f100eb64-89c9-429f-9c0c-c15b198631a9</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure where you get those DTS defines from, and why you think those should be generated. Could you give me some pointers?&lt;/p&gt;
&lt;p&gt;I think you should be fine using&amp;nbsp;&lt;span&gt;DT_ANY_INST_ON_BUS_STATUS_OKAY and&amp;nbsp;DT_ANY_INST_ON_BUS_STATUS_OKAY, that is what all the other sensor drives in NCS v1.3.0 are using:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs2/drivers/sensor/iis3dhhc/iis3dhhc.c#L235"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs2/drivers/sensor/iis3dhhc/iis3dhhc.c#L235&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs1/drivers/sensor/lps22hh/lps22hh.c#L210-L225"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs1/drivers/sensor/lps22hh/lps22hh.c#L210-L225&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs1/drivers/sensor/stts751/stts751.c#L207"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs1/drivers/sensor/stts751/stts751.c#L207&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs1/drivers/sensor/lsm6dso/lsm6dso.c#L755"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs1/drivers/sensor/lsm6dso/lsm6dso.c#L755&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/277863?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 15:18:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25ed2256-d20d-4f93-a60d-5b2f14e85bfa</guid><dc:creator>ChandraSR K</dc:creator><description>&lt;p&gt;This part i got it. it works for me early this week.&lt;/p&gt;
&lt;p&gt;but i have following code in driver.&lt;/p&gt;
&lt;p&gt;#if defined(DT_TDK_ICM20948_BUS_SPI)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; icm20948_spi_init(dev);&lt;br /&gt;#elif defined(DT_TDK_ICM20948_BUS_I2C)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; icm20948_i2c_init(dev);&lt;br /&gt;#else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #error &amp;quot;BUS MACRO NOT DEFINED IN DTS&amp;quot;&lt;br /&gt;#endif&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;DT_TDK_ICM20948_BUS_SPI, DT_TDK_ICM20948_BUS_I2C: what are these?&lt;/p&gt;
&lt;p&gt;I just repalced these with DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) and DT_ANY_INST_ON_BUS_STATUS_OKAY(I2C).&lt;/p&gt;
&lt;p&gt;How to enable these macros : DT_TDK_ICM20948_BUS_SPI ,DT_TDK_ICM20948_BUS_I2C? we can just ignore.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/277854?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 14:48:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a832681-752f-487b-b896-841ce1899841</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Try to do this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// You need this in order for DT_ANY_INST_ON_BUS_STATUS_OKAY to work
#define DT_DRV_COMPAT tdk_icm20948 

// code
// code
// code


#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
    //Do stuff
#elif DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
    //Do stuff
#else
#error &amp;quot;BUS MACRO NOT DEFINED IN DTS&amp;quot;
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Take a look at the&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.3.0-rc1-ncs3/include/devicetree.h#L1607-L1636"&gt;zephyr/include/devicetree.h&lt;/a&gt; for more information about the macro&amp;nbsp;&lt;span style="background-color:rgba(255, 255, 255, 1);"&gt;DT_ANY_INST_ON_BUS_STATUS_OKAY.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:rgba(255, 255, 255, 1);"&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:rgba(255, 255, 255, 1);"&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/277015?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 05:43:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51436e16-bd9f-4377-ac10-d9eb472c30a5</guid><dc:creator>ChandraSR K</dc:creator><description>&lt;p&gt;&lt;em&gt;Hi&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;zephyr\dts\bindings\sensor\&amp;lt;compatible string&amp;gt;.yaml&lt;/em&gt;&amp;nbsp; -----&amp;gt; Contains tdk,icm20948-i2c.yaml , tdk,icm20948-spi.yaml&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;tdk,icm20948-spi.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
description: |
  ICM-20948 Nine Axis I2C/SPI MEMS
  This is a representation of the ICM-20948 Three Axis High-g I2C/SPI accelerometer

compatible: &amp;quot;tdk,icm20948&amp;quot;

include: spi-device.yaml

#inherits:
#  !include i2c-device.yaml

properties:
    int1-gpios:
      type: phandle-array
      required: false
      description: |
        The INT1 signal defaults to active high as produced by the
        sensor.  The property value should ensure the flags properly
        describe the signal that is presented to the driver.
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;tdk,icm20948-i2c.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
description: |
  ICM-20948 Nine Axis I2C/SPI MEMS
  This is a representation of the ICM-20948 Three Axis High-g I2C/SPI accelerometer

compatible: &amp;quot;tdk,icm20948&amp;quot;

include: i2c-device.yaml

#inherits:
#  !include i2c-device.yaml

properties:
    int1-gpios:
      type: phandle-array
      required: false
      description: |
        The INT1 signal defaults to active high as produced by the
        sensor.  The property value should ensure the flags properly
        describe the signal that is presented to the driver.
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;zephyr\samples\sensor\&amp;lt;your sensor&amp;gt;\boards\&amp;lt;board name&amp;gt;.overlay&lt;/em&gt; --&amp;gt; I donot have this file. but I have overlay file in my application:nrf9160dk_nrf9160ns.overlay&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* 	uart0 reserved for debug prints
	uart1 reserved for modem traces
*/

/*		status = &amp;quot;okay&amp;quot;; disable usart2 to use I2C_2 for ICM20948 */

&amp;amp;uart2 {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;i2c2 {
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	sda-pin = &amp;lt;11&amp;gt;;
	scl-pin = &amp;lt;12&amp;gt;;
	clock-frequency = &amp;lt;I2C_BITRATE_STANDARD&amp;gt;; 

        /* The I2C address could be one of two, here 0x68 is assumed */
	icm20948@68 {
		compatible = &amp;quot;tdk,icm20948&amp;quot;;
		reg = &amp;lt;0x68&amp;gt;;
		label = &amp;quot;ICM20948&amp;quot;;
	};
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/276920?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2020 14:37:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d894717-922d-4321-a063-1c97e82f1312</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you upload these files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;zephyr\dts\bindings\sensor\&amp;lt;compatible string&amp;gt;.yaml&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;zephyr\samples\sensor\&amp;lt;your sensor&amp;gt;\boards\&amp;lt;board name&amp;gt;.overlay&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;If you have placed the sample or overlay file somewhere else, please provide that instead.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&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: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/276471?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2020 14:10:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:521c0923-1820-4fe8-9b06-9a1ed94fcedf</guid><dc:creator>ChandraSR K</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thanks for the info and this is verymuch useful.&lt;/p&gt;
&lt;p&gt;I have followed all the steps.&lt;/p&gt;
&lt;p&gt;in&amp;nbsp; the sensor&amp;nbsp; c file, i have some like below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#if defined(DT_VENDOR_CHIPNAME_BUS_SPI)
    chip_spi_init(dev);
#elif defined(DT_VENDOR_CHIPNAME_BUS_I2C)
    chip_i2c_init(dev);
#else
    #error &amp;quot;BUS MACRO NOT DEFINED IN DTS&amp;quot;
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;These macros are not getting defined. This is some things to do with zephyr system, but any pointers that would greatly help to proceed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/274127?ContentTypeID=1</link><pubDate>Sat, 10 Oct 2020 05:18:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70ed77aa-39a8-4c62-b8e8-6ae8200b238a</guid><dc:creator>ChandraSR K</dc:creator><description>&lt;p&gt;Thanks for the info. will check and revert.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor</title><link>https://devzone.nordicsemi.com/thread/271109?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 13:13:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5fd2f46-e78f-44d8-a0a6-c3591990a7de</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I tried to look around but could not find any such guides. However I have provided an answer for this earlier, take a look at it &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/63460/nrf5340---dac-driver-in-zephyr"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Down below&amp;nbsp;I&amp;#39;ve provided a short guide how to add a custom sensor to Zephyr&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start with a senor most similar to your sensor and use it as a reference&lt;/li&gt;
&lt;li&gt;Create a binding in&amp;nbsp;&lt;em&gt;zephyr\dts\bindings\sensor\&amp;lt;compatible string&amp;gt;.yaml&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;E.g. copy&amp;nbsp;&lt;em&gt;zephyr\dts\bindings\sensor\adi,adxl362.yaml&lt;/em&gt;, change the name and modify it according to your sensor&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Create the driver in&lt;em&gt;&lt;span&gt; zephyr\drivers\sensor&lt;/span&gt;&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;E.g. copy &lt;em&gt;zephyr\drivers\sensor\adxl362,&lt;/em&gt;&amp;nbsp;change the name and modify it according to your sensor&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span&gt;In&amp;nbsp;&lt;/span&gt;&lt;em&gt;\zephyr\drivers\sensor\CMakeLists.txt &lt;/em&gt;add the following line
&lt;ul&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;add_subdirectory_ifdef(CONFIG_&amp;lt;name of sensor&amp;gt; &amp;lt;sensor directory&amp;gt;)&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In&amp;nbsp;&lt;em&gt;\zephyr\drivers\sensor\Kconfig &lt;/em&gt;add the following line
&lt;ul&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;source &amp;quot;drivers/sensor/&amp;lt;sensor directory&amp;gt;/Kconfig&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a sample in&amp;nbsp;&lt;span&gt;&lt;em&gt;zephyr\samples\sensor&lt;/em&gt;, to test if it works as expected&lt;/span&gt;&lt;/li&gt;
&lt;/ul&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>