<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Receiving arbitrary number of bytes as I2C slave in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Receiving-arbitrary-number-of-bytes-as-I2C-slave/m-p/615615#M6410</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Kevin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do not know the byte number the I2C slave device should be received, could you use only interrupt mode? once the I2C s slave receives a byte, an interrupt is triggered, you can read the char in ISR of slave I2C, this is the triditional method.&lt;/P&gt;&lt;P&gt;You can refer to the example&amp;nbsp; in SDK2.0:&lt;/P&gt;&lt;P&gt;C:\Freescale\SDK2.0_FRDM_K64F\boards\frdmk64f\driver_examples\i2c\interrupt&lt;/P&gt;&lt;P&gt;Hope it can help&amp;nbsp; you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Xiangjun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Dec 2016 06:08:56 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2016-12-16T06:08:56Z</dc:date>
    <item>
      <title>Receiving arbitrary number of bytes as I2C slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Receiving-arbitrary-number-of-bytes-as-I2C-slave/m-p/615614#M6409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm implementing a "passthrough" functionality with the K22 acting as a slave.&amp;nbsp; Essentially I take some USB data in, strip the protocol extras, and pass the payload over to the I2C line.&amp;nbsp; In return, the Master will send data back to the K22 slave, and that will be packetized, and send back over USB.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, since I don't necessarily&amp;nbsp;know how many bytes the master is going to send back to me, what is the best method to receive an arbitrary number of bytes from a master?&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do know the maximum amount of bytes the master can send to me.&amp;nbsp; So would the best method be something like this:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;uint32_t currTimeMs&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
uint32_t remainingRx&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
uint32_t numUsbTx&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
uint32_t timeout &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OSA_TimeGetMsec&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; I2C_RX_TX_TIMEOUT&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

i2cStatus &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;I2C_DRV_SlaveReceiveData&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;I2C_RTOS_SLAVE_INSTANCE&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; usbTxBuff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; MAX_PAYLOAD_SIZE&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;do&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp; i2cStatus &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;I2C_DRV_SlaveGetTransmitStatus&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;I2C_RTOS_SLAVE_INSTANCE&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;remainingRx&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp; currTimeMs &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OSA_TimeGetMsec&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i2cStatus &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; kStatus_I2C_Success &lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt; timeout &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; currTimeMs&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

numUsbTx &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; MAX_PAYLOAD_SIZE &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; remainingRx&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Usb_Send&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;usbTxBuff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; numUsbTx&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="line-numbers-rows"&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, wait for a timeout and and send only the number of bytes that were received.&amp;nbsp; Are there any other ways?&amp;nbsp; Would this be easier with the ReceiveDataBlocking call?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2016 16:51:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Receiving-arbitrary-number-of-bytes-as-I2C-slave/m-p/615614#M6409</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2016-12-15T16:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Receiving arbitrary number of bytes as I2C slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Receiving-arbitrary-number-of-bytes-as-I2C-slave/m-p/615615#M6410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Kevin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do not know the byte number the I2C slave device should be received, could you use only interrupt mode? once the I2C s slave receives a byte, an interrupt is triggered, you can read the char in ISR of slave I2C, this is the triditional method.&lt;/P&gt;&lt;P&gt;You can refer to the example&amp;nbsp; in SDK2.0:&lt;/P&gt;&lt;P&gt;C:\Freescale\SDK2.0_FRDM_K64F\boards\frdmk64f\driver_examples\i2c\interrupt&lt;/P&gt;&lt;P&gt;Hope it can help&amp;nbsp; you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Xiangjun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Dec 2016 06:08:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Receiving-arbitrary-number-of-bytes-as-I2C-slave/m-p/615615#M6410</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2016-12-16T06:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Receiving arbitrary number of bytes as I2C slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Receiving-arbitrary-number-of-bytes-as-I2C-slave/m-p/615616#M6411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ended up changing the protocol so that my device will know how many bytes it should receive.&amp;nbsp; The suggestion you made, and the change I made (providing the device with the number of bytes to receive), I'm assuming are the only possibilities available.&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Dec 2016 16:17:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Receiving-arbitrary-number-of-bytes-as-I2C-slave/m-p/615616#M6411</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2016-12-22T16:17:14Z</dc:date>
    </item>
  </channel>
</rss>

