<?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>Operating NRF52 peripherals (TWI) in c++ mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53820/operating-nrf52-peripherals-twi-in-c-mode</link><description>I&amp;#39;m trying to operate the &amp;#39;&amp;#39;twi_sensor&amp;quot; example of SDK 15.30 , using Kielu5 , but the compiler is issuing errors for the syntax of the TWI libraries. From my side I only changed the main source file from c to c++. 
 
 The following image shows how I changed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 01 Nov 2019 11:40:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53820/operating-nrf52-peripherals-twi-in-c-mode" /><item><title>RE: Operating NRF52 peripherals (TWI) in c++ mode</title><link>https://devzone.nordicsemi.com/thread/217933?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2019 11:40:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d92db002-bcd9-4ece-b10c-1988823c4dd1</guid><dc:creator>Patrick</dc:creator><description>&lt;p&gt;The problem you&amp;#39;re likely running into is that C++ requires initializers to be in order whereas C will let you initialize members in any order. What this means for you, if you want to use C++ with the SDK, is that instead of using the helper macros to initialize a peripheral instance you need to explicitly initialize the structs in the correct order.&lt;/p&gt;
&lt;p&gt;For example, in the twi_sensor example, lets look at line 80. Rather than use the macro to initialize the TWI instance you would need to do something like the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Using nrf_drv
static const nrf_drv_twi_t m_twi = { .inst_idx = 0, .twi = NRF_DRV_TWI_INSTANCE_0, .use_easy_dma = true };

// If using nrfx
static const nrfx_twim_t m_twi = { .p_twim = NRF_TWIM0, .drv_inst_idx = NRFX_TWIM0_INST_IDX };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Looking further into the example you may also need to replace the function calls to nrf_drv_twi_tx and nrf_drv_twi_rx with the version that takes a transfer descriptor that you have created, initializing the members in order.&lt;/p&gt;
&lt;p&gt;I am using the nrfx drivers in my projects so hopefully I have gotten the nrf_drv initialization correct. If nothing else you should have an idea of what you need to do now to clear your compiler errors.&lt;/p&gt;
&lt;p&gt;*The above applies to initializing other peripherals as well. It is somewhat an inconvenience but worth the effort in my opinion.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Operating NRF52 peripherals (TWI) in c++ mode</title><link>https://devzone.nordicsemi.com/thread/217892?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2019 08:25:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e10d4057-4c66-44dc-958e-d52e7110faec</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.mbed.com/en/platform/mbed-os/"&gt;mbed OS&lt;/a&gt; is also C++ based, and has support for the nRF52DK (not sure about the nRF52840 though..)&lt;/p&gt;
&lt;p&gt;The problem of any third party software platform is that we don&amp;#39;t support it, and you need to rely on whatever support/forums are available for that specific platform if you have software issues.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Operating NRF52 peripherals (TWI) in c++ mode</title><link>https://devzone.nordicsemi.com/thread/217832?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 18:14:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdb282e0-aec1-4afd-b96c-6fe5f86f51fc</guid><dc:creator>Mojo</dc:creator><description>&lt;p&gt;Try this library&amp;nbsp;&lt;a href="https://github.com/IOsonata/IOsonata"&gt;https://github.com/IOsonata/IOsonata&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s C++ object design.&lt;/p&gt;
&lt;p&gt;some tutorial from these pages.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://embeddedsoftdev.blogspot.com/2018/02/bluetooth-le-with-nordic-nrf51-nrf52.html"&gt;http://embeddedsoftdev.blogspot.com/2018/02/bluetooth-le-with-nordic-nrf51-nrf52.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Operating NRF52 peripherals (TWI) in c++ mode</title><link>https://devzone.nordicsemi.com/thread/217681?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 08:14:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:768df71f-eb7a-4106-b9a3-2f9fb6cc6c94</guid><dc:creator>MRK-196</dc:creator><description>&lt;p&gt;Thanks for your reply, Is there an example how I can use the TWI and Bluetooth peripheral on a C++ platform ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Operating NRF52 peripherals (TWI) in c++ mode</title><link>https://devzone.nordicsemi.com/thread/217673?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 07:35:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b739102c-1b8a-4df9-b823-f1c8673fb070</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The nRF5 SDK doesn&amp;#39;t support C++ unfortunately.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Several of the files use features not supported by the C++ compiler, such as &lt;a href="https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html"&gt;designated struct initializers&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Operating NRF52 peripherals (TWI) in c++ mode</title><link>https://devzone.nordicsemi.com/thread/217495?ContentTypeID=1</link><pubDate>Wed, 30 Oct 2019 11:13:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e1d7202-7317-438c-b2a7-9e104c3e41e7</guid><dc:creator>MRK-196</dc:creator><description>&lt;p&gt;Maybe it was not clear in my question, just to make it clear, I want the code to work in a C++ environment instead of C&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>