Skip to content

Commit

Permalink
make hardware delay subsitute global
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jun 14, 2024
1 parent e6378ce commit adc41ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
12 changes: 12 additions & 0 deletions include/common/core/hardware_delay.hpp
Original file line number Diff line number Diff line change
@@ -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 <typename T>
requires std::is_integral_v<T>
static void vtask_hardware_delay(T ticks) {
#ifndef INC_TASK_H
std::ignore = ticks;
#else
vTaskDelay(ticks);
#endif
}
15 changes: 2 additions & 13 deletions include/motor-control/core/tasks/usage_storage_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 <typename T>
requires std::is_integral_v<T>
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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
15 changes: 2 additions & 13 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@

#include <cmath>

// 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 <typename T>
requires std::is_integral_v<T>
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"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit adc41ad

Please sign in to comment.