APM:Libraries
AP_HAL_Main.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Intel Corporation. All rights reserved.
3  *
4  * This file is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This file is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #pragma once
18 
19 #include "HAL.h"
20 
21 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
22 #define AP_MAIN __EXPORT ArduPilot_main
23 #endif
24 
25 #ifndef AP_MAIN
26 #define AP_MAIN main
27 #endif
28 
29 #define AP_HAL_MAIN() \
30  AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
31  extern "C" { \
32  int AP_MAIN(int argc, char* const argv[]); \
33  int AP_MAIN(int argc, char* const argv[]) { \
34  hal.run(argc, argv, &callbacks); \
35  return 0; \
36  } \
37  }
38 
39 #define AP_HAL_MAIN_CALLBACKS(CALLBACKS) extern "C" { \
40  int AP_MAIN(int argc, char* const argv[]); \
41  int AP_MAIN(int argc, char* const argv[]) { \
42  hal.run(argc, argv, CALLBACKS); \
43  return 0; \
44  } \
45  }