Browse Source
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.master
Caio Marcelo de Oliveira Filho
9 years ago
committed by
Andrew Tridgell
16 changed files with 41 additions and 146 deletions
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
#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__
|
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
|
||||
#ifndef __AP_HAL_AVR_MAIN_H__ |
||||
#define __AP_HAL_AVR_MAIN_H__ |
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 |
||||
#define AP_HAL_MAIN() extern "C" {\ |
||||
int main (void) {\
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(0, NULL, &callbacks); \
|
||||
return 0; \
|
||||
}\
|
||||
} |
||||
#endif |
||||
|
||||
#endif // __AP_HAL_AVR_MAIN_H__
|
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
#ifndef __AP_HAL_EMPTY_MAIN_H__ |
||||
#define __AP_HAL_EMPTY_MAIN_H__ |
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_EMPTY |
||||
#define AP_HAL_MAIN() extern "C" {\ |
||||
int main (void) {\
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(0, NULL, &callbacks); \
|
||||
return 0; \
|
||||
}\
|
||||
} |
||||
#endif // HAL_BOARD_EMPTY
|
||||
|
||||
#endif // __AP_HAL_EMPTY_MAIN_H__
|
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
/*
|
||||
Flymaple port by Mike McCauley |
||||
*/ |
||||
|
||||
|
||||
#ifndef __AP_HAL_FLYMAPLE_MAIN_H__ |
||||
#define __AP_HAL_FLYMAPLE_MAIN_H__ |
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_FLYMAPLE |
||||
#define AP_HAL_MAIN() extern "C" {\ |
||||
int main (void) {\
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(0, NULL, &callbacks); \
|
||||
return 0; \
|
||||
}\
|
||||
} |
||||
#endif // HAL_BOARD_FLYMAPLE
|
||||
|
||||
#endif // __AP_HAL_FLYMAPLE_MAIN_H__
|
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
#ifndef __AP_HAL_LINUX_MAIN_H__ |
||||
#define __AP_HAL_LINUX_MAIN_H__ |
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX |
||||
#define AP_HAL_MAIN() extern "C" {\ |
||||
int main (int argc, char * const argv[]) { \
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(argc, argv, &callbacks); \
|
||||
return 0; \
|
||||
}\
|
||||
} |
||||
#endif // HAL_BOARD_LINUX
|
||||
|
||||
#endif // __AP_HAL_LINUX_MAIN_H__
|
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
#ifndef __AP_HAL_PX4_MAIN_H__ |
||||
#define __AP_HAL_PX4_MAIN_H__ |
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 |
||||
|
||||
#define AP_HAL_MAIN() \ |
||||
extern "C" __EXPORT int SKETCH_MAIN(int argc, char * const argv[]); \
|
||||
int SKETCH_MAIN(int argc, char * const argv[]) { \
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(argc, argv, &callbacks); \
|
||||
return OK; \
|
||||
} |
||||
|
||||
#endif |
||||
#endif // __AP_HAL_PX4_MAIN_H__
|
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
|
||||
#ifndef __AP_HAL_SITL_MAIN_H__ |
||||
#define __AP_HAL_SITL_MAIN_H__ |
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL |
||||
#define AP_HAL_MAIN() extern "C" {\ |
||||
int main (int argc, char * const argv[]) { \
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(argc, argv, &callbacks); \
|
||||
return 0; \
|
||||
}\
|
||||
} |
||||
#endif |
||||
|
||||
#endif // __AP_HAL_SITL_MAIN_H__
|
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
#ifndef __AP_HAL_VRBRAIN_MAIN_H__ |
||||
#define __AP_HAL_VRBRAIN_MAIN_H__ |
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN |
||||
|
||||
#define AP_HAL_MAIN() \ |
||||
extern "C" __EXPORT int SKETCH_MAIN(int argc, char * const argv[]); \
|
||||
int SKETCH_MAIN(int argc, char * const argv[]) { \
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(argc, argv, &callbacks); \
|
||||
return OK; \
|
||||
} |
||||
|
||||
#endif |
||||
#endif // __AP_HAL_VRBRAIN_MAIN_H__
|
Loading…
Reference in new issue