AP_HAL_ChibiOS: introduce get_HAL_mutable() to complement get_HAL()

Returns a mutable reference to the same HAL for certain purposes where
the HAL needs to be mutated to avoid UB problems with casting away const
and to make the fact that mutation is happening obvious.
This commit is contained in:
Thomas Watson 2023-11-23 19:55:45 -06:00 committed by Peter Barker
parent dc76e03890
commit a9ddadee3b
1 changed files with 6 additions and 1 deletions

View File

@ -344,8 +344,13 @@ void HAL_ChibiOS::run(int argc, char * const argv[], Callbacks* callbacks) const
main_loop();
}
static HAL_ChibiOS hal_chibios;
const AP_HAL::HAL& AP_HAL::get_HAL() {
static const HAL_ChibiOS hal_chibios;
return hal_chibios;
}
AP_HAL::HAL& AP_HAL::get_HAL_mutable() {
return hal_chibios;
}