- I used layer architecture for developing the drivers and the HALs of the atmega32 microcontroller.
- Every folder in the
MCALorHALfolders is considered as a module. - Every module contains 5 files:
MODULE_interface.h: Contains the interface of the module like functions prototypes and structure types.MODULE_program.c: Contains the implementations and details of the module.MODULE_register.h: A register definition file that contains registers names and their map either in the microcontroller or in an external device.MODULE_config.h: Contains the pre-build configurations of the module.MODULE_private.h: Contains definitions private to the module.MODULE_test.c: Contains tests for the module only. (Note: It has a main function.)
This Project has multiple main functions. We can compile source files, but can link only with one
source file that has a main function.
-
make compile-all:Compiles all source file that has no
mainfunction. (It only compiles the_program.csource files) -
make build-all:- Compiles all source files that has no
mainfunction. - For every source file that has the
mainfunction, Compile it and Link it with other object files. Then Generate its corresponding executable. (Usually.elfand.hexformat)
- Compiles all source files that has no
-
make flash EXEC=*flash_name*:Flashes the
.hexfile to the microcontroller. TheEXECvariable must be specified because we have multiple executables.(Note:
flash_namemust be without any suffixes) -
make clean: Cleans all the generated files. -
make docs: Generate documentation files.
To build all the executables and flash the MPU6050_test.hex, just do as the following:
$ make build-all && make all EXEC=MPU6050_test