AP_HAL_ESP32: 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:56:04 -06:00 committed by Peter Barker
parent a9ddadee3b
commit 2dbf5aefb3
1 changed files with 8 additions and 2 deletions

View File

@ -56,8 +56,14 @@ uint64_t millis64()
} // namespace AP_HAL
static HAL_ESP32 hal_esp32;
const AP_HAL::HAL& AP_HAL::get_HAL()
{
static const HAL_ESP32 hal;
return hal;
return hal_esp32;
}
AP_HAL::HAL& AP_HAL::get_HAL_mutable()
{
return hal_esp32;
}