<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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 remove start bit from an I2C transfer in zephyr</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/88473/how-to-remove-start-bit-from-an-i2c-transfer-in-zephyr</link><description>Hello, 
 
 I am developing a driver for the vl53l5cx TOF sensor from ST, however their sequential write format looks as such: 
 
 This is problematic for me since I can get the address, and register index sent correctly with the stop bit at the end, however</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Fri, 03 Jun 2022 08:40:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/88473/how-to-remove-start-bit-from-an-i2c-transfer-in-zephyr" /><item><title>RE: How to remove start bit from an I2C transfer in zephyr</title><link>https://test-devzone.nordicsemi.com/thread/370823?ContentTypeID=1</link><pubDate>Fri, 03 Jun 2022 08:40:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c660ae2-8961-4798-8efc-16277a669740</guid><dc:creator>user111520</dc:creator><description>&lt;p&gt;Yes I saw this in the data sheet, but I was wondering if the sequential write figure could be a misprint&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to remove start bit from an I2C transfer in zephyr</title><link>https://test-devzone.nordicsemi.com/thread/370741?ContentTypeID=1</link><pubDate>Thu, 02 Jun 2022 15:08:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:298cae4b-f751-4227-b982-37fec5063f44</guid><dc:creator>user113427</dc:creator><description>&lt;p&gt;That&amp;#39;s what I thought as well, it&amp;#39;s strange that they wrote it in such a way. Perhaps it is an issue with the datasheet, I will contact ST about this. I will keep playing around with different variations to see what works. But yes it mentions here:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://test-devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1654182455109v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;That P is for stop and S is for start.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Jacob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to remove start bit from an I2C transfer in zephyr</title><link>https://test-devzone.nordicsemi.com/thread/370664?ContentTypeID=1</link><pubDate>Thu, 02 Jun 2022 11:18:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8084164-19bf-4b29-905f-0067bd5189e8</guid><dc:creator>user111520</dc:creator><description>&lt;p&gt;Hm I see, that&amp;#39;s strange.&lt;/p&gt;
&lt;p&gt;It seems&amp;nbsp;odd to me that you&amp;#39;re supposed to send data after a stop sequence with no start sequence.&lt;/p&gt;
&lt;p&gt;Looking at your sensor&amp;#39;s data sheet, it says &amp;quot;All serial interface communications with the Time-of-Flight sensor must begin with a start condition.&amp;quot; and &amp;quot;A message contains a series of bytes preceded by a start condition and followed by either a stop or repeated start (another start condition but without a preceding stop condition) followed by another message.&amp;quot;&lt;/p&gt;
&lt;p&gt;Are you sure the P after the index bytes is really supposed to be a stop sequence, and not perhaps a &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Ftwi.html&amp;amp;cp=4_0_0_5_28_5&amp;amp;anchor=concept_cdz_xtv_sr"&gt;repeated start sequence&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;-Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to remove start bit from an I2C transfer in zephyr</title><link>https://test-devzone.nordicsemi.com/thread/370508?ContentTypeID=1</link><pubDate>Wed, 01 Jun 2022 15:30:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58a2b212-2d6b-4b74-b010-2cc9d1b0663a</guid><dc:creator>user113427</dc:creator><description>&lt;p&gt;Aha, turns out that is exactly what I have done. But it still gives me a start bit before the data bytes. I removed the I2C_MSG_WRITE from the second message but still no luck.&lt;/p&gt;
&lt;p&gt;See here:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://test-devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0552.Image-from-iOS-_2800_1_2900_.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Using:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static inline int i2c_write_test(const struct device *dev, uint8_t *write_reg, uint8_t *write_buf, size_t num_write, uint16_t addr)
{
	struct i2c_msg msg[2];

	msg[0].buf = write_reg;
	msg[0].len = 2U;
	msg[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;

	msg[1].buf = write_buf;
	msg[1].len = num_write;
	msg[1].flags = I2C_MSG_STOP;

	return i2c_transfer(dev, msg, 2, addr);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to remove start bit from an I2C transfer in zephyr</title><link>https://test-devzone.nordicsemi.com/thread/370446?ContentTypeID=1</link><pubDate>Wed, 01 Jun 2022 12:35:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6d3d21a-514c-4bbd-a8a6-bf4710e70d28</guid><dc:creator>user111520</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;What function(s) are you currently using when you try to write? i2c_write? i2c_burst_write? i2c_transfer?&lt;/p&gt;
&lt;p&gt;It seems to me that what you want is similar to &lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/drivers/i2c.h#:~:text=static%20inline%20int-,i2c_burst_write,-(const%20struct"&gt;i2c_burst_write&lt;/a&gt;, but with a stop condition after sending the buffer address, you might have to set up your write manually using i2c_transfer since you want this irregular formatting.&lt;/p&gt;
&lt;p&gt;Perhaps something like this:&lt;/p&gt;
&lt;pre&gt;struct i2c_msg msg[2];&lt;br /&gt;&lt;br /&gt;msg[0].buf = &amp;amp;start_addr;&lt;br /&gt;msg[0].len = 1U;&lt;br /&gt;msg[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;&lt;br /&gt;&lt;br /&gt;msg[1].buf = (uint8_t *)buf;&lt;br /&gt;msg[1].len = num_bytes;&lt;br /&gt;msg[1].flags = I2C_MSG_WRITE | I2C_MSG_STOP;&lt;br /&gt;&lt;br /&gt;i2c_transfer(dev, msg, 2, dev_addr);&lt;/pre&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>