This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

accelerometer driver in c++

We are trying to integrate an accelerator driver with the code written in c++ with example code from twi sensor from the SDK 0.10 for the nRF51, which is written in c. Will there be any issues porting the code to c++?

Also, we are using the example code in main.c of the twi sensor example, inside the twi master with twis slave example in SDK 9.2 from the nRF52. Are all the supporting drivers and libraries the same between the twi sensor example and the twi master with twis slave?

Parents
  • Hi

    You should not have any issue mixing and matching C++ and C code, as long as all files that use C++ code are compiled with the C++ compiler (in Keil this happens automatically for .cpp files, but if your main.c file also uses C++ modules you have to configure it manually).

    Converting a C file to C++ is as easy as enabling the C++ compiler, at which point you can start writing C++ code.

    The driver used by the GTT examples were customized specifically for the GTT, and is slightly different from the official SDK driver. I would recommend sticking to the one in the SDK, as this is the one being maintained going forward.

    Best regards
    Torbjørn

Reply
  • Hi

    You should not have any issue mixing and matching C++ and C code, as long as all files that use C++ code are compiled with the C++ compiler (in Keil this happens automatically for .cpp files, but if your main.c file also uses C++ modules you have to configure it manually).

    Converting a C file to C++ is as easy as enabling the C++ compiler, at which point you can start writing C++ code.

    The driver used by the GTT examples were customized specifically for the GTT, and is slightly different from the official SDK driver. I would recommend sticking to the one in the SDK, as this is the one being maintained going forward.

    Best regards
    Torbjørn

Children
No Data
Related