Skip to content

Commit

Permalink
get all of the firmwares to compile now
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Feb 7, 2024
1 parent 914d5ee commit cb4e03c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 8 deletions.
48 changes: 47 additions & 1 deletion include/motor-control/core/stepper_motor/motion_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ template <lms::MotorMechanicalConfig MEConfig>
class MotionController {
public:
using GenericQueue =
#ifdef PIPETTE_TYPE_DEFINE
freertos_message_queue::FreeRTOSMessageQueue<SensorSyncMove>;
#else
freertos_message_queue::FreeRTOSMessageQueue<Move>;
#endif
using UpdatePositionQueue = freertos_message_queue::FreeRTOSMessageQueue<
can::messages::UpdateMotorPositionEstimationRequest>;
MotionController(lms::LinearMotionSystemConfig<MEConfig> lms_config,
Expand Down Expand Up @@ -59,7 +63,7 @@ class MotionController {
-> const lms::LinearMotionSystemConfig<MEConfig>& {
return linear_motion_sys_config;
}

#ifdef PIPETTE_TYPE_DEFINE
void move(const can::messages::AddSensorMoveRequest& can_msg) {
steps_per_tick velocity_steps =
fixed_point_multiply(steps_per_mm, can_msg.velocity);
Expand Down Expand Up @@ -122,6 +126,48 @@ class MotionController {
}
queue.try_write(msg);
}
#else

void move(const can::messages::AddLinearMoveRequest& can_msg) {
steps_per_tick velocity_steps =
fixed_point_multiply(steps_per_mm, can_msg.velocity);
steps_per_tick_sq acceleration_steps =
fixed_point_multiply(steps_per_um, can_msg.acceleration);
Move msg{
.message_index = can_msg.message_index,
.duration = can_msg.duration,
.velocity = velocity_steps,
.acceleration = acceleration_steps,
.group_id = can_msg.group_id,
.seq_id = can_msg.seq_id,
.stop_condition = can_msg.request_stop_condition,
.usage_key = hardware.get_usage_eeprom_config().get_distance_key()};
if (!enabled) {
enable_motor();
}
queue.try_write(msg);
}

void move(const can::messages::HomeRequest& can_msg) {
steps_per_tick velocity_steps =
fixed_point_multiply(steps_per_mm, can_msg.velocity);
Move msg{
.message_index = can_msg.message_index,
.duration = can_msg.duration,
.velocity = velocity_steps,
.acceleration = 0,
.group_id = can_msg.group_id,
.seq_id = can_msg.seq_id,
.stop_condition =
static_cast<uint8_t>(MoveStopCondition::limit_switch),
.usage_key = hardware.get_usage_eeprom_config().get_distance_key()};
if (!enabled) {
enable_motor();
}
queue.try_write(msg);
}

#endif

[[nodiscard]] auto update_position(
const can::messages::UpdateMotorPositionEstimationRequest& can_msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include "motor-control/core/motor_messages.hpp"
#include "motor-control/core/stall_check.hpp"
#include "motor-control/core/tasks/move_status_reporter_task.hpp"
#ifdef PIPETTE_TYPE_DEFINE
#include "pipettes/core/sensor_tasks.hpp"
#endif
namespace motor_handler {

using namespace motor_messages;
Expand Down Expand Up @@ -375,6 +377,7 @@ class MotorInterruptHandler {
hardware.enable_encoder();
buffered_move.start_encoder_position =
hardware.get_encoder_pulses();
#ifdef PIPETTE_TYPE_DEFINE
if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) {
auto msg = can::messages::BindSensorOutputRequest{
.message_index = buffered_move.message_index,
Expand All @@ -384,6 +387,7 @@ class MotorInterruptHandler {
};
send_to_pressure_sensor_queue(msg);
}
#endif
}
if (set_direction_pin()) {
hardware.positive_direction();
Expand Down Expand Up @@ -466,6 +470,7 @@ class MotorInterruptHandler {
tick_count = 0x0;
stall_handled = false;
build_and_send_ack(ack_msg_id);
#ifdef PIPETTE_TYPE_DEFINE
if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) {
auto stop_msg = can::messages::BindSensorOutputRequest{
.message_index = buffered_move.message_index,
Expand All @@ -475,6 +480,7 @@ class MotorInterruptHandler {
static_cast<uint8_t>(can::ids::SensorOutputBinding::sync)};
send_to_pressure_sensor_queue(stop_msg);
}
#endif
set_buffered_move(MotorMoveMessage{});
// update the stall check ideal encoder counts based on
// last known location
Expand Down Expand Up @@ -617,13 +623,14 @@ class MotorInterruptHandler {
hardware.set_step_tracker(
static_cast<uint32_t>(position_tracker >> 31));
}
#ifdef PIPETTE_TYPE_DEFINE
void send_to_pressure_sensor_queue(
can::messages::BindSensorOutputRequest& m) {
std::ignore = sensor_tasks::get_queues()
.pressure_sensor_queue_rear->try_write_isr(m);
// if (!success) {this->cancel_and_clear_moves();}
}

#endif
uint64_t tick_count = 0x0;
static constexpr const q31_31 tick_flag = 0x80000000;
static constexpr const uint64_t overflow_flag = 0x8000000000000000;
Expand Down
12 changes: 9 additions & 3 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
#include "sensors/core/sensors.hpp"
#include "sensors/core/utils.hpp"

#if PIPETTE_TYPE_DEFINE == NINETY_SIX_CHANNEL
#define PRESSURE_SENSOR_BUFFER_SIZE 1800
#else
#define PRESSURE_SENSOR_BUFFER_SIZE 3000
#endif

namespace sensors {

namespace tasks {
Expand All @@ -35,7 +41,7 @@ class MMR920C04 {
MMR920C04(I2CQueueWriter &writer, I2CQueuePoller &poller,
CanClient &can_client, OwnQueue &own_queue,
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id, std::array<float, 3000> *p_buff)
const can::ids::SensorId &id, std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff)
: writer(writer),
poller(poller),
can_client(can_client),
Expand Down Expand Up @@ -353,7 +359,7 @@ class MMR920C04 {
if (echo_this_time) {
// send a response with 9999 to make an overload of the buffer
// visible
if (pressure_buffer_index < 3000) {
if (pressure_buffer_index < PRESSURE_SENSOR_BUFFER_SIZE) {
(*p_buff)[pressure_buffer_index] = pressure;
pressure_buffer_index++;
} else {
Expand Down Expand Up @@ -544,7 +550,7 @@ class MMR920C04 {
value &= Reg::value_mask;
return write(Reg::address, value);
}
std::array<float, 3000> *p_buff;
std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff;
uint16_t pressure_buffer_index = 0;
};

Expand Down
4 changes: 2 additions & 2 deletions include/sensors/core/tasks/pressure_sensor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PressureMessageHandler {
I2CQueueWriter &i2c_writer, I2CQueuePoller &i2c_poller,
CanClient &can_client, OwnQueue &own_queue,
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id, std::array<float, 3000> *p_buff)
const can::ids::SensorId &id, std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff)
: driver{i2c_writer, i2c_poller, can_client, own_queue,
hardware, id, p_buff} {}
PressureMessageHandler(const PressureMessageHandler &) = delete;
Expand Down Expand Up @@ -200,7 +200,7 @@ class PressureSensorTask {
i2c::writer::Writer<QueueImpl> *writer,
i2c::poller::Poller<QueueImpl> *poller, CanClient *can_client,
sensors::hardware::SensorHardwareBase *hardware,
std::array<float, 3000> *p_buff) {
std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff) {
auto handler = PressureMessageHandler{
*writer, *poller, *can_client, get_queue(),
*hardware, sensor_id, p_buff};
Expand Down
2 changes: 1 addition & 1 deletion pipettes/core/sensor_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

static auto tasks = sensor_tasks::Tasks{};
static auto queue_client = sensor_tasks::QueueClient{};
static std::array<float, 3000> p_buff;
static std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> p_buff;
static auto eeprom_task_builder =
freertos_task::TaskStarter<512, eeprom::task::EEPromTask>{};

Expand Down

0 comments on commit cb4e03c

Please sign in to comment.