| 554 | } |
| 555 | |
| 556 | void Scheduler::_io_thread(void* arg) |
| 557 | { |
| 558 | Scheduler *sched = (Scheduler *)arg; |
| 559 | chRegSetThreadName("io"); |
| 560 | while (!sched->_hal_initialized) { |
| 561 | sched->delay_microseconds(1000); |
| 562 | } |
| 563 | #if HAL_LOGGING_ENABLED |
| 564 | uint32_t last_sd_start_ms = AP_HAL::millis(); |
| 565 | #endif |
| 566 | #if CH_DBG_ENABLE_STACK_CHECK == TRUE |
| 567 | uint32_t last_stack_check_ms = 0; |
| 568 | #endif |
| 569 | while (true) { |
| 570 | sched->delay_microseconds(1000); |
| 571 | |
| 572 | // run registered IO processes |
| 573 | sched->_run_io(); |
| 574 | |
| 575 | #if HAL_LOGGING_ENABLED || CH_DBG_ENABLE_STACK_CHECK == TRUE |
| 576 | uint32_t now = AP_HAL::millis(); |
| 577 | #endif |
| 578 | |
| 579 | #if HAL_LOGGING_ENABLED |
| 580 | if (!hal.util->get_soft_armed()) { |
| 581 | // if sdcard hasn't mounted then retry it every 3s in the IO |
| 582 | // thread when disarmed |
| 583 | if (now - last_sd_start_ms > 3000) { |
| 584 | last_sd_start_ms = now; |
| 585 | AP::FS().retry_mount(); |
| 586 | } |
| 587 | } |
| 588 | #endif |
| 589 | #if CH_DBG_ENABLE_STACK_CHECK == TRUE |
| 590 | if (now - last_stack_check_ms > 1000) { |
| 591 | last_stack_check_ms = now; |
| 592 | sched->check_stack_free(); |
| 593 | } |
| 594 | #endif |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | #if defined(STM32H7) |
| 599 | /* |
nothing calls this directly
no test coverage detected