<?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 reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20645/how-can-i-reuse-this-library-into-twi-library-in-nrf52</link><description>Hello all, 
 I am trying to make use of some Adafruit libraries for some sensors in my nrF52pca10040, the libraries are these two Adafruit_BME280.cpp , Adafruit_BME280.h and Adafruit_TSL2591.h , Adafruit_TSL2591.cpp 
 They both make use of either SPI</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 02 Jun 2017 10:41:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20645/how-can-i-reuse-this-library-into-twi-library-in-nrf52" /><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80506?ContentTypeID=1</link><pubDate>Fri, 02 Jun 2017 10:41:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d096e7fc-a397-47b7-b1ff-9454bab62246</guid><dc:creator>BosseSand</dc:creator><description>&lt;p&gt;Did you succeed ?
If you did, can you please share your code?&lt;/p&gt;
&lt;p&gt;Best Regards
Bo-Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80485?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 15:07:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e56a2ac-aa37-45bb-9cf6-c6256f67e1b4</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;I understand Jorgen, thanks again! I will try it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80493?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 14:52:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bff18b05-4e73-49a0-938a-6143c5c70a15</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Should work, but you need to use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;value = valueAux[0] &amp;lt;&amp;lt; 16;
value = valueAux[1] &amp;lt;&amp;lt; 8;
value = value | valueAux[2];
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Otherwise, value will be overwritten multiple times.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80502?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 13:24:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:899e62ea-7cff-47b0-97e2-b1025f37d672</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The TWI driver will read one byte at a time and place it into the buffer. If you do not provide an array to the buffer parameter, the driver will try to access an index outside of the provided buffer on the second read. If you want to use single variable you need to call the rx function two times with a size of 1 byte to receive 16 bits.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80501?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 13:19:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60079bf9-d06c-45de-954b-b22988dc22a7</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Thanks Jorgen, I had the transmit as well but  I didn&amp;#39;t show before. Thanks for the tip I will incorporate as well, could you tell me why is better using an array than two variables, performance?
In case of reading 24 bits, I can reuse the above function like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t Adafruit_BME280::read24(byte reg)
{
  uint32_t value = 0;
  uint8_t valueAux[3] ;
  ret_code_t err_code;

  if (_cs == -1) {

    byte xfer[1] = {reg};
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, _i2caddr, (const byte*)xfer, sizeof(xfer), false);
    APP_ERROR_CHECK(err_code);
    while (m_txfer_done == false);

    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, _i2caddr, valueAux, 3*sizeof(byte));//2*sizeof(byte) = 2bytes = 16bits
    APP_ERROR_CHECK(err_code);
    while (m_txfer_done == false);
      value = valueAux[0] &amp;lt;&amp;lt; 8;
      value = valueAux[1] &amp;lt;&amp;lt; 8;
      value = value | valueAux[0] | valueAux[1];
      m_rxfer_done = false;

//    Wire.beginTransmission((uint8_t)_i2caddr);
//    Wire.write((uint8_t)reg);
//    Wire.endTransmission();
//    Wire.requestFrom((uint8_t)_i2caddr, (byte)3);
//    
//    value = Wire.read();
//    value &amp;lt;&amp;lt;= 8;
//    value |= Wire.read();
//    value &amp;lt;&amp;lt;= 8;
//    value |= Wire.read();
      return value;
    }
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80503?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 11:51:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5100824f-1c51-4b04-911d-0851292d16ac</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You will need a transmitt here as well. I would suggest something like this (not tested):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t Adafruit_BME280::read16(byte reg)
{
  uint16_t value = 0;
  uint8_t valueAux[2];
  ret_code_t err_code;

  if (_cs == -1) {

    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, _i2caddr, (const byte*)reg, sizeof(reg), false);
    APP_ERROR_CHECK(err_code);
    while (m_txfer_done == false);

    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, _i2caddr, valueAux, 2*sizeof(byte));
    APP_ERROR_CHECK(err_code);
    while (m_rxfer_done == false);
    if (m_rxfer_done) {
      value = valueAux[0] &amp;lt;&amp;lt; 8;
	  value = value | valueAux[1];
      m_rxfer_done = false;
    }
  }
  return value;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You don&amp;#39;t really need the &lt;code&gt;if (m_rxfer_done)&lt;/code&gt; part though, as the above while loop will ensure the RX operation in finished.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80486?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 11:30:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b5f9fb8-5c00-48fb-ba08-8099fffca767</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;sorry, you&amp;#39;re right I had changed that in the code but not in the post, now it goes through the condition &lt;code&gt;if (read8(BME280_REGISTER_CHIPID) != 0x60)&lt;/code&gt; but it stalls in the read16 function, I need to figure out how to translate these lines&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;//    Wire.requestFrom((uint8_t)_i2caddr, (byte)2);
//    value = (Wire.read() &amp;lt;&amp;lt; 8) | Wire.read();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;for reading 16bits, so far I have done this but still not working as expected&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = nrf_drv_twi_rx(&amp;amp;m_twi, _i2caddr, &amp;amp;valueAux, 2*sizeof(byte));//2*sizeof(byte) = 2bytes = 16bits
APP_ERROR_CHECK(err_code);
while (m_rxfer_done == false);
if (m_rxfer_done) {
  value = valueAux &amp;lt;&amp;lt; 8;
  value = value | valueAux;
  m_rxfer_done = false;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80487?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 10:11:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fffddcc-8093-4dfc-bbdf-2ac177d4c13f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;What is the purpose of the 3rd last line of your above code? You are also waiting for &lt;code&gt;m_txfer_done&lt;/code&gt;, while in the if-check you have &lt;code&gt;m_rxfer_done&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80488?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 10:02:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9696fb89-0ea6-4826-9087-3321e017cf77</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Hi Jorgen that was ineeded something that was happening , now I read as &lt;code&gt;BME280_REGISTER_CHIPID&lt;/code&gt; 0x60 but the assignation between my return value (aux) and the read one(valueAux) seems to fail not sure why ( I have upadted a pic of the debugger in such as case), notice that &lt;code&gt;value&lt;/code&gt; before the return has only debugging purpose to check the value itself.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t Adafruit_BME280::read8(byte reg)
{
  uint8_t value = 0;
  uint8_t valueAux = 0;
  ret_code_t err_code;

  if (_cs == -1) {
  
    byte xfer[1] = {reg};
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, _i2caddr, (const byte*)xfer, sizeof(xfer), false);
    APP_ERROR_CHECK(err_code);
    while (m_txfer_done == false);

    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, _i2caddr, &amp;amp;valueAux, sizeof(byte));
    APP_ERROR_CHECK(err_code);
    while (m_rxfer_done == false);
    if (m_rxfer_done) {
      value = valueAux;
      m_rxfer_done = false;
    }
  }
  value;
  return value;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80505?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 09:44:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14996467-2aef-4e60-857a-42d5fd6eeeb7</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Hi Jorgen, thanks for replying,I see now that there is a write indeed I will incorporate the same into my code&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80504?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 08:47:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a334f9fd-66c2-4f3d-b80b-fe1c02bc64a0</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;From the Adafruit driver you posted, it looks like the read8 function first write the register, sends a stop flag and then request and reads 1 byte from the device. Note that the way devices use the TWI protocol varies from device to device. You need to look in the datasheet of the device to know exactly how to read and write to the device.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80496?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 19:36:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fb2729d-04b8-4698-94dd-1393d600211b</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Jorgen, is this also needed for the receiver part? I mean sending register address and value together.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80495?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 19:28:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ea5d4a4-7fc2-42c1-a058-6d825b195dc1</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;I will try it tomorrow morning  and come back with the outcome, thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80494?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 19:07:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:435cf0e3-0915-4bc5-b35e-24c72f2cec65</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You should send both register address and value in the same TX transfer (in your write8() function), something like the code shown below, else the driver will end the transmission and the sensor will most likely return to an idle state.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void Adafruit_BME280::write8(byte reg, byte value)
{
  if (_cs == -1) {
	byte xfer[2] = {reg, value};
    ret_code_t err_code;
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, _i2caddr, (const byte*)xfer, sizeof(xfer), false);
    APP_ERROR_CHECK(err_code);
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you need to do two separate transfers, you need to make sure that the first transfer is finished before starting the second transfer, using the flags set in the handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80500?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 18:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b9f6536-0f75-494f-b1f3-6dc7a930ea35</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;There were no error codes, as far as I remember, before executing the call to &lt;code&gt;nrf_drv_twi_tx&lt;/code&gt; the return value of &lt;code&gt;err_code&lt;/code&gt; was something like 0x040300 or so ( I don&amp;#39;t have the board with me now). But just after the execution I could see in the debugger that it was 0x00000&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80499?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 18:39:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:166445e5-db5d-4749-b0e6-0f6585902199</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Thanks Jorgen, then the code above should work to detect either a TX or RX transfers has been carried out ( the handler function in the main post that I have just edited)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80498?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 18:35:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31b0271a-68df-44a0-b48b-129e18dc7f1f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Sorry, I misunderstood you. I thought you wanted separate events for TX and RX. You can check the transfer type of the event, but both TX and RX events are handled in the code you posted above. If the transfer type was TX, m_xfer_done is set, while if the transfer type was RX, the received data is handled using the function &lt;code&gt;data_handler()&lt;/code&gt; in addition to m_xfer_done to true.&lt;/p&gt;
&lt;p&gt;Have you checked the error codes returned by the functions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80497?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 18:25:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e012ae24-48f9-406e-a96b-c2994a383366</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Jorgen, then the handler that in twi_sensor_example make use of such a value, does it have a different meaning/purpose?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
    switch (p_event-&amp;gt;type)
    {
        case NRF_DRV_TWI_EVT_DONE:
            if (p_event-&amp;gt;xfer_desc.type == NRF_DRV_TWI_XFER_RX)
            {
                data_handler(m_sample);
            }
            m_xfer_done = true;
            break;
        default:
            break;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I have created the function that you mentioned, but when reading from the sensor I get nothing, actually the check &lt;code&gt;if (read8(BME280_REGISTER_CHIPID) != 0x60)&lt;/code&gt; seems to fail... I have updated the main post with my changes&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80492?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 15:04:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24b1bbdd-27f6-4983-925d-20674149e159</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;There is &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/group__nrf__drv__twi.html#ga8dd2153e3c8fc75f486dc1fa33219c93"&gt;no such events&lt;/a&gt; using the TWI driver. If you want a higher level abstraction and control of your TWI transactions, you can check out the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/lib_app_twi.html?cp=4_0_1_3_35"&gt;TWI transaction manage&lt;/a&gt;r library.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80491?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 13:16:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2b6cb41-4cfa-4e56-8b87-67141de88d77</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;ok, thanks again, but that handler function only works for the twi_init() not for the receiver or transmitter, is there a way to reuse it for those functions? I would be interested on checking the events like &lt;code&gt;NRF_DRV_TWI_XFER_TX&lt;/code&gt; or &lt;code&gt;NRF_DRV_TWI_XFER_RX&lt;/code&gt; so that I can know that the transfer is done.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80490?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 12:52:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6882e31-3a4f-4cf6-8922-a73ead5f3030</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You can use the handler function of the example, but you should modify it to do what you need for your sensor. The TWI sensor example runs in a loop as it reads the sensor once every 500ms (note the delay inside the loop). It is normal to have a loop in the application to put the chip in sleep mode when no processing needs to be done.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80489?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 12:43:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:760ba273-e269-490f-a223-ba532f9724c2</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Thanks Jorgen, I was wondering as well, in order to make the read and write function, can I use the handler function of &lt;code&gt;twi_sensorex_ample&lt;/code&gt; to read and write? I get a bit confused by the fact hat in the  main of such as example there&amp;#39;s an inifite loop for reading, should my function include that so?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I reuse this library into TWI library in nrF52?</title><link>https://devzone.nordicsemi.com/thread/80484?ContentTypeID=1</link><pubDate>Tue, 21 Mar 2017 11:50:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ab22e1a-6f42-4fd9-ae4f-f07c2e8e691e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You will have to rewrite all the init, write and read functions to use the corresponding TWI driver functions. For instance, in place of &lt;code&gt;Wire.begin()&lt;/code&gt;, you should use an init function similar to &lt;code&gt;twi_init()&lt;/code&gt; in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/twi_sensor_example.html?cp=4_0_0_4_4_36"&gt;twi_sensor example&lt;/a&gt;, and use &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__drv__twi.html?cp=4_0_0_6_8_24_3_25#ga5367610e58bd96b27fbe02b3d52b9d80"&gt;&lt;code&gt;nrf_drv_twi_rx()&lt;/code&gt;&lt;/a&gt; and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__drv__twi.html?cp=4_0_0_6_8_24_3_28#ga2c5ea8408254dfa9cbff55dbee171a95"&gt;&lt;code&gt;nrf_drv_twi_tx()&lt;/code&gt;&lt;/a&gt; in place of the read and write functions.&lt;/p&gt;
&lt;p&gt;For details about configuring and setting GPIOs, you should have a look at the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__gpio.html?cp=4_0_0_6_8_6"&gt;GPIO abstraction documentation&lt;/a&gt;. Pins are configured as input or output using &lt;code&gt;nrf_gpio_cfg_input()&lt;/code&gt; and &lt;code&gt;nrf_gpio_cfg_output()&lt;/code&gt; functions. There are functions available for &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__gpio.html#gadfd30c1e5321180f1e333cf5642058e8"&gt;setting&lt;/a&gt;, &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__gpio.html#ga5c671adfb6b44f32c9d99d3156aff2b1"&gt;clearing&lt;/a&gt;, &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__gpio.html#gac7f7bf539f5bb053b4a313ec51d8157e"&gt;toggling&lt;/a&gt; and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__gpio.html#ga2ad9c02e0534e3ab6679f45c6f42dcdd"&gt;writing&lt;/a&gt; to GPIOs.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>