CCS and TI-RTOS with Class
For my Hearing Guard System Safe & Sound Challenge project it was decided to attempt to implement C++ Object Oriented Programming features which includes the use of Classes over the standard C Structured Programming. As a baseline, I used the 'bigtime' project which can be found in the MSP432 TI-RTOS package. However, I soon ran into a limitation especially when calling the Graphics files used with the Sharp LCD. Initially, like with the 'bigtime' project, I tried to use the default TI-Compiler TI v16.12.0.STS. The issue is that the grlib libraries use defined variables such as 'int8_t' which are typdef'd as '__int8_t' and is defined as follows
typedef signed char __int8_t ;
The problem is that the the TI-Compiler TI v16.12.0.STS only supports up to C++03, C Compiler defaults at c89, which does not include defined C99 types from C so I kept getting compiler errors. After some research, and many a late night hacking, I found the GNU compiler that can be added to CCS via the CCS App Center tool does support up to C++11 and includes support for the C99 style int8_t and other defines. Thus, I added this to CCS, 6.2 in this instance, and then Created another project via 'Project->New CSS Project' and Selecting Compiler Version GNU v4.9.3 (Linaro). Set a Project name and then under 'Project Templates and examples' select:
TI-RTOS Examples->MSP_EXP432P401R->Driver Examples->GNU Driver Examples->Empty Examples->Empty Project.
Once the project has been added to the Project Explorer, the first thing to do to make this a C++ project is to replace the existing empty.c file with a .cpp file. I found it is best just to create a new Source File and use '_Template' 'Default C++ source template' and ensure to name the file with an .cpp extension. Once the file is in place, copy the contents from empty.c to the new .cpp file and then remove the empty.c file.
To complete the conversion to a C++11 supported project, a few changes to the Project Properties have to be made.
1. Right click on the new project and select 'Properties' at the bottom of the pop-up window
a. Under CSS General, select the RTSC tab
I. Select Product and Repositories:
1. ensure the following are set:
i. XDCtools version:
a. 3.32.1.22_core
NOTE: The is the latest in my config
2. TI-RTOS for MSP43x (checked)
I. 2.20.0.06 (checked)
Note: Your version may differ
3. Other Repositories
I. '${TARGET_CONTENT_BASE}' (checked)
4. All other items not checked at this time
II. Target:
1. gnu.targets.arm.M4F
III. Platform:
1. ti.platforms.msp432:MSP432P401R
2. In the Properties window
a. Select CCS Build
I. GNU Compiler
1. Symbols
i. Add the following
a. '__cplusplus'
1. Value = 201103L
b. __GXX_EXPERIMENTAL_CXXOX__
2. Miscellaneous
i. Other flags:
a. Add
1. -std=c++11
3. Select Directories
i. Under 'Include paths (-l)' add
a. Directory path to the grlib/grlib folder in your workspace
1. ex: "${workspace_loc:/${ProjName}/grlib/grlib}"
3. Still in the Properties window, in the left window
a. Select CCS General
I. GNU linker
1. Libraries
i. Libraries ('-l, --library)
a. Click Add
1. Enter: “stdc++”
NOTE: use quotes around stdc++
4. In the Properties window
a. Select C/C++ Build
I. Settings
1. Tool Settings tab
i. GNU Compiler
a. Symbols
NOTE: ensure the following settings performed previously are set
1. __cplusplus
i. Value = 201103L
2. __GXX_EXPERIMENTAL_CXX0X_
b. Miscellaneous
1. Ensure Other flags has
i. -stdc=c++11
b. Select C/C++ General
I. Paths and Symbols
1. Library Path tab
i. Ensure the TIRTOS path is set to the appropriate path for the 'gcc' compiler
NOTE: TI-RTOS for MSP432 in this instance for the MSP432 Launchpad
${COM_TI_RTSC_TIRTOSMSP430_INSTALL_DIR}/products/msp432_driverlib_3_21_00_05/driverlib/MSP432P4xx/gcc
II. Preprocessor Include Paths, Macros etc.
1. Providers tab
i. Ensure the only 'CDT GCC Built-in Compiler Settings' is selected:
NOTE: All other options are not selected.
ii. In the Command to get compiler specs, add the following:
a. '-std=c++11'
This should get the environment set to for c++11 style development in TI-RTOS using Code Composer Studio.
Since this is such a long posting, I'll create a follow on post to cover the C++ Class code I have started.
Top Comments