Hello everyone, I am a ruffian balance, is a serious technical ruffian. Today ruffian balance to introduce you is MCUXpresso IDE to add a new path under the source file into the project compilation method.

Next to the last article “SDK project import and Workspace management mechanism under MCUXpresso IDE”, Ruffian Heng said that it is not recommended to create a new project from scratch, it is best to import a ready project in SDK (try to be close to your final needs, mainly include the SDK basic drivers required). Then based on this project, modify it into the final project you want.

If you are used to a non-Eclipse integrated development environment like IAR or MDK, you may not be comfortable with the way you manage projects (mainly adding source files to projects) under the MCUXpresso IDE. This article will show you where adding source files in the MCUXpresso IDE makes you uncomfortable.

1. Prepare the test environment

In the previous article “SDK project Import and Workspace Management mechanism under MCUXpresso IDE”, we imported a Hello World project of RT500 into workspace space. Let’s copy this project to the following customized path. Then use Import Project (s) from File System under the MCUXpresso IDE and uncheck Copy Projects into Workspace to open the Hello World project under the custom path.

C /h, sw_delay2.c/. H, and sw_delay3.c/. H. We will use these three sets of source files to test adding source files to the project under three different path types.

////////////////sw_delayx.c////////////////
#include "sw_delayx.h"
void sw_delayx(uint32_t n)
{
    while(n ! =0U) { n--; }}////////////////sw_delayx.h////////////////
#include <stdint.h>
#if defined(__cplusplus)
extern "C" {
#endif
void sw_delayx(uint32_t n);
#if defined(__cplusplus)
}
#endif
Copy the code

2. Add the source file in the existing path to the project

In the first test case, which is the easiest, we directly place the sw_delay1.c/h file in the \ McUx_test \ evkMIMxrt595_hello_world \source\ path, alongside the main function source file hello_world.c. When we put the new source file in the existing path, in the MCUXpresso IDE project, the new file is immediately displayed in the workspace in the upper left corner of the interface. You don’t have to manually add it. C /h), we can reference and call sw_delay1.c/h directly from the main function file without any additional engineering setup.

Path automatically refresh the project source files into the project is under the Eclipse IDE features, this feature is quite good, there is only one case is not very convenient, it is different in the source file has the same function definition (could be testing purposes, or deliberately withhold different version function), the compile error of the project in this case, In the IDE, right-click the source file you don’t want to add to the project and check Exclude Resource from Build in the Properties box.

3. Add the source file to the project in the new path

3.1 In the Path where the Project File Is Stored

Now let’s switch to the current project path \ McUx_test \ evKMIMxrt595_hello_world, but create a new folder named sw_delay2, And place the sw_delay2.c/h file in the \ McUx_test \ evKMIMxrt595_hello_world \sw_delay2\ path. Because of the new path, it is also necessary to add the new path in the MCU C Compiler/Includes of the project Properties option (preferably in the MCU Assembler/General as well).

The new folder sw_delay2 and its source files also appear to be automatically updated to the project workspace. Try calling sw_delay2() from the main function source file and compiling the project. Sw_delay2 () : undefined reference to ‘sw_delay2’

The second problem is that the new folder under the project file path appears to be automatically updated to the project workspace, but the source file is not actually added to the project. You need to manually add the path. Do the following under Paths and Symbols in C/C++ General under the Properties option of the project. After you have done this, you can see in workspace that the sw_delay2 folder is displayed above Debug. (In SDK projects, the Debug and doc folders are usually displayed at the bottom. These two folders are not actually added to the project source file path. Any folders that appear after them are not actually added to the project), and the project now compiles normally.

3.2 Path for Storing Non-engineering Files

Finally, for the most complicated case, instead of working on the project path \ McUx_test \ evKMIMxrt595_hello_world, we will create a new folder named sw_delay3 under \ McUx_test \ And place the sw_delay3.c/h file in the \ McUx_test \ sw_delay3. path. Since this new path is not related to the project path, the project workspace does not automatically display it, so of course we need to manually add this folder into the project. Right-click the project and select New/Folder. Use the Link to Alternate Location function under Advanced in the Folder option to add the SW_delay3 Folder and its source files to the project.

The sw_delay3 folder is already displayed in the project workspace, but it is displayed at the bottom (after Debug and doc). If the sw_delay3 folder is just placed under \ McUx_test \ evkMIMxrt595_hello_world \, Follow the method in section 3.1 and set the MCU C Compiler/Includes and C/C++ general-paths and Symbols respectively.

There is a third thing you can’t get used to. When a source folder in the path of a non-project file is forced to link to the project, its Include path is directly converted to the current project path /${ProjName}/, instead of using IAR/MDK. / Go back and find specific relative paths.

At this point, MCUXpresso IDE to add a new path under the source file into the project compilation method Ruffian Balance will be introduced, applause where ~~~

Welcome to subscribe to

The article will be published on my blog park homepage, CSDN homepage, Zhihu homepage and wechat public account at the same time.

Wechat search “ruffian balance embedded” or scan the following two-dimensional code, you can see the first time on the phone oh.