China Naming Network - Auspicious day query - How to integrate multiple microcontroller programs?

How to integrate multiple microcontroller programs?

No matter how many programs there are, they must be put together to make all the programs for a project. There can only be one main program, main().

If the original programs have main(), you have to choose one as the main program, and the others must be written as subroutines. And if there is a while(1) in the original programs, they must be Delete.

As for the integration of multiple programs, the easiest way to do it without making mistakes is to put all the multiple programs in one file, and put those programs that are changed into subroutines in front of the main program. .

Of course, a more reasonable structure is that a project consists of multiple files. The easiest way to do this is to save the modified subroutines as separate header files, named xxx.h, and use .h. These header files are placed in the same folder.

Use

#include "xxx.h" in the main program to include all subprograms. If there are several subprograms, just write a few lines.

Note that the original #include in the subprogram must be deleted. Just one line in the main program is enough, that is, there is only one line of #include in the entire project.

In this way, those subroutines can be called by the main program.