AP_HAL_Main.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include "HAL.h"
  19. #ifndef AP_MAIN
  20. #define AP_MAIN main
  21. #endif
  22. #define AP_HAL_MAIN() \
  23. AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
  24. extern "C" { \
  25. int AP_MAIN(int argc, char* const argv[]); \
  26. int AP_MAIN(int argc, char* const argv[]) { \
  27. hal.run(argc, argv, &callbacks); \
  28. return 0; \
  29. } \
  30. }
  31. #define AP_HAL_MAIN_CALLBACKS(CALLBACKS) 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. }