跳转到主内容
Knowledgebase
Home
Renesas Electronics China - Knowledgebase

How to create a C++ project for the Synergy Platform

Latest Updated:10/04/2016

Overview

This How-To explains the process used to create a C++ project in the Synergy Platform.

Goal

After completing this How-To you will be able to add C++ content to a Synergy Platform project.

Create a Synergy Project

First start by creating and configuring a Synergy project as you normally would. When the project is configured as required, change the "Build Artifact" to "Static Library" as shown in the figure below.

StaticLibrary.png

Then build the project again. This will result in a static library being built in the output directory for the current build configuration (in this case libS7_DK_GCC_SSP_LIBRARY.a in the Debug output directory) as seen in the Figure below.

Library.png

Create Another Project for C++

Now, we can create another ISDE project that will support C++, and include the SSP as a static library from the first project we set up.

To create the new project, File->New->Project then select C/C++->C++ Project as seen in the Figure below.

Create.png

Then click next, and select Executable->Hello World GNU ARM Embedded C++ Project, and fill in the desired project name.

Name.png

Then click Next (no need to modify anything on this screen), and next again.

Finish.png

then click Finish.

Now go to the properties of the project just created. Maximize the window, and select "Tool settings", change the ARM Family to "cortex-M4", Float ABI to "FP instructions (Hard)" and FPU type to "fpv4-sp-d16", these will match the settings in the SSP library project.

MatchSettings.png

 In Cross ARM C++ Linker->General add in the linker script from the SSP project we previously generated.

LinkerScript.png

And in the Cross ARM C++ Linker->Libraries section add in the reference to the static SSP library, and the library path.

LibraryPath.png

Next, add in the include paths, to Cross ARM GNU Assembler.

Assembler.png

The Cross ARM C Compiler->Includes are also needed.

Includes.png

Add the Cross ARM C++ Compiler -> Includes.

CPlusIncludes.png

These include paths are the ones the original SSP project referenced.

OriginalIncludes.png

Then click, Ok, and then click Finish.

The project wizard will have created a file src\main.cpp, this should deleted.

Add this linked file (R_BSP_WarmStart.c, from https://knowledgebase.renesas.com/@api/deki/files/284/R_BSP_WarmStart.c?draft=true) to the src directory, this calls the Static Constructor from the GCC tool chain libraries.

    else if (BSP_WARM_START_POST_C == event)

    {

        /* Static Constructor */

       __libc_init_array();

    }

and is required to set up the C++ environment correctly.

Finally, we can add a file for the user code for the threads that were created in the SSP. E.g. if a thread called "new_thread" was added to the SSP in the first project, we need to add to the C++ project, a .cpp file in the src\ directory of the project, containing at least the user entry function for the thread we created in the SSP, i.e. add the file src\new_thread_entry.cpp, and the basic required code in that file is:

#ifdef __cplusplus

    extern "C" {

#endif

#include "new_thread.h"

#include <stdio.h>

void new_thread_entry(void);

#ifdef __cplusplus

    }

#endif

void new_thread_entry(void)

{

       while(1)

       {

              tx_thread_sleep(1);

       }

}

Add files as required for all the threads that were added to the SSP configuration in the first project. Now you can add code as required to the threads in the C++ project.

Important Note: If you get unexpected errors and have double checked all you entries are correct, you may need to adjust the order of your Linker Library include files to remove the error.

What's Next

Write some code!

  • 这篇文章对您有帮助吗?