diff --git a/include/motor-control/core/stepper_motor/motion_controller.hpp b/include/motor-control/core/stepper_motor/motion_controller.hpp index c2bd85ad1..df5cc07e6 100644 --- a/include/motor-control/core/stepper_motor/motion_controller.hpp +++ b/include/motor-control/core/stepper_motor/motion_controller.hpp @@ -25,7 +25,11 @@ template class MotionController { public: using GenericQueue = +#ifdef PIPETTE_TYPE_DEFINE freertos_message_queue::FreeRTOSMessageQueue; +#else + freertos_message_queue::FreeRTOSMessageQueue; +#endif using UpdatePositionQueue = freertos_message_queue::FreeRTOSMessageQueue< can::messages::UpdateMotorPositionEstimationRequest>; MotionController(lms::LinearMotionSystemConfig lms_config, @@ -59,7 +63,7 @@ class MotionController { -> const lms::LinearMotionSystemConfig& { 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); @@ -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(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) diff --git a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp index 2e6195294..7f224bcf3 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -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; @@ -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, @@ -384,6 +387,7 @@ class MotorInterruptHandler { }; send_to_pressure_sensor_queue(msg); } +#endif } if (set_direction_pin()) { hardware.positive_direction(); @@ -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, @@ -475,6 +480,7 @@ class MotorInterruptHandler { static_cast(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 @@ -617,13 +623,14 @@ class MotorInterruptHandler { hardware.set_step_tracker( static_cast(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; diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index f2ccacba3..d53878b58 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -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 { @@ -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 *p_buff) + const can::ids::SensorId &id, std::array *p_buff) : writer(writer), poller(poller), can_client(can_client), @@ -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 { @@ -544,7 +550,7 @@ class MMR920C04 { value &= Reg::value_mask; return write(Reg::address, value); } - std::array *p_buff; + std::array *p_buff; uint16_t pressure_buffer_index = 0; }; diff --git a/include/sensors/core/tasks/pressure_sensor_task.hpp b/include/sensors/core/tasks/pressure_sensor_task.hpp index 193801489..4c6cc5459 100644 --- a/include/sensors/core/tasks/pressure_sensor_task.hpp +++ b/include/sensors/core/tasks/pressure_sensor_task.hpp @@ -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 *p_buff) + const can::ids::SensorId &id, std::array *p_buff) : driver{i2c_writer, i2c_poller, can_client, own_queue, hardware, id, p_buff} {} PressureMessageHandler(const PressureMessageHandler &) = delete; @@ -200,7 +200,7 @@ class PressureSensorTask { i2c::writer::Writer *writer, i2c::poller::Poller *poller, CanClient *can_client, sensors::hardware::SensorHardwareBase *hardware, - std::array *p_buff) { + std::array *p_buff) { auto handler = PressureMessageHandler{ *writer, *poller, *can_client, get_queue(), *hardware, sensor_id, p_buff}; diff --git a/pipettes/core/sensor_tasks.cpp b/pipettes/core/sensor_tasks.cpp index 31a446539..46df7d568 100644 --- a/pipettes/core/sensor_tasks.cpp +++ b/pipettes/core/sensor_tasks.cpp @@ -6,7 +6,7 @@ static auto tasks = sensor_tasks::Tasks{}; static auto queue_client = sensor_tasks::QueueClient{}; -static std::array p_buff; +static std::array p_buff; static auto eeprom_task_builder = freertos_task::TaskStarter<512, eeprom::task::EEPromTask>{};