From 3ea1c8079bfd4da9b5d90cc810123205d154cda2 Mon Sep 17 00:00:00 2001 From: pmoegenburg Date: Wed, 24 Jan 2024 17:21:37 -0500 Subject: [PATCH] added send_from_isr method --- gantry/core/tasks_proto.cpp | 5 +++++ gantry/core/tasks_rev1.cpp | 5 +++++ gripper/core/tasks_z.cpp | 5 +++++ head/core/tasks_proto.cpp | 5 +++++ head/core/tasks_rev1.cpp | 5 +++++ include/gantry/core/queues.hpp | 2 ++ include/gripper/core/tasks.hpp | 2 ++ include/head/core/queues.hpp | 2 ++ .../core/stepper_motor/motor_interrupt_handler.hpp | 2 +- .../core/tasks/tmc2130_motor_driver_task.hpp | 1 + .../core/tasks/tmc2160_motor_driver_task.hpp | 1 + .../motor-control/core/tasks/tmc_motor_driver_common.hpp | 1 + include/pipettes/core/gear_motor_tasks.hpp | 2 ++ include/pipettes/core/linear_motor_tasks.hpp | 8 ++++++++ include/pipettes/core/tasks.hpp | 2 ++ pipettes/core/gear_motor_tasks.cpp | 5 +++++ 16 files changed, 52 insertions(+), 1 deletion(-) diff --git a/gantry/core/tasks_proto.cpp b/gantry/core/tasks_proto.cpp index c7577a431..965adbd0f 100644 --- a/gantry/core/tasks_proto.cpp +++ b/gantry/core/tasks_proto.cpp @@ -142,6 +142,11 @@ void gantry::queues::QueueClient::send_motor_driver_queue( motor_driver_queue->try_write(m); } +void gantry::queues::QueueClient::send_motor_driver_queue_isr( + const tmc2130::tasks::TaskMessage& m) { + static_cast(motor_driver_queue->try_write_isr(m)); +} + void gantry::queues::QueueClient::send_move_group_queue( const move_group_task::TaskMessage& m) { move_group_queue->try_write(m); diff --git a/gantry/core/tasks_rev1.cpp b/gantry/core/tasks_rev1.cpp index f376b1e39..4ba6f156c 100644 --- a/gantry/core/tasks_rev1.cpp +++ b/gantry/core/tasks_rev1.cpp @@ -141,6 +141,11 @@ void gantry::queues::QueueClient::send_motor_driver_queue( motor_driver_queue->try_write(m); } +void gantry::queues::QueueClient::send_motor_driver_queue_isr( + const tmc2160::tasks::TaskMessage& m) { + static_cast(motor_driver_queue->try_write_isr(m)); +} + void gantry::queues::QueueClient::send_move_group_queue( const move_group_task::TaskMessage& m) { move_group_queue->try_write(m); diff --git a/gripper/core/tasks_z.cpp b/gripper/core/tasks_z.cpp index bdeb75d3b..ce5f9b306 100644 --- a/gripper/core/tasks_z.cpp +++ b/gripper/core/tasks_z.cpp @@ -101,6 +101,11 @@ void z_tasks::QueueClient::send_motor_driver_queue( tmc2130_driver_queue->try_write(m); } +void z_tasks::QueueClient::send_motor_driver_queue_isr( + const tmc2130::tasks::TaskMessage& m) { + static_cast(tmc2130_driver_queue->try_write_isr(m)); +} + void z_tasks::QueueClient::send_move_group_queue( const move_group_task::TaskMessage& m) { move_group_queue->try_write(m); diff --git a/head/core/tasks_proto.cpp b/head/core/tasks_proto.cpp index 9567d6011..54c772575 100644 --- a/head/core/tasks_proto.cpp +++ b/head/core/tasks_proto.cpp @@ -248,6 +248,11 @@ void head_tasks::MotorQueueClient::send_motor_driver_queue( motor_queue->try_write(m); } +void head_tasks::MotorQueueClient::send_motor_driver_queue_isr( + const tmc2130::tasks::TaskMessage& m) { + static_cast(motor_queue->try_write_isr(m)); +} + void head_tasks::MotorQueueClient::send_move_group_queue( const move_group_task::TaskMessage& m) { move_group_queue->try_write(m); diff --git a/head/core/tasks_rev1.cpp b/head/core/tasks_rev1.cpp index 3b618f4e7..7d3ead190 100644 --- a/head/core/tasks_rev1.cpp +++ b/head/core/tasks_rev1.cpp @@ -273,6 +273,11 @@ void head_tasks::MotorQueueClient::send_motor_driver_queue( motor_queue->try_write(m); } +void head_tasks::MotorQueueClient::send_motor_driver_queue_isr( + const tmc::tasks::TaskMessage& m) { + static_cast(motor_queue->try_write_isr(m)); +} + void head_tasks::MotorQueueClient::send_move_group_queue( const move_group_task::TaskMessage& m) { move_group_queue->try_write(m); diff --git a/include/gantry/core/queues.hpp b/include/gantry/core/queues.hpp index 3007e49cb..42884aa01 100644 --- a/include/gantry/core/queues.hpp +++ b/include/gantry/core/queues.hpp @@ -32,6 +32,8 @@ struct QueueClient : can::message_writer::MessageWriter { void send_motor_driver_queue(const tmc::tasks::TaskMessage& m); + void send_motor_driver_queue_isr(const tmc::tasks::TaskMessage& m); + void send_move_group_queue(const move_group_task::TaskMessage& m); void send_move_status_reporter_queue( diff --git a/include/gripper/core/tasks.hpp b/include/gripper/core/tasks.hpp index 64233697f..4f8641442 100644 --- a/include/gripper/core/tasks.hpp +++ b/include/gripper/core/tasks.hpp @@ -191,6 +191,8 @@ struct QueueClient : can::message_writer::MessageWriter { void send_motor_driver_queue(const tmc2130::tasks::TaskMessage& m); + void send_motor_driver_queue_isr(const tmc2130::tasks::TaskMessage& m); + void send_move_group_queue(const move_group_task::TaskMessage& m); void send_move_status_reporter_queue( diff --git a/include/head/core/queues.hpp b/include/head/core/queues.hpp index 2552275ff..6a07d9cd1 100644 --- a/include/head/core/queues.hpp +++ b/include/head/core/queues.hpp @@ -55,6 +55,8 @@ struct MotorQueueClient : can::message_writer::MessageWriter { void send_motor_driver_queue(const tmc::tasks::TaskMessage& m); + void send_motor_driver_queue_isr(const tmc::tasks::TaskMessage& m); + void send_move_group_queue(const move_group_task::TaskMessage& m); void send_move_status_reporter_queue( 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 82e0fef95..43a9d957b 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -432,7 +432,7 @@ class MotorInterruptHandler { .severity = severity, .error_code = err_code}); if (err_code == can::ids::ErrorCode::motor_driver_error_detected) { - driver_client.send_motor_driver_queue( + driver_client.send_motor_driver_queue_isr( can::messages::ReadMotorDriverErrorStatusRequest{.message_index = message_index}); } diff --git a/include/motor-control/core/tasks/tmc2130_motor_driver_task.hpp b/include/motor-control/core/tasks/tmc2130_motor_driver_task.hpp index 3ec884cf2..9983bd344 100644 --- a/include/motor-control/core/tasks/tmc2130_motor_driver_task.hpp +++ b/include/motor-control/core/tasks/tmc2130_motor_driver_task.hpp @@ -176,6 +176,7 @@ class MotorDriverTask { template concept TaskClient = requires(Client client, const TaskMessage& m) { {client.send_motor_driver_queue(m)}; + {client.send_motor_driver_queue_isr(m)}; }; } // namespace tasks diff --git a/include/motor-control/core/tasks/tmc2160_motor_driver_task.hpp b/include/motor-control/core/tasks/tmc2160_motor_driver_task.hpp index 6ee39198d..728652258 100644 --- a/include/motor-control/core/tasks/tmc2160_motor_driver_task.hpp +++ b/include/motor-control/core/tasks/tmc2160_motor_driver_task.hpp @@ -176,6 +176,7 @@ class MotorDriverTask { template concept TaskClient = requires(Client client, const TaskMessage& m) { {client.send_motor_driver_queue(m)}; + {client.send_motor_driver_queue_isr(m)}; }; } // namespace tasks diff --git a/include/motor-control/core/tasks/tmc_motor_driver_common.hpp b/include/motor-control/core/tasks/tmc_motor_driver_common.hpp index f70fef7fe..5398de1dc 100644 --- a/include/motor-control/core/tasks/tmc_motor_driver_common.hpp +++ b/include/motor-control/core/tasks/tmc_motor_driver_common.hpp @@ -39,6 +39,7 @@ using GearTaskMessage = typename ::utils::VariantCat< template concept TaskClient = requires(Client client, const TaskMessage& m) { {client.send_motor_driver_queue(m)}; + {client.send_motor_driver_queue_isr(m)}; }; /** diff --git a/include/pipettes/core/gear_motor_tasks.hpp b/include/pipettes/core/gear_motor_tasks.hpp index 292f73b4d..65330b1f1 100644 --- a/include/pipettes/core/gear_motor_tasks.hpp +++ b/include/pipettes/core/gear_motor_tasks.hpp @@ -73,6 +73,8 @@ struct QueueClient : can::message_writer::MessageWriter { void send_motor_driver_queue(const tmc2160::tasks::gear::TaskMessage& m); + void send_motor_driver_queue_isr(const tmc2160::tasks::gear::TaskMessage& m); + void send_move_group_queue( const pipettes::tasks::move_group_task::TaskMessage& m); diff --git a/include/pipettes/core/linear_motor_tasks.hpp b/include/pipettes/core/linear_motor_tasks.hpp index ae20e52d8..3f622d257 100644 --- a/include/pipettes/core/linear_motor_tasks.hpp +++ b/include/pipettes/core/linear_motor_tasks.hpp @@ -134,6 +134,10 @@ struct QueueClient : can::message_writer::MessageWriter { driver_queue->try_write(m); } + void send_motor_driver_queue_isr(const tmc2130::tasks::TaskMessage& m) const { + static_cast(driver_queue->try_write_isr(m)); + } + freertos_message_queue::FreeRTOSMessageQueue* driver_queue{nullptr}; }; @@ -173,6 +177,10 @@ struct QueueClient : can::message_writer::MessageWriter { driver_queue->try_write(m); } + void send_motor_driver_queue_isr(const tmc2160::tasks::TaskMessage& m) const { + static_cast(driver_queue->try_write_isr(m)); + } + freertos_message_queue::FreeRTOSMessageQueue* driver_queue{nullptr}; }; diff --git a/include/pipettes/core/tasks.hpp b/include/pipettes/core/tasks.hpp index 2a53bc335..149beb395 100644 --- a/include/pipettes/core/tasks.hpp +++ b/include/pipettes/core/tasks.hpp @@ -49,6 +49,8 @@ struct QueueClient : can::message_writer::MessageWriter { void send_motor_driver_queue(const tmc2130::tasks::TaskMessage& m); + void send_motor_driver_queue_isr(const tmc2130::tasks::TaskMessage& m); + void send_move_group_queue(const move_group_task::TaskMessage& m); void send_move_status_reporter_queue( diff --git a/pipettes/core/gear_motor_tasks.cpp b/pipettes/core/gear_motor_tasks.cpp index c5caabc5d..5355bf2d3 100644 --- a/pipettes/core/gear_motor_tasks.cpp +++ b/pipettes/core/gear_motor_tasks.cpp @@ -133,6 +133,11 @@ void gear_motor_tasks::QueueClient::send_motor_driver_queue( driver_queue->try_write(m); } +void gear_motor_tasks::QueueClient::send_motor_driver_queue_isr( + const tmc2160::tasks::gear::TaskMessage& m) { + static_cast(driver_queue->try_write_isr(m)); +} + void gear_motor_tasks::QueueClient::send_move_group_queue( const pipettes::tasks::move_group_task::TaskMessage& m) { move_group_queue->try_write(m);