richard_damon wrote on Friday, November 15, 2013:
My own organization is that the project is divided into source files, each source file being one aspect of the program (dealing with a specific device or operation). Every C file has a matching .h file defining the API for that file, functions that other files might need to call, Global data (as little as possible) to be referenced by other files, and any types/constants needed for these.
One function that every file will define is an init function that main will call to perform the needed initialization for that piece of code, creating tasks/queue/semaphores, and initializing the hardware.
The main program will then include all these headers (other files will just need to include the headers for the parts they talk to, but main talks to almost all of them for this init function), and calls the init functions. (If I am programming in C++, I don’t need the calls to the init function, as I can normally create object whose constructors, called at startup time, do this needed initialization).