mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-04 15:08:28 -04:00
19b4ca60c4
Move the macros to a single place and reduce the variations not based on board, but based on - The name of the entry-point function, specified by AP_MAIN; - Whether it contains argc/argv arguments or not. The goal here is that programs (vehicles and examples) don't need to include all possible boards to define a main function. Further patches will change the programs.
41 lines
911 B
C
41 lines
911 B
C
#ifndef __AP_HAL_MAIN_H__
|
|
#define __AP_HAL_MAIN_H__
|
|
|
|
#include "HAL.h"
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 || CONFIG_HAL_BOARD == HAL_BOARD_FLYMAPLE
|
|
#define CONFIG_MAIN_WITHOUT_ARGC_ARGV 1
|
|
#endif
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
|
#define AP_MAIN __EXPORT ArduPilot_main
|
|
#endif
|
|
|
|
#ifndef AP_MAIN
|
|
#define AP_MAIN main
|
|
#endif
|
|
|
|
#if CONFIG_MAIN_WITHOUT_ARGC_ARGV
|
|
|
|
#define AP_HAL_MAIN() extern "C" { \
|
|
int AP_MAIN(void) { \
|
|
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
|
hal.run(0, NULL, &callbacks); \
|
|
return 0; \
|
|
} \
|
|
}
|
|
|
|
#else
|
|
|
|
#define AP_HAL_MAIN() extern "C" { \
|
|
int AP_MAIN(int argc, char* const argv[]) { \
|
|
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
|
hal.run(argc, argv, &callbacks); \
|
|
return 0; \
|
|
} \
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif // __AP_HAL_MAIN_H__
|