<?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>Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103810/does-zephyr-i2c-apis-support-16bit-register-address-on-ncs-v2-4-2</link><description>From https://docs.zephyrproject.org/latest/hardware/peripherals/i2c.html link, I didn&amp;#39;t find any APIs for 16bit register address. Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Sep 2023 06:07:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103810/does-zephyr-i2c-apis-support-16bit-register-address-on-ncs-v2-4-2" /><item><title>RE: Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</title><link>https://devzone.nordicsemi.com/thread/446760?ContentTypeID=1</link><pubDate>Wed, 20 Sep 2023 06:07:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f6042de-f8c7-49e8-bc62-abcf333d78d8</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply! I can read/write registers now.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int _lp5861ReadReg(uint16_t regAddr, uint8_t *regVal) {
    printk(&amp;quot;tca6424aReadReg(regAddr=0x%x)\n&amp;quot;, regAddr);
    const uint16_t devAddr   = LP5861_CHIP_ADDRESS | _lp5861GetRegAddrHigh(regAddr);
    const uint8_t  startAddr = _lp5861GetRegAddrLow(regAddr);
    printk(&amp;quot;devAddr=0x%x, startAddr=0x%x\n&amp;quot;, devAddr, startAddr);
    uint8_t rbuf[2];
    const int ret = i2c_burst_read(_gI2cDev, devAddr, startAddr, rbuf, sizeof(rbuf));
    if (ret &amp;lt; 0) {
        printk(&amp;quot;i2c_burst_read(0x%x) failed, ret=%d\n&amp;quot;, regAddr, ret);
        return ERROR_I2C_READ_FAIL;
    }

    printk(&amp;quot;rbuf[0]=0x%x, rbuf[1]=0x%x\n&amp;quot;, rbuf[0], rbuf[1]);
    *regVal = rbuf[0];
    return 0;
}

static int _lp5861WriteReg(uint16_t regAddr, uint8_t regVal) {
    printk(&amp;quot;tca6424aWriteReg(regAddr=0x%x, regVal0x%x)\n&amp;quot;, regAddr, regVal);
    const uint16_t devAddr   = LP5861_CHIP_ADDRESS | _lp5861GetRegAddrHigh(regAddr);
    const uint8_t  startAddr = _lp5861GetRegAddrLow(regAddr);
    printk(&amp;quot;_lp5861GetRegAddrHigh(regAddr)=0x%x\n&amp;quot;, _lp5861GetRegAddrHigh(regAddr));
    printk(&amp;quot;devAddr=0x%x, startAddr=0x%x\n&amp;quot;, devAddr, startAddr);
    const uint8_t wbuf[2] = { regVal,  0x00};
    const int ret =  i2c_burst_write(_gI2cDev, devAddr, startAddr, wbuf, sizeof(wbuf));
    if (ret &amp;lt; 0) {
        printk(&amp;quot;i2c_burst_write(0x%x) failed, ret=%d\n&amp;quot;, regAddr, ret);
        return ERROR_I2C_WRITE_FAIL;
    }

    return 0;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</title><link>https://devzone.nordicsemi.com/thread/446239?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 11:12:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51abf35f-98d1-4ca2-ac7d-f9f16767b971</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The I2C standard does not support 16-bit device addresses, and the datasheet you referred to shows a 7-bit address (+1 write bit). The second address byte is for the internal register address in the I2C slave and, from the I2C protocol&amp;#39;s perspective, it&amp;#39;s treated just like any other data byte.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</title><link>https://devzone.nordicsemi.com/thread/446176?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 05:53:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea62db47-6866-447b-ac4f-080ebd242d12</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/I2c_5F00_data_5F00_format.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</title><link>https://devzone.nordicsemi.com/thread/446174?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 05:45:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de1162af-bd15-45b4-b35c-73b191d1b2ed</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/3022.registers.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</title><link>https://devzone.nordicsemi.com/thread/446173?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 05:41:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a4acf98-7d93-4485-a518-eaed2584d4ef</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/I2c_5F00_timing.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does Zephyr I2C APIs support 16bit register address on ncs v2.4.2?</title><link>https://devzone.nordicsemi.com/thread/446172?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 05:32:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:469f825f-9002-4b98-b8f1-5f66d7c4e028</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/3731.LP5861.pdf"&gt;devzone.nordicsemi.com/.../3731.LP5861.pdf&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>