HAL_Empty_Class.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include <AP_HAL/AP_HAL.h>
  2. #if CONFIG_HAL_BOARD == HAL_BOARD_EMPTY
  3. #include <assert.h>
  4. #include "HAL_Empty_Class.h"
  5. #include "AP_HAL_Empty_Private.h"
  6. using namespace Empty;
  7. static UARTDriver uartADriver;
  8. static UARTDriver uartBDriver;
  9. static UARTDriver uartCDriver;
  10. static SPIDeviceManager spiDeviceManager;
  11. static AnalogIn analogIn;
  12. static Storage storageDriver;
  13. static GPIO gpioDriver;
  14. static RCInput rcinDriver;
  15. static RCOutput rcoutDriver;
  16. static Scheduler schedulerInstance;
  17. static Util utilInstance;
  18. static OpticalFlow opticalFlowDriver;
  19. static Flash flashDriver;
  20. HAL_Empty::HAL_Empty() :
  21. AP_HAL::HAL(
  22. &uartADriver,
  23. &uartBDriver,
  24. &uartCDriver,
  25. nullptr, /* no uartD */
  26. nullptr, /* no uartE */
  27. nullptr, /* no uartF */
  28. nullptr, /* no uartG */
  29. nullptr, /* no uartH */
  30. &spiDeviceManager,
  31. &analogIn,
  32. &storageDriver,
  33. &uartADriver,
  34. &gpioDriver,
  35. &rcinDriver,
  36. &rcoutDriver,
  37. &schedulerInstance,
  38. &utilInstance,
  39. &opticalFlowDriver,
  40. &flashDriver)
  41. {}
  42. void HAL_Empty::run(int argc, char* const argv[], Callbacks* callbacks) const
  43. {
  44. assert(callbacks);
  45. /* initialize all drivers and private members here.
  46. * up to the programmer to do this in the correct order.
  47. * Scheduler should likely come first. */
  48. scheduler->init();
  49. uartA->begin(115200);
  50. _member->init();
  51. callbacks->setup();
  52. scheduler->system_initialized();
  53. for (;;) {
  54. callbacks->loop();
  55. }
  56. }
  57. const AP_HAL::HAL& AP_HAL::get_HAL() {
  58. static const HAL_Empty hal;
  59. return hal;
  60. }
  61. #endif