Scheduler.cpp 688 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "Scheduler.h"
  2. #include "AP_HAL.h"
  3. using namespace AP_HAL;
  4. extern const AP_HAL::HAL& hal;
  5. void Scheduler::register_delay_callback(AP_HAL::Proc proc,
  6. uint16_t min_time_ms)
  7. {
  8. _delay_cb = proc;
  9. _min_delay_cb_ms = min_time_ms;
  10. }
  11. void Scheduler::call_delay_cb()
  12. {
  13. if (_delay_cb == nullptr) {
  14. return;
  15. }
  16. if (_in_delay_callback) {
  17. // don't recurse!
  18. return;
  19. }
  20. _in_delay_callback = true;
  21. _delay_cb();
  22. _in_delay_callback = false;
  23. }
  24. ExpectDelay::ExpectDelay(uint32_t ms)
  25. {
  26. hal.scheduler->expect_delay_ms(ms);
  27. }
  28. ExpectDelay::~ExpectDelay()
  29. {
  30. hal.scheduler->expect_delay_ms(0);
  31. }