...
Ardupilot implementation reference
RSSI.cpp calls on AP_HAL_SITL/AnalopIn.cpp class for its ‘channel’ function
AnalogIn.cpp has ‘channel’ function which returns a pointer to an AnalogSource object by calling the ADCSource object constructor. Pointer is stored in rssi_analog_source variable
(ADCSource inherits from AnalogSource, is declared in AP_HAL_SITL/AnalogIn)
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_HAL_SITL/AnalogIn.cpp
AnalogSource is an abstract class, defined in a different AnalogIn file, AP_HAL/AnalogIn
AnalogSource constructor requires inputting a pointer to a SITL_State object
In RSSI.cpp, AnalogIn object is actually a member variable of AP_HAL::HAL.h class
A hal.h object called hal is accessed using ‘extern’ keyword
In RSSI.cpp read_pin_rssi function
ADCSource voltage_average() function is called on rssi_analog_source variable
voltage_average() returns a manipulated output of ADCSource read_average() function. read_average() returns return of ADCSource read_latest() function.
read_latest(), depending on the pin, returns the appropriate pin value from the _sitlState member variable of ADCSource, which holds a pointer to a sitlState object