- I used layer architecture for developing the drivers and the HALs of the atmega32 microcontroller.
- Every folder in the
MCAL
orHAL
folders 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
main
function. (It only compiles the_program.c
source files) -
make build-all
:- Compiles all source files that has no
main
function. - For every source file that has the
main
function, Compile it and Link it with other object files. Then Generate its corresponding executable. (Usually.elf
and.hex
format)
- Compiles all source files that has no
-
make flash EXEC=*flash_name*
:Flashes the
.hex
file to the microcontroller. TheEXEC
variable must be specified because we have multiple executables.(Note:
flash_name
must 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