mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-04 15:08:28 -04:00
efbc7648b1
For certain basic functionality, there aren't much benefit to be able to vary the implementation easily at runtime. So instead of using virtual functions, use regular functions that are "resolved" at link time. The implementation of such functions is provided per board/platform. Examples of functions that fit this include: getting the current time (since boot), panic'ing, getting system information, rebooting. These functions are less likely to benefit from the indirection provided by virtual interfaces. For more complex hardware access APIs the indirection makes more sense and ease the testing (when we have it!). The idea is that instead of calling hal.scheduler->panic("on the streets of london"); now use AP_HAL::panic("on the streets of london"); A less important side-effect is that call-site code gets smaller. Currently the compiler needs to get the hal, get the scheduler pointer, get the right function pointer in the vtable for that scheduler. And the call must include an extra parameter ("this"). Now it will be just a function call, with the address resolved at link time. This patch introduces the first functions that will be in the namespace, further patches will implementations for each board and then switch the call-sites. The extra init() function allow any initial setup needed for the functions to work. |
||
---|---|---|
.. | ||
examples | ||
utility | ||
AnalogIn.h | ||
AP_HAL_Boards.h | ||
AP_HAL_Macros.h | ||
AP_HAL_Main.h | ||
AP_HAL_Namespace.h | ||
AP_HAL.h | ||
GPIO.h | ||
HAL.cpp | ||
HAL.h | ||
I2CDriver.h | ||
RCInput.h | ||
RCOutput.h | ||
Scheduler.h | ||
Semaphores.h | ||
SPIDriver.h | ||
Storage.h | ||
system.h | ||
UARTDriver.cpp | ||
UARTDriver.h | ||
Util.cpp | ||
Util.h |