diff --git a/include/common/core/hardware_delay.hpp b/include/common/core/hardware_delay.hpp new file mode 100644 index 000000000..d6c34ce45 --- /dev/null +++ b/include/common/core/hardware_delay.hpp @@ -0,0 +1,12 @@ +#pragma once +// Not my favorite way to check this, but if we don't have access +// to vTaskDelay during host compilation so just dummy the function +template +requires std::is_integral_v +static void vtask_hardware_delay(T ticks) { +#ifndef INC_TASK_H + std::ignore = ticks; +#else + vTaskDelay(ticks); +#endif +} diff --git a/include/motor-control/core/tasks/usage_storage_task.hpp b/include/motor-control/core/tasks/usage_storage_task.hpp index db3d214ac..b0b05571a 100644 --- a/include/motor-control/core/tasks/usage_storage_task.hpp +++ b/include/motor-control/core/tasks/usage_storage_task.hpp @@ -7,6 +7,7 @@ #include "can/core/ids.hpp" #include "can/core/messages.hpp" #include "common/core/bit_utils.hpp" +#include "common/core/hardware_delay.hpp" #include "common/core/logging.h" #include "eeprom/core/dev_data.hpp" #include "motor-control/core/tasks/messages.hpp" @@ -15,18 +16,6 @@ namespace usage_storage_task { using namespace usage_messages; -// Not my favorite way to check this, but if we don't have access -// to vTaskDelay during host compilation so just dummy the function -template -requires std::is_integral_v -static void _hardware_delay(T ticks) { -#ifndef INC_TASK_H - std::ignore = ticks; -#else - vTaskDelay(ticks); -#endif -} - using TaskMessage = motor_control_task_messages::UsageStorageTaskMessage; static constexpr uint16_t distance_data_usage_len = 8; @@ -237,7 +226,7 @@ class UsageStorageTask { } else { // wait for the handler to be ready before sending the next // message - _hardware_delay(10); + vtask_hardware_delay(10); } } } diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index 13ce583fc..a57867b49 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -2,22 +2,11 @@ #include -// Not my favorite way to check this, but if we don't have access -// to vTaskDelay during host compilation so just dummy the function -template -requires std::is_integral_v -static void _hardware_delay(T ticks) { -#ifndef INC_TASK_H - std::ignore = ticks; -#else - vTaskDelay(ticks); -#endif -} - #include "can/core/can_writer_task.hpp" #include "can/core/ids.hpp" #include "can/core/messages.hpp" #include "common/core/bit_utils.hpp" +#include "common/core/hardware_delay.hpp" #include "common/core/logging.h" #include "common/core/message_queue.hpp" #include "common/core/sensor_buffer.hpp" @@ -317,7 +306,7 @@ class MMR920 { (*sensor_buffer).at(current_index))}); if (i % 10 == 0) { // slow it down so the can buffer doesn't choke - _hardware_delay(50); + vtask_hardware_delay(50); } (*sensor_buffer).at(current_index) = 0; }