MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / main_loop

Function main_loop

libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp:211–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209static AP_HAL::HAL::Callbacks* g_callbacks;
210
211static void main_loop()
212{
213 daemon_task = chThdGetSelfX();
214
215 /*
216 switch to high priority for main loop
217 */
218 chThdSetPriority(APM_MAIN_PRIORITY);
219
220#ifdef HAL_I2C_CLEAR_BUS
221 // Clear all I2C Buses. This can be needed on some boards which
222 // can get a stuck I2C peripheral on boot
223 ChibiOS::I2CBus::clear_all();
224#endif
225
226#if AP_HAL_SHARED_DMA_ENABLED
227 ChibiOS::Shared_DMA::init();
228#endif
229
230 peripheral_power_enable();
231
232 hal.serial(0)->begin(SERIAL0_BAUD);
233
234#if (HAL_USE_SPI == TRUE) && defined(HAL_SPI_CHECK_CLOCK_FREQ)
235 // optional test of SPI clock frequencies
236 ChibiOS::SPIDevice::test_clock_freq();
237#endif
238
239 hal.analogin->init();
240 hal.scheduler->init();
241
242 /*
243 run setup() at low priority to ensure CLI doesn't hang the
244 system, and to allow initial sensor read loops to run
245 */
246 hal_chibios_set_priority(APM_STARTUP_PRIORITY);
247
248 if (stm32_was_watchdog_reset()) {
249 // load saved watchdog data
250 stm32_watchdog_load((uint32_t *)&utilInstance.persistent_data, (sizeof(utilInstance.persistent_data)+3)/4);
251 utilInstance.last_persistent_data = utilInstance.persistent_data;
252 }
253
254 schedulerInstance.hal_initialized();
255
256 g_callbacks->setup();
257
258#if HAL_ENABLE_SAVE_PERSISTENT_PARAMS
259 utilInstance.apply_persistent_params();
260#endif
261
262#if HAL_FLASH_PROTECTION
263 if (AP_BoardConfig::unlock_flash()) {
264 stm32_flash_unprotect_flash();
265 } else {
266 stm32_flash_protect_flash(false, AP_BoardConfig::protect_flash());
267 stm32_flash_protect_flash(true, AP_BoardConfig::protect_bootloader());
268 }

Callers 1

runMethod · 0.70

Calls 15

peripheral_power_enableFunction · 0.85
hal_chibios_set_priorityFunction · 0.85
stm32_was_watchdog_resetFunction · 0.85
stm32_watchdog_loadFunction · 0.85
serialMethod · 0.80
watchdog_patMethod · 0.80
check_called_boostMethod · 0.80
initFunction · 0.70
stm32_watchdog_initFunction · 0.50

Tested by

no test coverage detected