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

Method init

libraries/AP_HAL_Linux/RCInput_RPI.cpp:524–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522}
523
524void RCInput_RPI::init()
525{
526 uint64_t signal_states(0);
527
528#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2
529 _version = LINUX_BOARD_TYPE::RPI_2_3_ZERO2;
530#else
531 _version = UtilRPI::from(hal.util)->detect_linux_board_type();
532#endif
533
534 set_physical_addresses();
535 // Init memory for buffer and for DMA control blocks.
536 // See comments in "init_ctrl_data()" to understand values "2" and "15"
537 circle_buffer = NEW_NOTHROW Memory_table(RCIN_RPI_BUFFER_LENGTH * 2, _version);
538 con_blocks = NEW_NOTHROW Memory_table(RCIN_RPI_BUFFER_LENGTH * 15, _version);
539
540 init_registers();
541
542 // Enable PPM or PWM input
543 for (uint32_t i = 0; i < RCIN_RPI_CHN_NUM; ++i) {
544 rc_channels[i].enable_pin = hal.gpio->channel(RcChnGpioTbl[i]);
545 rc_channels[i].enable_pin->mode(HAL_GPIO_INPUT);
546 }
547
548 // Configuration
549 set_sigaction();
550 init_ctrl_data();
551 init_PCM();
552 init_DMA();
553
554 // Wait a bit to let DMA fill queues and come to stable sampling
555 hal.scheduler->delay(300);
556
557 // Reading first sample
558 curr_tick = *((uint64_t *)circle_buffer->get_page(circle_buffer->_virt_pages, curr_pointer));
559 curr_pointer += 8;
560 signal_states = *((uint64_t *)circle_buffer->get_page(circle_buffer->_virt_pages, curr_pointer));
561 for (uint32_t i = 0; i < RCIN_RPI_CHN_NUM; ++i) {
562 rc_channels[i].prev_tick = curr_tick;
563 rc_channels[i].curr_signal = (signal_states & (1 << RcChnGpioTbl[i])) ? RCIN_RPI_SIG_HIGH
564 : RCIN_RPI_SIG_LOW;
565 rc_channels[i].last_signal = rc_channels[i].curr_signal;
566 }
567 curr_pointer += 8;
568
569 set_num_channels(RCIN_RPI_CHN_NUM);
570
571 _initialized = true;
572}
573
574// Processing signal
575void RCInput_RPI::_timer_tick()

Callers

nothing calls this directly

Calls 5

get_pageMethod · 0.80
channelMethod · 0.45
modeMethod · 0.45
delayMethod · 0.45

Tested by

no test coverage detected