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

Programming nRF52 DK in C++ in Segger Embedded Studio

Hi.

I am writing software for my custom nRF52832 device but hardware wise it is identical to the nRF52 DK. 

I'm not that good of an embedded coder (or any kind of coder for that matter) and I am trying to integrate some i2c sensors on my device. 

But all the libraries of these sensors are written in C++, and are using objects and classes. Which C doesn't support.

I have managed to convert *some* of the code (in probably a very inefficient way) to plain C, but most of the code is beyond my capabilities. 

How can I code with C++ on this thing using Segger Embedded Studio? 

Any help would be greatly appreciated. 

- Usman

Parents Reply
  • Hi Usman

    I did the same exercise myself based on the ble_app_uart example to illustrate how it can be done:
    261622_ble_app_uart.zip

    Basically I copy the entirety of the main.c file into the separate C file (ble_app.c). 

    Essentially the only thing I put in the ble_app.h file is the prototype of any function that needs to be called from main.cpp. Everything else I leave in the ble_app.c file, to avoid this being pulled into main.cpp when you include the header file. 

    If you try to follow the same approach I expect you should get the example to compile. 

    Best regards
    Torbjørn

Children
Related