diff --git a/.github/workflows/build-tests.yaml b/.github/workflows/build-tests.yaml index 375c02434..b6fbfd09d 100644 --- a/.github/workflows/build-tests.yaml +++ b/.github/workflows/build-tests.yaml @@ -18,7 +18,7 @@ jobs: build-and-test: name: Run all tests runs-on: "ubuntu-20.04" - timeout-minutes: 20 + timeout-minutes: 10 steps: - name: Checkout ot3-firmware repo uses: actions/checkout@v4 diff --git a/gantry/core/tasks_proto.cpp b/gantry/core/tasks_proto.cpp index 965adbd0f..de020ffc3 100644 --- a/gantry/core/tasks_proto.cpp +++ b/gantry/core/tasks_proto.cpp @@ -55,20 +55,18 @@ static auto eeprom_data_rev_update_builder = /** * Start gantry tasks. */ -auto gantry::tasks::start_tasks( +void gantry::tasks::start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& motion_controller, spi::hardware::SpiDeviceBase& spi_device, tmc2130::configs::TMC2130DriverConfig& driver_configs, motor_hardware_task::MotorHardwareTask& mh_tsk, i2c::hardware::I2CBase& i2c2, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> interfaces::diag0_handler { + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) { auto& can_writer = can_task::start_writer(can_bus); can_task::start_reader(can_bus); - auto& motion = - mc_task_builder.start(5, "motion controller", motion_controller, - ::queues, ::queues, ::queues, ::queues); + auto& motion = mc_task_builder.start(5, "motion controller", + motion_controller, ::queues, ::queues); auto& tmc2130_driver = motor_driver_task_builder.start( 5, "tmc2130 driver", driver_configs, ::queues, spi_task_client); auto& move_group = @@ -118,15 +116,6 @@ auto gantry::tasks::start_tasks( ::queues.usage_storage_queue = &usage_storage_task.get_queue(); mh_tsk.start_task(); - - return gantry::tasks::call_run_diag0_interrupt; -} - -void gantry::tasks::call_run_diag0_interrupt() { - if (gantry::tasks::get_tasks().motion_controller) { - return gantry::tasks::get_tasks() - .motion_controller->run_diag0_interrupt(); - } } gantry::queues::QueueClient::QueueClient(can::ids::NodeId this_fw) @@ -142,11 +131,6 @@ 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 4ba6f156c..95c81ba29 100644 --- a/gantry/core/tasks_rev1.cpp +++ b/gantry/core/tasks_rev1.cpp @@ -54,20 +54,18 @@ static auto tail_accessor = eeprom::dev_data::DevDataTailAccessor{queues}; /** * Start gantry ::tasks. */ -auto gantry::tasks::start_tasks( +void gantry::tasks::start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& motion_controller, spi::hardware::SpiDeviceBase& spi_device, tmc2160::configs::TMC2160DriverConfig& driver_configs, motor_hardware_task::MotorHardwareTask& mh_tsk, i2c::hardware::I2CBase& i2c2, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> interfaces::diag0_handler { + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) { auto& can_writer = can_task::start_writer(can_bus); can_task::start_reader(can_bus); - auto& motion = - mc_task_builder.start(5, "motion controller", motion_controller, - ::queues, ::queues, ::queues, ::queues); + auto& motion = mc_task_builder.start(5, "motion controller", + motion_controller, ::queues, ::queues); auto& tmc2160_driver = motor_driver_task_builder.start( 5, "tmc2160 driver", driver_configs, ::queues, spi_task_client); auto& move_group = @@ -117,15 +115,6 @@ auto gantry::tasks::start_tasks( ::queues.usage_storage_queue = &usage_storage_task.get_queue(); mh_tsk.start_task(); - - return gantry::tasks::call_run_diag0_interrupt; -} - -void gantry::tasks::call_run_diag0_interrupt() { - if (gantry::tasks::get_tasks().motion_controller) { - return gantry::tasks::get_tasks() - .motion_controller->run_diag0_interrupt(); - } } gantry::queues::QueueClient::QueueClient(can::ids::NodeId this_fw) @@ -141,11 +130,6 @@ 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/gantry/firmware/interfaces_proto.cpp b/gantry/firmware/interfaces_proto.cpp index 0c142d197..584fd990e 100644 --- a/gantry/firmware/interfaces_proto.cpp +++ b/gantry/firmware/interfaces_proto.cpp @@ -86,16 +86,10 @@ struct motion_controller::HardwareConfig motor_pins_x { .port = GPIOB, .pin = GPIO_PIN_7, .active_setting = GPIO_PIN_RESET}, - .estop_in = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOA, - .pin = GPIO_PIN_10, - .active_setting = GPIO_PIN_RESET}, - .diag0 = { + .estop_in = { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_5, + .port = GPIOA, + .pin = GPIO_PIN_10, .active_setting = GPIO_PIN_RESET} }; @@ -131,21 +125,15 @@ struct motion_controller::HardwareConfig motor_pins_y { .port = GPIOB, .pin = GPIO_PIN_5, .active_setting = GPIO_PIN_RESET}, - .estop_in = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOA, - .pin = GPIO_PIN_10, - .active_setting = GPIO_PIN_RESET}, - .diag0 = { + .estop_in = { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_5, + .port = GPIOA, + .pin = GPIO_PIN_10, .active_setting = GPIO_PIN_RESET} }; static tmc2130::configs::TMC2130DriverConfig gantry_x_driver_configs{ - .registers = {.gconfig = {.en_pwm_mode = 1, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 1}, .ihold_irun = {.hold_current = 0x2, .run_current = 0x18, .hold_current_delay = 0x7}, @@ -168,7 +156,7 @@ static tmc2130::configs::TMC2130DriverConfig gantry_x_driver_configs{ }}; static tmc2130::configs::TMC2130DriverConfig gantry_y_driver_configs{ - .registers = {.gconfig = {.en_pwm_mode = 1, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 1}, .ihold_irun = {.hold_current = 0x2, .run_current = 0x18, .hold_current_delay = 0x7}, @@ -244,8 +232,8 @@ static stall_check::StallCheck stallcheck( * Handler of motor interrupts. */ static motor_handler::MotorInterruptHandler motor_interrupt( - motor_queue, gantry::queues::get_queues(), gantry::queues::get_queues(), - motor_hardware_iface, stallcheck, update_position_queue); + motor_queue, gantry::queues::get_queues(), motor_hardware_iface, stallcheck, + update_position_queue); static auto encoder_background_timer = motor_encoder::BackgroundTimer(motor_interrupt, motor_hardware_iface); @@ -281,14 +269,13 @@ static constexpr auto can_bit_timings = can::bit_timings::BitTimings<170 * can::bit_timings::MHZ, 100, 500 * can::bit_timings::KHZ, 800>{}; -void interfaces::initialize(diag0_handler* call_diag0_handler) { +void interfaces::initialize() { // Initialize SPI if (initialize_spi(get_axis_type()) != HAL_OK) { Error_Handler(); } - initialize_timer(call_motor_handler, call_diag0_handler, - enc_overflow_callback); + initialize_timer(call_motor_handler, enc_overflow_callback); // Start the can bus canbus.start(can_bit_timings); diff --git a/gantry/firmware/interfaces_rev1.cpp b/gantry/firmware/interfaces_rev1.cpp index d34b82c10..bf0de3359 100644 --- a/gantry/firmware/interfaces_rev1.cpp +++ b/gantry/firmware/interfaces_rev1.cpp @@ -86,16 +86,10 @@ struct motion_controller::HardwareConfig motor_pins_x { .port = GPIOB, .pin = GPIO_PIN_7, .active_setting = GPIO_PIN_RESET}, - .estop_in = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOA, - .pin = GPIO_PIN_10, - .active_setting = GPIO_PIN_RESET}, - .diag0 = { + .estop_in = { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_5, + .port = GPIOA, + .pin = GPIO_PIN_10, .active_setting = GPIO_PIN_RESET} }; @@ -131,21 +125,15 @@ struct motion_controller::HardwareConfig motor_pins_y { .port = GPIOB, .pin = GPIO_PIN_7, .active_setting = GPIO_PIN_RESET}, - .estop_in = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOA, - .pin = GPIO_PIN_10, - .active_setting = GPIO_PIN_RESET}, - .diag0 = { + .estop_in = { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_5, + .port = GPIOA, + .pin = GPIO_PIN_10, .active_setting = GPIO_PIN_RESET} }; static tmc2160::configs::TMC2160DriverConfig motor_driver_config_x{ - .registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 0}, .ihold_irun = {.hold_current = 16, .run_current = 31, .hold_current_delay = 0x7}, @@ -171,7 +159,6 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_config_x{ .freewheel = 0, .pwm_reg = 0x7, .pwm_lim = 0xC}, - .drvconf = {.ot_select = 0}, .glob_scale = {.global_scaler = 0xA7}}, .current_config = { @@ -185,7 +172,7 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_config_x{ }}; static tmc2160::configs::TMC2160DriverConfig motor_driver_config_y{ - .registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 0}, .ihold_irun = {.hold_current = 16, .run_current = 31, .hold_current_delay = 0x7}, @@ -211,7 +198,6 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_config_y{ .freewheel = 0, .pwm_reg = 0x7, .pwm_lim = 0xC}, - .drvconf = {.ot_select = 0}, .glob_scale = {.global_scaler = 0xA7}}, .current_config = { @@ -271,8 +257,8 @@ static stall_check::StallCheck stallcheck( * Handler of motor interrupts. */ static motor_handler::MotorInterruptHandler motor_interrupt( - motor_queue, gantry::queues::get_queues(), gantry::queues::get_queues(), - motor_hardware_iface, stallcheck, update_position_queue); + motor_queue, gantry::queues::get_queues(), motor_hardware_iface, stallcheck, + update_position_queue); static auto encoder_background_timer = motor_encoder::BackgroundTimer(motor_interrupt, motor_hardware_iface); @@ -309,14 +295,13 @@ static constexpr auto can_bit_timings = can::bit_timings::BitTimings<170 * can::bit_timings::MHZ, 100, 500 * can::bit_timings::KHZ, 800>{}; -void interfaces::initialize(diag0_handler* call_diag0_handler) { +void interfaces::initialize() { // Initialize SPI if (initialize_spi(get_axis_type()) != HAL_OK) { Error_Handler(); } - initialize_timer(call_motor_handler, call_diag0_handler, - enc_overflow_callback); + initialize_timer(call_motor_handler, enc_overflow_callback); // Start the can bus canbus.start(can_bit_timings); diff --git a/gantry/firmware/main_proto.cpp b/gantry/firmware/main_proto.cpp index 55d10cc16..cf7c26e03 100644 --- a/gantry/firmware/main_proto.cpp +++ b/gantry/firmware/main_proto.cpp @@ -16,8 +16,6 @@ #include "gantry/core/tasks_proto.hpp" #include "i2c/firmware/i2c_comms.hpp" -static interfaces::diag0_handler call_diag0_handler = nullptr; - static auto i2c_comms2 = i2c::hardware::I2C(); static auto i2c_handles = I2CHandlerStruct{}; @@ -46,11 +44,11 @@ auto main() -> int { app_update_clear_flags(); - interfaces::initialize(&call_diag0_handler); + interfaces::initialize(); i2c_setup(&i2c_handles); i2c_comms2.set_handle(i2c_handles.i2c2); - call_diag0_handler = gantry::tasks::start_tasks( + gantry::tasks::start_tasks( interfaces::get_can_bus(), interfaces::get_motor().motion_controller, interfaces::get_spi(), interfaces::get_driver_config(), interfaces::get_motor_hardware_task(), i2c_comms2, eeprom_hw_iface); diff --git a/gantry/firmware/main_rev1.cpp b/gantry/firmware/main_rev1.cpp index 77b198539..39fed3b73 100644 --- a/gantry/firmware/main_rev1.cpp +++ b/gantry/firmware/main_rev1.cpp @@ -16,8 +16,6 @@ #include "gantry/core/tasks_rev1.hpp" #include "i2c/firmware/i2c_comms.hpp" -static interfaces::diag0_handler call_diag0_handler = nullptr; - static auto i2c_comms2 = i2c::hardware::I2C(); static auto i2c_handles = I2CHandlerStruct{}; @@ -46,11 +44,11 @@ auto main() -> int { app_update_clear_flags(); - interfaces::initialize(&call_diag0_handler); + interfaces::initialize(); i2c_setup(&i2c_handles); i2c_comms2.set_handle(i2c_handles.i2c2); - call_diag0_handler = gantry::tasks::start_tasks( + gantry::tasks::start_tasks( interfaces::get_can_bus(), interfaces::get_motor().motion_controller, interfaces::get_spi(), interfaces::get_driver_config(), interfaces::get_motor_hardware_task(), i2c_comms2, eeprom_hw_iface); diff --git a/gantry/firmware/motor_hardware.c b/gantry/firmware/motor_hardware.c index 637087c76..f48bcb6d7 100644 --- a/gantry/firmware/motor_hardware.c +++ b/gantry/firmware/motor_hardware.c @@ -23,8 +23,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { PC8 ------> Motor Step Pin Enable PA9 ------> Motor Enable Pin - DIAG0 - PC5 ------> Motor Diag0 Pin */ GPIO_InitStruct.Pin = GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -56,12 +54,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; HAL_GPIO_Init(GPIOA, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) &GPIO_InitStruct); - - // Diag0 - GPIO_InitStruct.Pin = GPIO_PIN_5; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); } } SPI_HandleTypeDef hspi2 = { @@ -95,7 +87,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_1); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9); - HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8 | GPIO_PIN_5); + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8); } } @@ -127,7 +119,6 @@ HAL_StatusTypeDef initialize_spi(enum GantryAxisType gantry_type) { static motor_interrupt_callback timer_callback = NULL; static encoder_overflow_callback enc_overflow_callback = NULL; -static diag0_interrupt_callback* diag0_callback = NULL; /** @@ -149,9 +140,6 @@ void MX_GPIO_Init(void) { GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); } // motor timer: 200kHz from @@ -248,16 +236,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { } } -void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - if (GPIO_Pin == GPIO_PIN_5) { - if (diag0_callback != NULL) { - if (*diag0_callback != NULL) { - (*diag0_callback)(); - } - } - } -} - void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim) { if (htim == &htim2) { /* Peripheral clock enable */ @@ -277,10 +255,9 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) { } } -void initialize_timer(motor_interrupt_callback callback, diag0_interrupt_callback* diag0_int_callback, encoder_overflow_callback enc_callback) { +void initialize_timer(motor_interrupt_callback callback, encoder_overflow_callback enc_callback) { timer_callback = callback; enc_overflow_callback = enc_callback; - diag0_callback = diag0_int_callback; MX_GPIO_Init(); MX_TIM7_Init(); Encoder_GPIO_Init(); diff --git a/gantry/firmware/motor_hardware.h b/gantry/firmware/motor_hardware.h index 3a3024ac6..fa2e0ac71 100644 --- a/gantry/firmware/motor_hardware.h +++ b/gantry/firmware/motor_hardware.h @@ -14,12 +14,11 @@ extern TIM_HandleTypeDef htim2; typedef void (*motor_interrupt_callback)(); typedef void (*encoder_overflow_callback)(int32_t); -typedef void (*diag0_interrupt_callback)(); HAL_StatusTypeDef initialize_spi(enum GantryAxisType); void gantry_driver_CLK_init(enum GantryAxisType); -void initialize_timer(motor_interrupt_callback callback, diag0_interrupt_callback* diag0_int_callback, encoder_overflow_callback enc_callback); +void initialize_timer(motor_interrupt_callback callback, encoder_overflow_callback enc_callback); #ifdef __cplusplus } // extern "C" diff --git a/gantry/firmware/stm32g4xx_it.c b/gantry/firmware/stm32g4xx_it.c index 07463106c..b4f589e8f 100644 --- a/gantry/firmware/stm32g4xx_it.c +++ b/gantry/firmware/stm32g4xx_it.c @@ -147,7 +147,6 @@ void FDCAN1_IT0_IRQHandler(void) { */ void TIM7_IRQHandler(void) { HAL_TIM_IRQHandler(&htim7); } void TIM2_IRQHandler(void) { HAL_TIM_IRQHandler(&htim2); } -void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5); } extern void xPortSysTickHandler(void); diff --git a/gantry/simulator/interfaces.cpp b/gantry/simulator/interfaces.cpp index a22db5105..f1a59f0bd 100644 --- a/gantry/simulator/interfaces.cpp +++ b/gantry/simulator/interfaces.cpp @@ -89,16 +89,14 @@ static stall_check::StallCheck stallcheck( * Handler of motor interrupts. */ static motor_handler::MotorInterruptHandler motor_interrupt( - motor_queue, gantry::queues::get_queues(), gantry::queues::get_queues(), - motor_interface, stallcheck, update_position_queue); + motor_queue, gantry::queues::get_queues(), motor_interface, stallcheck, + update_position_queue); static motor_interrupt_driver::MotorInterruptDriver A(motor_queue, motor_interrupt, motor_interface, update_position_queue); -void interfaces::initialize(diag0_handler* call_diag0_handler) { - static_cast(call_diag0_handler); -} +void interfaces::initialize() {} static po::variables_map options{}; diff --git a/gantry/simulator/main.cpp b/gantry/simulator/main.cpp index 77a2d985d..d78b931e2 100644 --- a/gantry/simulator/main.cpp +++ b/gantry/simulator/main.cpp @@ -12,8 +12,6 @@ void signal_handler(int signum) { exit(signum); } -static interfaces::diag0_handler call_diag0_handler = NULL; - int main(int argc, char** argv) { signal(SIGINT, signal_handler); @@ -23,10 +21,10 @@ int main(int argc, char** argv) { return pcTaskGetName(xTaskGetCurrentTaskHandle()); }); - interfaces::initialize(&call_diag0_handler); + interfaces::initialize(); interfaces::initialize_sim(argc, argv); - call_diag0_handler = gantry::tasks::start_tasks( + gantry::tasks::start_tasks( interfaces::get_can_bus(), interfaces::get_motor().motion_controller, interfaces::get_spi(), interfaces::get_driver_config(), interfaces::get_motor_hardware_task(), *interfaces::get_sim_i2c2(), diff --git a/gripper/core/tasks.cpp b/gripper/core/tasks.cpp index 587bd4b64..46c9c811e 100644 --- a/gripper/core/tasks.cpp +++ b/gripper/core/tasks.cpp @@ -62,7 +62,7 @@ static auto eeprom_data_rev_update_builder = /** * Start gripper tasks. */ -auto gripper_tasks::start_tasks( +void gripper_tasks::start_tasks( can::bus::CanBus& can_bus, motor_class::Motor& z_motor, brushed_motor::BrushedMotor& grip_motor, @@ -72,8 +72,7 @@ auto gripper_tasks::start_tasks( sensors::hardware::SensorHardwareBase& sensor_hardware, eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface, motor_hardware_task::MotorHardwareTask& zmh_tsk, - motor_hardware_task::MotorHardwareTask& gmh_tsk) - -> z_motor_iface::diag0_handler { + motor_hardware_task::MotorHardwareTask& gmh_tsk) { auto& can_writer = can_task::start_writer(can_bus); can_task::start_reader(can_bus); tasks.can_writer = &can_writer; @@ -132,8 +131,8 @@ auto gripper_tasks::start_tasks( queues.capacitive_sensor_queue_rear = &capacitive_sensor_task_rear.get_queue(); - auto diag0_handler = z_tasks::start_task( - z_motor, spi_device, driver_configs, tasks, queues, tail_accessor); + z_tasks::start_task(z_motor, spi_device, driver_configs, tasks, queues, + tail_accessor); g_tasks::start_task(grip_motor, tasks, queues, tail_accessor); @@ -142,8 +141,6 @@ auto gripper_tasks::start_tasks( zmh_tsk.start_task(); gmh_tsk.start_task(); - - return diag0_handler; } gripper_tasks::QueueClient::QueueClient(can::ids::NodeId this_fw) diff --git a/gripper/core/tasks_z.cpp b/gripper/core/tasks_z.cpp index ce5f9b306..43432ea46 100644 --- a/gripper/core/tasks_z.cpp +++ b/gripper/core/tasks_z.cpp @@ -34,16 +34,15 @@ static auto z_usage_storage_task_builder = freertos_task::TaskStarter<512, usage_storage_task::UsageStorageTask>{}; #endif -auto z_tasks::start_task( +void z_tasks::start_task( motor_class::Motor& z_motor, spi::hardware::SpiDeviceBase& spi_device, tmc2130::configs::TMC2130DriverConfig& driver_configs, AllTask& gripper_tasks, gripper_tasks::QueueClient& main_queues, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) -> z_motor_iface::diag0_handler { - auto& motion = - mc_task_builder.start(5, "z mc", z_motor.motion_controller, z_queues, - z_queues, z_queues, z_queues); + tail_accessor) { + auto& motion = mc_task_builder.start(5, "z mc", z_motor.motion_controller, + z_queues, z_queues); auto& move_group = move_group_task_builder.start(5, "move group", z_queues, z_queues); auto& tmc2130_driver = motor_driver_task_builder.start( @@ -78,14 +77,6 @@ auto z_tasks::start_task( z_queues.z_usage_storage_queue = &z_usage_storage_task.get_queue(); #endif spi_task_client.set_queue(&spi_task.get_queue()); - - return z_tasks::call_run_diag0_interrupt; -} - -void z_tasks::call_run_diag0_interrupt() { - if (get_all_tasks().motion_controller) { - return get_all_tasks().motion_controller->run_diag0_interrupt(); - } } z_tasks::QueueClient::QueueClient() @@ -101,11 +92,6 @@ 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/gripper/firmware/interfaces_z_motor.cpp b/gripper/firmware/interfaces_z_motor.cpp index 662c87246..381d0e55e 100644 --- a/gripper/firmware/interfaces_z_motor.cpp +++ b/gripper/firmware/interfaces_z_motor.cpp @@ -103,13 +103,7 @@ struct motion_controller::HardwareConfig motor_pins { .port = ESTOP_IN_PORT, .pin = ESTOP_IN_PIN, .active_setting = GPIO_PIN_RESET}, - .diag0 = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOB, - .pin = GPIO_PIN_2, - .active_setting = GPIO_PIN_RESET}, - .ebrake = ebrake + .ebrake = ebrake, }; /** @@ -125,7 +119,6 @@ static motor_hardware::MotorHardware motor_hardware_iface(motor_pins, &htim7, */ static tmc2130::configs::TMC2130DriverConfig MotorDriverConfigurations{ .registers = {.gconfig = {.en_pwm_mode = 0x0, - .diag0_error = 1, .stop_enable = use_stop_enable}, .ihold_irun = {.hold_current = 0x2, // 0.177A .run_current = 0xA, // 0.648A @@ -218,13 +211,12 @@ extern "C" void call_enc_handler(int32_t direction) { motor_hardware_iface.encoder_overflow(direction); } -void z_motor_iface::initialize(diag0_handler* call_diag0_handler) { +void z_motor_iface::initialize() { if (initialize_spi() != HAL_OK) { Error_Handler(); } initialize_hardware_z(); - set_z_motor_timer_callback(call_motor_handler, call_diag0_handler, - call_enc_handler); + set_z_motor_timer_callback(call_motor_handler, call_enc_handler); encoder_background_timer.start(); } diff --git a/gripper/firmware/main_proto.cpp b/gripper/firmware/main_proto.cpp index 5ff96f001..b34d83acf 100644 --- a/gripper/firmware/main_proto.cpp +++ b/gripper/firmware/main_proto.cpp @@ -25,8 +25,6 @@ #include "i2c/firmware/i2c_comms.hpp" #include "sensors/firmware/sensor_hardware.hpp" -static z_motor_iface::diag0_handler call_diag0_handler = nullptr; - static auto iWatchdog = iwdg::IndependentWatchDog{}; /** @@ -97,7 +95,7 @@ auto main() -> int { app_update_clear_flags(); - z_motor_iface::initialize(&call_diag0_handler); + z_motor_iface::initialize(); grip_motor_iface::initialize(); i2c_setup(&i2c_handles); @@ -105,7 +103,7 @@ auto main() -> int { i2c_comms3.set_handle(i2c_handles.i2c3); canbus.start(can_bit_timings); - call_diag0_handler = gripper_tasks::start_tasks( + gripper_tasks::start_tasks( canbus, z_motor_iface::get_z_motor(), grip_motor_iface::get_grip_motor(), z_motor_iface::get_spi(), z_motor_iface::get_tmc2130_driver_configs(), i2c_comms2, i2c_comms3, diff --git a/gripper/firmware/main_rev1.cpp b/gripper/firmware/main_rev1.cpp index f07597938..62572ef6a 100644 --- a/gripper/firmware/main_rev1.cpp +++ b/gripper/firmware/main_rev1.cpp @@ -26,8 +26,6 @@ #include "i2c/firmware/i2c_comms.hpp" #include "sensors/firmware/sensor_hardware.hpp" -static z_motor_iface::diag0_handler call_diag0_handler = nullptr; - static auto iWatchdog = iwdg::IndependentWatchDog{}; /** @@ -108,7 +106,7 @@ auto main() -> int { app_update_clear_flags(); - z_motor_iface::initialize(&call_diag0_handler); + z_motor_iface::initialize(); grip_motor_iface::initialize(); i2c_setup(&i2c_handles); @@ -116,7 +114,7 @@ auto main() -> int { i2c_comms3.set_handle(i2c_handles.i2c3); canbus.start(can_bit_timings); - call_diag0_handler = gripper_tasks::start_tasks( + gripper_tasks::start_tasks( canbus, z_motor_iface::get_z_motor(), grip_motor_iface::get_grip_motor(), z_motor_iface::get_spi(), z_motor_iface::get_tmc2130_driver_configs(), i2c_comms2, i2c_comms3, diff --git a/gripper/firmware/motor_hardware.h b/gripper/firmware/motor_hardware.h index 4df6dbd0a..37bce25ca 100644 --- a/gripper/firmware/motor_hardware.h +++ b/gripper/firmware/motor_hardware.h @@ -32,7 +32,6 @@ extern TIM_HandleTypeDef htim8; typedef void (*motor_interrupt_callback)(); typedef void (*z_encoder_overflow_callback)(int32_t); -typedef void (*diag0_interrupt_callback)(); HAL_StatusTypeDef initialize_spi(); @@ -40,7 +39,6 @@ void initialize_hardware_z(); void set_z_motor_timer_callback( motor_interrupt_callback callback, - diag0_interrupt_callback* diag0_int_callback, z_encoder_overflow_callback enc_callback); diff --git a/gripper/firmware/motor_hardware_shared.c b/gripper/firmware/motor_hardware_shared.c index f6118af8b..997322797 100644 --- a/gripper/firmware/motor_hardware_shared.c +++ b/gripper/firmware/motor_hardware_shared.c @@ -3,7 +3,6 @@ static motor_interrupt_callback timer_callback = NULL; static z_encoder_overflow_callback z_enc_overflow_callback = NULL; -static diag0_interrupt_callback* diag0_callback = NULL; static brushed_motor_interrupt_callback brushed_timer_callback = NULL; static encoder_overflow_callback gripper_enc_overflow_callback = NULL; static encoder_idle_state_callback gripper_enc_idle_state_overflow_callback = @@ -11,19 +10,11 @@ static encoder_idle_state_callback gripper_enc_idle_state_overflow_callback = static stopwatch_overflow_callback gripper_force_stopwatch_overflow_callback = NULL; -void MX_GPIO_Init(void) { - HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI2_IRQn); -} - void set_z_motor_timer_callback( motor_interrupt_callback callback, - diag0_interrupt_callback* diag0_int_callback, z_encoder_overflow_callback enc_callback) { timer_callback = callback; z_enc_overflow_callback = enc_callback; - diag0_callback = diag0_int_callback; - MX_GPIO_Init(); } void set_brushed_motor_timer_callback( @@ -221,14 +212,9 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef* htim) { } } + void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - if (GPIO_Pin == GPIO_PIN_2) { - if (diag0_callback != NULL) { - if (*diag0_callback != NULL) { - (*diag0_callback)(); - } - } - } else if (GPIO_Pin == ESTOP_IN_PIN) { + if (GPIO_Pin == ESTOP_IN_PIN) { #if PCBA_PRIMARY_REVISION != 'b' && PCBA_PRIMARY_REVISION != 'a' HAL_GPIO_WritePin(EBRAKE_PORT, EBRAKE_PIN, GPIO_PIN_RESET); #endif diff --git a/gripper/firmware/stm32g4xx_it.c b/gripper/firmware/stm32g4xx_it.c index 6a90023e6..2051ebc6b 100644 --- a/gripper/firmware/stm32g4xx_it.c +++ b/gripper/firmware/stm32g4xx_it.c @@ -198,11 +198,6 @@ void TIM7_IRQHandler(void) { call_motor_handler(); } -__attribute__((section(".ccmram"))) -void EXTI2_IRQHandler(void) { - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); -} - /** * @brief This function handles EXTI line[15:10] interrupts. */ diff --git a/gripper/firmware/utility_gpio.c b/gripper/firmware/utility_gpio.c index 9c25e0b46..551f5cc12 100644 --- a/gripper/firmware/utility_gpio.c +++ b/gripper/firmware/utility_gpio.c @@ -108,8 +108,6 @@ static void z_motor_gpio_init(void) { PB1 ------> Motor Step Pin Enable PA9 ------> Motor Enable Pin - Diag0 - PB2 ------> Motor Diag0 Pin */ GPIO_InitStruct.Pin = Z_MOT_DIR_PIN | Z_MOT_STEP_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; @@ -121,11 +119,6 @@ static void z_motor_gpio_init(void) { GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; HAL_GPIO_Init(Z_MOT_ENABLE_PORT, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) &GPIO_InitStruct); - - GPIO_InitStruct.Pin = Z_MOT_DIAG0_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(Z_MOT_STEPDIR_PORT, &GPIO_InitStruct); } #if PCBA_PRIMARY_REVISION != 'b' && PCBA_PRIMARY_REVISION != 'a' diff --git a/gripper/simulator/interfaces.cpp b/gripper/simulator/interfaces.cpp index bdc4ce326..f3dfd2a14 100644 --- a/gripper/simulator/interfaces.cpp +++ b/gripper/simulator/interfaces.cpp @@ -94,9 +94,8 @@ static stall_check::StallCheck stallcheck( * Handler of motor interrupts. */ static motor_handler::MotorInterruptHandler motor_interrupt( - motor_queue, gripper_tasks::z_tasks::get_queues(), - gripper_tasks::z_tasks::get_queues(), motor_interface, stallcheck, - update_position_queue); + motor_queue, gripper_tasks::z_tasks::get_queues(), motor_interface, + stallcheck, update_position_queue); static motor_interrupt_driver::MotorInterruptDriver A(motor_queue, motor_interrupt, @@ -136,8 +135,7 @@ static brushed_motor_handler::BrushedMotorInterruptHandler static brushed_motor_interrupt_driver::BrushedMotorInterruptDriver G( brushed_motor_queue, brushed_motor_interrupt, brushed_motor_hardware_iface); -void z_motor_iface::initialize(diag0_handler* call_diag0_handler) { - static_cast(call_diag0_handler); +void z_motor_iface::initialize() { motor_interface.provide_mech_config(z_motor_sys_config); }; diff --git a/gripper/simulator/main.cpp b/gripper/simulator/main.cpp index c3f235244..831f2673d 100644 --- a/gripper/simulator/main.cpp +++ b/gripper/simulator/main.cpp @@ -21,8 +21,6 @@ namespace po = boost::program_options; -static z_motor_iface::diag0_handler call_diag0_handler = nullptr; - void signal_handler(int signum) { LOG("Interrupt signal (%d) received.", signum); exit(signum); @@ -113,9 +111,9 @@ int main(int argc, char** argv) { auto i2c3 = std::make_shared(i2c_device_map); static auto canbus = can::sim::bus::SimCANBus(can::sim::transport::create(options)); - z_motor_iface::initialize(&call_diag0_handler); + z_motor_iface::initialize(); grip_motor_iface::initialize(); - call_diag0_handler = gripper_tasks::start_tasks( + gripper_tasks::start_tasks( canbus, z_motor_iface::get_z_motor(), grip_motor_iface::get_grip_motor(), z_motor_iface::get_spi(), z_motor_iface::get_tmc2130_driver_configs(), i2c2, *i2c3, diff --git a/head/core/can_task.cpp b/head/core/can_task.cpp index dcb1f3359..6cc432b07 100644 --- a/head/core/can_task.cpp +++ b/head/core/can_task.cpp @@ -28,8 +28,7 @@ using MotorDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::motor::MotorHandler, can::messages::ReadMotorDriverRegister, can::messages::WriteMotorDriverRegister, - can::messages::WriteMotorCurrentRequest, - can::messages::ReadMotorDriverErrorStatusRequest>; + can::messages::WriteMotorCurrentRequest>; using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::move_group::MoveGroupHandler< head_tasks::MotorQueueClient>, diff --git a/head/core/tasks_proto.cpp b/head/core/tasks_proto.cpp index c3c09d968..2690550ca 100644 --- a/head/core/tasks_proto.cpp +++ b/head/core/tasks_proto.cpp @@ -78,25 +78,10 @@ static auto eeprom_data_rev_update_builder = freertos_task::TaskStarter<512, eeprom::data_rev_task::UpdateDataRevTask>{}; static auto tail_accessor = eeprom::dev_data::DevDataTailAccessor{head_queues}; - -void call_run_diag0_z_interrupt() { - if (head_tasks::get_left_tasks().motion_controller) { - return head_tasks::get_left_tasks() - .motion_controller->run_diag0_interrupt(); - } -} - -void call_run_diag0_a_interrupt() { - if (head_tasks::get_right_tasks().motion_controller) { - return head_tasks::get_right_tasks() - .motion_controller->run_diag0_interrupt(); - } -} - /** * Start head tasks. */ -auto head_tasks::start_tasks( +void head_tasks::start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& left_motion_controller, @@ -110,8 +95,7 @@ auto head_tasks::start_tasks( motor_hardware_task::MotorHardwareTask& rmh_tsk, motor_hardware_task::MotorHardwareTask& lmh_tsk, i2c::hardware::I2CBase& i2c3, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> std::tuple { + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) { // Start the head tasks auto& can_writer = can_task::start_writer(can_bus); can_task::start_reader(can_bus); @@ -157,8 +141,7 @@ auto head_tasks::start_tasks( // Start the left motor tasks auto& left_motion = left_mc_task_builder.start( - 5, "left mc", left_motion_controller, left_queues, left_queues, - left_queues, left_queues); + 5, "left mc", left_motion_controller, left_queues, left_queues); auto& left_tmc2130_driver = left_motor_driver_task_builder.start( 5, "left motor driver", left_driver_configs, left_queues, spi3_task_client); @@ -187,8 +170,7 @@ auto head_tasks::start_tasks( // Start the right motor tasks auto& right_motion = right_mc_task_builder.start( - 5, "right mc", right_motion_controller, right_queues, right_queues, - right_queues, right_queues); + 5, "right mc", right_motion_controller, right_queues, right_queues); auto& right_tmc2130_driver = right_motor_driver_task_builder.start( 5, "right motor driver", right_driver_configs, right_queues, spi2_task_client); @@ -217,9 +199,6 @@ auto head_tasks::start_tasks( right_queues.move_status_report_queue = &right_move_status_reporter.get_queue(); right_queues.usage_storage_queue = &right_usage_storage_task.get_queue(); - - return std::make_tuple(call_run_diag0_z_interrupt, - call_run_diag0_a_interrupt); } // Implementation of HeadQueueClient @@ -252,11 +231,6 @@ 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 c86699d71..2cf2d803d 100644 --- a/head/core/tasks_rev1.cpp +++ b/head/core/tasks_rev1.cpp @@ -83,25 +83,10 @@ static auto right_usage_storage_task_builder = static auto eeprom_data_rev_update_builder = freertos_task::TaskStarter<512, eeprom::data_rev_task::UpdateDataRevTask>{}; #endif - -void call_run_diag0_z_interrupt() { - if (head_tasks::get_left_tasks().motion_controller) { - return head_tasks::get_left_tasks() - .motion_controller->run_diag0_interrupt(); - } -} - -void call_run_diag0_a_interrupt() { - if (head_tasks::get_right_tasks().motion_controller) { - return head_tasks::get_right_tasks() - .motion_controller->run_diag0_interrupt(); - } -} - /** * Start head tasks. */ -auto head_tasks::start_tasks( +void head_tasks::start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& left_motion_controller, @@ -115,8 +100,7 @@ auto head_tasks::start_tasks( motor_hardware_task::MotorHardwareTask& rmh_tsk, motor_hardware_task::MotorHardwareTask& lmh_tsk, i2c::hardware::I2CBase& i2c3, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> std::tuple { + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) { // Start the head tasks auto& can_writer = can_task::start_writer(can_bus); can_task::start_reader(can_bus); @@ -162,8 +146,7 @@ auto head_tasks::start_tasks( #endif // Start the left motor tasks auto& left_motion = left_mc_task_builder.start( - 5, "left mc", left_motion_controller, left_queues, left_queues, - left_queues, left_queues); + 5, "left mc", left_motion_controller, left_queues, left_queues); auto& left_tmc2160_driver = left_motor_driver_task_builder.start( 5, "left motor driver", left_driver_configs, left_queues, spi3_task_client); @@ -200,8 +183,7 @@ auto head_tasks::start_tasks( // Start the right motor tasks auto& right_motion = right_mc_task_builder.start( - 5, "right mc", right_motion_controller, right_queues, right_queues, - right_queues, right_queues); + 5, "right mc", right_motion_controller, right_queues, right_queues); auto& right_tmc2160_driver = right_motor_driver_task_builder.start( 5, "right motor driver", right_driver_configs, right_queues, spi2_task_client); @@ -238,9 +220,6 @@ auto head_tasks::start_tasks( #if PCBA_PRIMARY_REVISION != 'b' right_queues.usage_storage_queue = &right_usage_storage_task.get_queue(); #endif - - return std::make_tuple(call_run_diag0_z_interrupt, - call_run_diag0_a_interrupt); } // Implementation of HeadQueueClient @@ -277,11 +256,6 @@ 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/head/firmware/main_proto.cpp b/head/firmware/main_proto.cpp index 614af1142..d3ba07641 100644 --- a/head/firmware/main_proto.cpp +++ b/head/firmware/main_proto.cpp @@ -1,7 +1,6 @@ #include #include #include -#include // clang-format off #include "FreeRTOS.h" @@ -41,9 +40,6 @@ static auto iWatchdog = iwdg::IndependentWatchDog{}; -static head_tasks::diag0_handler call_diag0_z_handler = nullptr; -static head_tasks::diag0_handler call_diag0_a_handler = nullptr; - static auto can_bus_1 = can::hal::bus::HalCanBus( can_get_device_handle(), gpio::PinConfig{// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) @@ -146,16 +142,10 @@ struct motor_hardware::HardwareConfig pin_configurations_left { .port = GPIOA, .pin = GPIO_PIN_8, .active_setting = GPIO_PIN_RESET}, - .estop_in = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOB, - .pin = GPIO_PIN_4, - .active_setting = GPIO_PIN_RESET}, - .diag0 = { + .estop_in = { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_13, + .port = GPIOB, + .pin = GPIO_PIN_4, .active_setting = GPIO_PIN_RESET} }; @@ -196,16 +186,10 @@ struct motor_hardware::HardwareConfig pin_configurations_right { .port = GPIOA, .pin = GPIO_PIN_8, .active_setting = GPIO_PIN_RESET}, - .estop_in = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOB, - .pin = GPIO_PIN_4, - .active_setting = GPIO_PIN_RESET}, - .diag0 = { + .estop_in = { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_15, + .port = GPIOB, + .pin = GPIO_PIN_4, .active_setting = GPIO_PIN_RESET} }; @@ -213,7 +197,7 @@ struct motor_hardware::HardwareConfig pin_configurations_right { static tmc2130::configs::TMC2130DriverConfig motor_driver_configs_right{ .registers = { - .gconfig = {.en_pwm_mode = 1, .diag0_error = 1}, + .gconfig = {.en_pwm_mode = 1}, .ihold_irun = {.hold_current = 0xB, .run_current = 0x19, .hold_current_delay = 0x7}, @@ -240,7 +224,7 @@ static tmc2130::configs::TMC2130DriverConfig motor_driver_configs_right{ static tmc2130::configs::TMC2130DriverConfig motor_driver_configs_left{ .registers = { - .gconfig = {.en_pwm_mode = 1, .diag0_error = 1}, + .gconfig = {.en_pwm_mode = 1}, .ihold_irun = {.hold_current = 0xB, .run_current = 0x19, .hold_current_delay = 0x7}, @@ -284,9 +268,8 @@ static stall_check::StallCheck stallcheck_right( static motor_hardware::MotorHardware motor_hardware_right( pin_configurations_right, &htim7, &htim2, right_usage_config); static motor_handler::MotorInterruptHandler motor_interrupt_right( - motor_queue_right, head_tasks::get_right_queues(), - head_tasks::get_right_queues(), motor_hardware_right, stallcheck_right, - update_position_queue_right); + motor_queue_right, head_tasks::get_right_queues(), motor_hardware_right, + stallcheck_right, update_position_queue_right); static auto encoder_background_timer_right = motor_encoder::BackgroundTimer(motor_interrupt_right, motor_hardware_right); @@ -306,9 +289,8 @@ static stall_check::StallCheck stallcheck_left( static motor_hardware::MotorHardware motor_hardware_left( pin_configurations_left, &htim7, &htim3, left_usage_config); static motor_handler::MotorInterruptHandler motor_interrupt_left( - motor_queue_left, head_tasks::get_left_queues(), - head_tasks::get_left_queues(), motor_hardware_left, stallcheck_left, - update_position_queue_left); + motor_queue_left, head_tasks::get_left_queues(), motor_hardware_left, + stallcheck_left, update_position_queue_left); static auto encoder_background_timer_left = motor_encoder::BackgroundTimer(motor_interrupt_left, motor_hardware_left); @@ -411,8 +393,7 @@ auto main() -> int { app_update_clear_flags(); initialize_timer(motor_callback_glue, left_enc_overflow_callback_glue, - right_enc_overflow_callback_glue, &call_diag0_z_handler, - &call_diag0_a_handler); + right_enc_overflow_callback_glue); if (initialize_spi(&hspi2) != HAL_OK) { Error_Handler(); @@ -426,12 +407,12 @@ auto main() -> int { i2c_setup(&i2c_handles); i2c_comms3.set_handle(i2c_handles.i2c3); - std::tie(call_diag0_z_handler, call_diag0_a_handler) = - head_tasks::start_tasks(can_bus_1, motor_left.motion_controller, - motor_right.motion_controller, psd, spi_comms2, - spi_comms3, motor_driver_configs_left, - motor_driver_configs_right, rmh_tsk, lmh_tsk, - i2c_comms3, eeprom_hw_iface); + + head_tasks::start_tasks(can_bus_1, motor_left.motion_controller, + motor_right.motion_controller, psd, spi_comms2, + spi_comms3, motor_driver_configs_left, + motor_driver_configs_right, rmh_tsk, lmh_tsk, + i2c_comms3, eeprom_hw_iface); timer_for_notifier.start(); diff --git a/head/firmware/main_rev1.cpp b/head/firmware/main_rev1.cpp index e6d17776f..ce5849129 100644 --- a/head/firmware/main_rev1.cpp +++ b/head/firmware/main_rev1.cpp @@ -1,7 +1,6 @@ #include #include #include -#include // clang-format off #include "FreeRTOS.h" @@ -41,9 +40,6 @@ static auto iWatchdog = iwdg::IndependentWatchDog{}; -static head_tasks::diag0_handler call_diag0_z_handler = nullptr; -static head_tasks::diag0_handler call_diag0_a_handler = nullptr; - static auto can_bus_1 = can::hal::bus::HalCanBus( can_get_device_handle(), gpio::PinConfig{// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) @@ -158,12 +154,6 @@ struct motor_hardware::HardwareConfig pin_configurations_left { .port = GPIOB, .pin = GPIO_PIN_4, .active_setting = GPIO_PIN_RESET}, - .diag0 = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_13, - .active_setting = GPIO_PIN_RESET}, .ebrake = gpio::PinConfig { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) .port = GPIOB, .pin = GPIO_PIN_5, .active_setting = GPIO_PIN_RESET @@ -208,12 +198,6 @@ struct motor_hardware::HardwareConfig pin_configurations_right { .port = GPIOB, .pin = GPIO_PIN_4, .active_setting = GPIO_PIN_RESET}, - .diag0 = - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_15, - .active_setting = GPIO_PIN_RESET}, .ebrake = gpio::PinConfig { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) .port = GPIOB, .pin = GPIO_PIN_0, .active_setting = GPIO_PIN_RESET @@ -222,7 +206,7 @@ struct motor_hardware::HardwareConfig pin_configurations_right { // TODO clean up the head main file by using interfaces. static tmc2160::configs::TMC2160DriverConfig motor_driver_configs_right{ - .registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 0}, .ihold_irun = {.hold_current = 16, .run_current = 31, .hold_current_delay = 0x7}, @@ -248,7 +232,7 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_configs_right{ }}; static tmc2160::configs::TMC2160DriverConfig motor_driver_configs_left{ - .registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 0}, .ihold_irun = {.hold_current = 16, .run_current = 31, .hold_current_delay = 0x7}, @@ -302,9 +286,8 @@ static stall_check::StallCheck stallcheck_right( static motor_hardware::MotorHardware motor_hardware_right( pin_configurations_right, &htim7, &htim2, right_usage_config); static motor_handler::MotorInterruptHandler motor_interrupt_right( - motor_queue_right, head_tasks::get_right_queues(), - head_tasks::get_right_queues(), motor_hardware_right, stallcheck_right, - update_position_queue_right); + motor_queue_right, head_tasks::get_right_queues(), motor_hardware_right, + stallcheck_right, update_position_queue_right); static auto encoder_background_timer_right = motor_encoder::BackgroundTimer(motor_interrupt_right, motor_hardware_right); @@ -328,9 +311,8 @@ static stall_check::StallCheck stallcheck_left( static motor_hardware::MotorHardware motor_hardware_left( pin_configurations_left, &htim7, &htim3, left_usage_config); static motor_handler::MotorInterruptHandler motor_interrupt_left( - motor_queue_left, head_tasks::get_left_queues(), - head_tasks::get_left_queues(), motor_hardware_left, stallcheck_left, - update_position_queue_left); + motor_queue_left, head_tasks::get_left_queues(), motor_hardware_left, + stallcheck_left, update_position_queue_left); static auto encoder_background_timer_left = motor_encoder::BackgroundTimer(motor_interrupt_left, motor_hardware_left); @@ -436,8 +418,7 @@ auto main() -> int { app_update_clear_flags(); initialize_timer(motor_callback_glue, left_enc_overflow_callback_glue, - right_enc_overflow_callback_glue, &call_diag0_z_handler, - &call_diag0_a_handler); + right_enc_overflow_callback_glue); i2c_setup(&i2c_handles); i2c_comms3.set_handle(i2c_handles.i2c3); @@ -451,12 +432,11 @@ auto main() -> int { utility_gpio_init(); can_bus_1.start(can_bit_timings); - std::tie(call_diag0_z_handler, call_diag0_a_handler) = - head_tasks::start_tasks(can_bus_1, motor_left.motion_controller, - motor_right.motion_controller, psd, spi_comms2, - spi_comms3, motor_driver_configs_left, - motor_driver_configs_right, rmh_tsk, lmh_tsk, - i2c_comms3, eeprom_hw_iface); + head_tasks::start_tasks(can_bus_1, motor_left.motion_controller, + motor_right.motion_controller, psd, spi_comms2, + spi_comms3, motor_driver_configs_left, + motor_driver_configs_right, rmh_tsk, lmh_tsk, + i2c_comms3, eeprom_hw_iface); timer_for_notifier.start(); diff --git a/head/firmware/motor_hardware.h b/head/firmware/motor_hardware.h index 2cce7382f..e01e68d85 100644 --- a/head/firmware/motor_hardware.h +++ b/head/firmware/motor_hardware.h @@ -14,14 +14,11 @@ extern TIM_HandleTypeDef htim3; typedef void (*motor_interrupt_callback)(); typedef void (*encoder_overflow_callback)(int32_t); -typedef void (*diag0_interrupt_callback)(); HAL_StatusTypeDef initialize_spi(SPI_HandleTypeDef* hspi); void initialize_timer(motor_interrupt_callback callback, encoder_overflow_callback left_enc_overflow_callback, - encoder_overflow_callback right_enc_overflow_callback, - diag0_interrupt_callback* diag0_z_int_callback, - diag0_interrupt_callback* diag0_a_int_callback); + encoder_overflow_callback right_enc_overflow_callback); void initialize_rev_specific_pins(); #ifdef __cplusplus diff --git a/head/firmware/motor_hardware_common.c b/head/firmware/motor_hardware_common.c index e895252fe..d1313df4d 100644 --- a/head/firmware/motor_hardware_common.c +++ b/head/firmware/motor_hardware_common.c @@ -21,8 +21,6 @@ TIM_HandleTypeDef htim3 = { motor_interrupt_callback motor_callback = NULL; encoder_overflow_callback left_enc_overflow_callback = NULL; encoder_overflow_callback right_enc_overflow_callback = NULL; -static diag0_interrupt_callback* diag0_z_callback = NULL; -static diag0_interrupt_callback* diag0_a_callback = NULL; void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) { GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -57,14 +55,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) { GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) &GPIO_InitStruct); - - // A motor diag0 - GPIO_InitStruct.Pin = GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) - &GPIO_InitStruct); } else if (hspi->Instance == SPI3) { @@ -101,14 +91,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) { GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) &GPIO_InitStruct); - - // Z motor diag0 - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) - &GPIO_InitStruct); } } @@ -247,9 +229,6 @@ void MX_GPIO_Init(void) { __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); initialize_rev_specific_pins(); - - HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); } #if PCBA_PRIMARY_REVISION == 'b' || PCBA_PRIMARY_REVISION == 'a' @@ -366,31 +345,15 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { // disable both left and right enable pins HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_RESET); - } else if (GPIO_Pin == GPIO_PIN_13) { - if (diag0_z_callback != NULL) { - if (*diag0_z_callback != NULL) { - (*diag0_z_callback)(); - } - } - } else if (GPIO_Pin == GPIO_PIN_15) { - if (diag0_a_callback != NULL) { - if (*diag0_a_callback != NULL) { - (*diag0_a_callback)(); - } - } } } void initialize_timer(motor_interrupt_callback callback, encoder_overflow_callback l_f_callback, - encoder_overflow_callback r_f_callback, - diag0_interrupt_callback* diag0_z_int_callback, - diag0_interrupt_callback* diag0_a_int_callback) { + encoder_overflow_callback r_f_callback) { motor_callback = callback; left_enc_overflow_callback = l_f_callback; right_enc_overflow_callback = r_f_callback; - diag0_z_callback = diag0_z_int_callback; - diag0_a_callback = diag0_a_int_callback; MX_GPIO_Init(); Encoder_GPIO_Init(); encoder_init(&htim2); diff --git a/head/firmware/stm32g4xx_it.c b/head/firmware/stm32g4xx_it.c index 929586b89..6e031a2bf 100644 --- a/head/firmware/stm32g4xx_it.c +++ b/head/firmware/stm32g4xx_it.c @@ -177,14 +177,6 @@ void TIM2_IRQHandler(void) { HAL_TIM_IRQHandler(&htim2); } */ void TIM3_IRQHandler(void) { HAL_TIM_IRQHandler(&htim3); } -void EXTI15_10_IRQHandler(void) { - if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_13)) { - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13); - } else if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_15)) { - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_15); - } -} - extern void xPortSysTickHandler(void); void SysTick_Handler(void) { HAL_IncTick(); diff --git a/head/simulator/main.cpp b/head/simulator/main.cpp index 907f60bdb..79db8f736 100644 --- a/head/simulator/main.cpp +++ b/head/simulator/main.cpp @@ -94,9 +94,8 @@ static stall_check::StallCheck stallcheck_right( linear_config.get_usteps_per_mm() / 1000.0F, utils::STALL_THRESHOLD_UM); static motor_handler::MotorInterruptHandler motor_interrupt_right( - motor_queue_right, head_tasks::get_right_queues(), - head_tasks::get_right_queues(), motor_interface_right, stallcheck_right, - update_position_queue_right); + motor_queue_right, head_tasks::get_right_queues(), motor_interface_right, + stallcheck_right, update_position_queue_right); static stall_check::StallCheck stallcheck_left( linear_config.get_encoder_pulses_per_mm() / 1000.0F, @@ -118,9 +117,8 @@ static motor_class::Motor motor_right{ motor_queue_right, update_position_queue_right}; static motor_handler::MotorInterruptHandler motor_interrupt_left( - motor_queue_left, head_tasks::get_left_queues(), - head_tasks::get_left_queues(), motor_interface_left, stallcheck_left, - update_position_queue_left); + motor_queue_left, head_tasks::get_left_queues(), motor_interface_left, + stallcheck_left, update_position_queue_left); static motor_class::Motor motor_left{ motor_sys_config, motor_interface_left, diff --git a/include/can/core/ids.hpp b/include/can/core/ids.hpp index f04ce6a97..8bcee3c42 100644 --- a/include/can/core/ids.hpp +++ b/include/can/core/ids.hpp @@ -64,8 +64,6 @@ enum class MessageId { write_motor_current_request = 0x33, read_motor_current_request = 0x34, read_motor_current_response = 0x35, - read_motor_driver_error_status_request = 0x36, - read_motor_driver_error_status_response = 0x37, set_brushed_motor_vref_request = 0x40, set_brushed_motor_pwm_request = 0x41, gripper_grip_request = 0x42, @@ -169,12 +167,10 @@ enum class ErrorCode { over_pressure = 0xd, door_open = 0xe, reed_open = 0xf, - motor_driver_error_detected = 0x10, }; /** Error Severity levels. */ enum class ErrorSeverity { - none = 0x0, warning = 0x1, recoverable = 0x2, unrecoverable = 0x3, diff --git a/include/can/core/messages.hpp b/include/can/core/messages.hpp index 4f424b4d7..bb9bb6ada 100644 --- a/include/can/core/messages.hpp +++ b/include/can/core/messages.hpp @@ -646,41 +646,6 @@ struct ReadMotorDriverRegisterResponse -> bool = default; }; -struct ReadMotorDriverErrorStatusRequest - : BaseMessage { - uint32_t message_index; - - template - static auto parse(Input body, Limit limit) - -> ReadMotorDriverErrorStatusRequest { - uint32_t msg_ind = 0; - - body = bit_utils::bytes_to_int(body, limit, msg_ind); - return ReadMotorDriverErrorStatusRequest{.message_index = msg_ind}; - } - - auto operator==(const ReadMotorDriverErrorStatusRequest& other) const - -> bool = default; -}; - -struct ReadMotorDriverErrorStatusResponse - : BaseMessage { - uint32_t message_index; - uint8_t reg_address; - uint32_t data; - - template - auto serialize(Output body, Limit limit) const -> uint8_t { - auto iter = bit_utils::int_to_bytes(message_index, body, limit); - iter = bit_utils::int_to_bytes(reg_address, iter, limit); - iter = bit_utils::int_to_bytes(data, iter, limit); - return iter - body; - } - - auto operator==(const ReadMotorDriverErrorStatusResponse& other) const - -> bool = default; -}; - struct WriteMotorCurrentRequest : BaseMessage { uint32_t message_index; @@ -1832,7 +1797,6 @@ using ResponseMessageType = std::variant< UpdateMotorPositionEstimationResponse, BaselineSensorResponse, PushTipPresenceNotification, GetMotorUsageResponse, GripperJawStateResponse, GripperJawHoldoffResponse, HepaUVInfoResponse, GetHepaFanStateResponse, - GetHepaUVStateResponse, MotorStatusResponse, GearMotorStatusResponse, - ReadMotorDriverErrorStatusResponse>; + GetHepaUVStateResponse, MotorStatusResponse, GearMotorStatusResponse>; } // namespace can::messages diff --git a/include/gantry/core/can_task.hpp b/include/gantry/core/can_task.hpp index 53bf495f9..2c4918fff 100644 --- a/include/gantry/core/can_task.hpp +++ b/include/gantry/core/can_task.hpp @@ -21,8 +21,7 @@ using MotorDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::motor::MotorHandler, can::messages::ReadMotorDriverRegister, can::messages::WriteMotorDriverRegister, - can::messages::WriteMotorCurrentRequest, - can::messages::ReadMotorDriverErrorStatusRequest>; + can::messages::WriteMotorCurrentRequest>; using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::move_group::MoveGroupHandler< gantry::queues::QueueClient>, diff --git a/include/gantry/core/interfaces_proto.hpp b/include/gantry/core/interfaces_proto.hpp index ad72967b2..d58ea63fd 100644 --- a/include/gantry/core/interfaces_proto.hpp +++ b/include/gantry/core/interfaces_proto.hpp @@ -9,12 +9,10 @@ namespace interfaces { -extern "C" using diag0_handler = void(*)(); - /** * Initialize the hardware portability layer. */ -void initialize(diag0_handler *call_diag0_handler); +void initialize(); /** * Get the CAN bus interface. diff --git a/include/gantry/core/interfaces_rev1.hpp b/include/gantry/core/interfaces_rev1.hpp index fa276cbff..129d2ac68 100644 --- a/include/gantry/core/interfaces_rev1.hpp +++ b/include/gantry/core/interfaces_rev1.hpp @@ -9,12 +9,10 @@ namespace interfaces { -extern "C" using diag0_handler = void(*)(); - /** * Initialize the hardware portability layer. */ -void initialize(diag0_handler *call_diag0_handler); +void initialize(); /** * Get the CAN bus interface. diff --git a/include/gantry/core/queues.hpp b/include/gantry/core/queues.hpp index 42884aa01..3007e49cb 100644 --- a/include/gantry/core/queues.hpp +++ b/include/gantry/core/queues.hpp @@ -32,8 +32,6 @@ 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/gantry/core/tasks_proto.hpp b/include/gantry/core/tasks_proto.hpp index 8fe6846d4..c9fe5be64 100644 --- a/include/gantry/core/tasks_proto.hpp +++ b/include/gantry/core/tasks_proto.hpp @@ -6,7 +6,6 @@ #include "eeprom/core/hardware_iface.hpp" #include "eeprom/core/task.hpp" #include "eeprom/core/update_data_rev_task.hpp" -#include "gantry/core/interfaces_proto.hpp" #include "i2c/core/hardware_iface.hpp" #include "i2c/core/tasks/i2c_poller_task.hpp" #include "i2c/core/tasks/i2c_task.hpp" @@ -29,17 +28,14 @@ namespace tasks { /** * Start gantry tasks. */ -auto start_tasks( +void start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& motion_controller, spi::hardware::SpiDeviceBase& spi_device, tmc2130::configs::TMC2130DriverConfig& driver_configs, motor_hardware_task::MotorHardwareTask& mh_tsk, i2c::hardware::I2CBase& i2c2, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> interfaces::diag0_handler; - -void call_run_diag0_interrupt(); + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface); /** * Access to all tasks in the system. diff --git a/include/gantry/core/tasks_rev1.hpp b/include/gantry/core/tasks_rev1.hpp index ea086c412..0a90e559d 100644 --- a/include/gantry/core/tasks_rev1.hpp +++ b/include/gantry/core/tasks_rev1.hpp @@ -6,7 +6,6 @@ #include "eeprom/core/hardware_iface.hpp" #include "eeprom/core/task.hpp" #include "eeprom/core/update_data_rev_task.hpp" -#include "gantry/core/interfaces_rev1.hpp" #include "i2c/core/hardware_iface.hpp" #include "i2c/core/tasks/i2c_poller_task.hpp" #include "i2c/core/tasks/i2c_task.hpp" @@ -29,17 +28,14 @@ namespace tasks { /** * Start gantry tasks. */ -auto start_tasks( +void start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& motion_controller, spi::hardware::SpiDeviceBase& spi_device, tmc2160::configs::TMC2160DriverConfig& driver_configs, motor_hardware_task::MotorHardwareTask& mh_tsk, i2c::hardware::I2CBase& i2c2, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> interfaces::diag0_handler; - -void call_run_diag0_interrupt(); + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface); /** * Access to all tasks in the system. diff --git a/include/gripper/core/can_task.hpp b/include/gripper/core/can_task.hpp index 334801bf6..e3b3f294c 100644 --- a/include/gripper/core/can_task.hpp +++ b/include/gripper/core/can_task.hpp @@ -18,8 +18,7 @@ using MotorDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::motor::MotorHandler, can::messages::ReadMotorDriverRegister, can::messages::WriteMotorDriverRegister, - can::messages::WriteMotorCurrentRequest, - can::messages::ReadMotorDriverErrorStatusRequest>; + can::messages::WriteMotorCurrentRequest>; #ifdef USE_SENSOR_MOVE using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::move_group::MoveGroupHandler, diff --git a/include/gripper/core/interfaces.hpp b/include/gripper/core/interfaces.hpp index 5430d5801..f11dac6ef 100644 --- a/include/gripper/core/interfaces.hpp +++ b/include/gripper/core/interfaces.hpp @@ -11,9 +11,7 @@ namespace z_motor_iface { -extern "C" using diag0_handler = void(*)(); - -void initialize(diag0_handler *call_diag0_handler); +void initialize(); /** * Access to the z motor. diff --git a/include/gripper/core/tasks.hpp b/include/gripper/core/tasks.hpp index 8e849547e..f31229362 100644 --- a/include/gripper/core/tasks.hpp +++ b/include/gripper/core/tasks.hpp @@ -7,7 +7,6 @@ #include "eeprom/core/hardware_iface.hpp" #include "eeprom/core/task.hpp" #include "eeprom/core/update_data_rev_task.hpp" -#include "gripper/core/interfaces.hpp" #include "i2c/core/hardware_iface.hpp" #include "i2c/core/tasks/i2c_poller_task.hpp" #include "i2c/core/tasks/i2c_task.hpp" @@ -37,7 +36,7 @@ namespace gripper_tasks { /** * Start gripper tasks. */ -auto start_tasks(can::bus::CanBus& can_bus, +void start_tasks(can::bus::CanBus& can_bus, motor_class::Motor& z_motor, brushed_motor::BrushedMotor& grip_motor, spi::hardware::SpiDeviceBase& spi_device, @@ -46,8 +45,7 @@ auto start_tasks(can::bus::CanBus& can_bus, sensors::hardware::SensorHardwareBase& sensor_hardware, eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface, motor_hardware_task::MotorHardwareTask& zmh_tsk, - motor_hardware_task::MotorHardwareTask& gmh_tsk) - -> z_motor_iface::diag0_handler; + motor_hardware_task::MotorHardwareTask& gmh_tsk); /** * Access to all the message queues in the system. @@ -186,15 +184,13 @@ struct AllTask { namespace z_tasks { -auto start_task( +void start_task( motor_class::Motor& z_motor, spi::hardware::SpiDeviceBase& spi_device, tmc2130::configs::TMC2130DriverConfig& driver_configs, AllTask& tasks, gripper_tasks::QueueClient& main_queues, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) -> z_motor_iface::diag0_handler; - -void call_run_diag0_interrupt(); + tail_accessor); struct QueueClient : can::message_writer::MessageWriter { QueueClient(); @@ -204,8 +200,6 @@ 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/gripper/firmware/utility_gpio.h b/include/gripper/firmware/utility_gpio.h index c0267033a..4cb96d005 100644 --- a/include/gripper/firmware/utility_gpio.h +++ b/include/gripper/firmware/utility_gpio.h @@ -53,7 +53,6 @@ void utility_gpio_init(); // z motor pins #define Z_MOT_DIR_PIN GPIO_PIN_10 #define Z_MOT_STEP_PIN GPIO_PIN_1 -#define Z_MOT_DIAG0_PIN GPIO_PIN_2 #define Z_MOT_STEPDIR_PORT GPIOB #define Z_MOT_ENABLE_PIN GPIO_PIN_9 #define Z_MOT_ENABLE_PORT GPIOA diff --git a/include/gripper/simulation/sim_interfaces.hpp b/include/gripper/simulation/sim_interfaces.hpp index a3750ab63..4de28bad4 100644 --- a/include/gripper/simulation/sim_interfaces.hpp +++ b/include/gripper/simulation/sim_interfaces.hpp @@ -4,8 +4,6 @@ namespace z_motor_iface { -extern "C" using diag0_handler = void(*)(); - auto get_z_motor_interface() -> sim_motor_hardware_iface::SimMotorHardwareIface&; diff --git a/include/head/core/queues.hpp b/include/head/core/queues.hpp index 6a07d9cd1..2552275ff 100644 --- a/include/head/core/queues.hpp +++ b/include/head/core/queues.hpp @@ -55,8 +55,6 @@ 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/head/core/tasks_proto.hpp b/include/head/core/tasks_proto.hpp index 8be17643e..6f87e5286 100644 --- a/include/head/core/tasks_proto.hpp +++ b/include/head/core/tasks_proto.hpp @@ -24,12 +24,11 @@ namespace head_tasks { -extern "C" using diag0_handler = void(*)(); - /** * Start head tasks. */ -auto start_tasks( + +void start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& left_motion_controller, @@ -43,8 +42,7 @@ auto start_tasks( motor_hardware_task::MotorHardwareTask& right_motor_hardware, motor_hardware_task::MotorHardwareTask& left_motor_hardware, i2c::hardware::I2CBase& i2c3, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> std::tuple; + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface); /** * Access to all tasks not associated with a motor. This will be a singleton. diff --git a/include/head/core/tasks_rev1.hpp b/include/head/core/tasks_rev1.hpp index 430c89cf4..bbb375586 100644 --- a/include/head/core/tasks_rev1.hpp +++ b/include/head/core/tasks_rev1.hpp @@ -24,12 +24,11 @@ namespace head_tasks { -extern "C" using diag0_handler = void(*)(); - /** * Start head tasks. */ -auto start_tasks( + +void start_tasks( can::bus::CanBus& can_bus, motion_controller::MotionController& left_motion_controller, @@ -43,8 +42,7 @@ auto start_tasks( motor_hardware_task::MotorHardwareTask& right_motor_hardware, motor_hardware_task::MotorHardwareTask& left_motor_hardware, i2c::hardware::I2CBase& i2c3, - eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface) - -> std::tuple; + eeprom::hardware_iface::EEPromHardwareIface& eeprom_hw_iface); /** * Access to all tasks not associated with a motor. This will be a singleton. diff --git a/include/motor-control/core/brushed_motor/brushed_motion_controller.hpp b/include/motor-control/core/brushed_motor/brushed_motion_controller.hpp index 113f56214..00ec0dddf 100644 --- a/include/motor-control/core/brushed_motor/brushed_motion_controller.hpp +++ b/include/motor-control/core/brushed_motor/brushed_motion_controller.hpp @@ -101,15 +101,12 @@ class MotionController { enabled = false; } - void stop( - can::ids::ErrorSeverity error_severity = - can::ids::ErrorSeverity::warning, - can::ids::ErrorCode error_code = can::ids::ErrorCode::stop_requested) { + void stop() { queue.reset(); // if we're gripping something we need to flag this so we don't drop it if (!hardware.get_stay_enabled()) { if (hardware.is_timer_interrupt_running()) { - hardware.set_cancel_request(error_severity, error_code); + hardware.request_cancel(); } } } diff --git a/include/motor-control/core/brushed_motor/brushed_motor_interrupt_handler.hpp b/include/motor-control/core/brushed_motor/brushed_motor_interrupt_handler.hpp index 634249d8c..436311fad 100644 --- a/include/motor-control/core/brushed_motor/brushed_motor_interrupt_handler.hpp +++ b/include/motor-control/core/brushed_motor/brushed_motor_interrupt_handler.hpp @@ -180,7 +180,7 @@ class BrushedMotorInterruptHandler { } else if (in_estop) { // if we've received a stop request during this time we can clear // that flag since there isn't anything running - std::ignore = hardware.get_cancel_request(); + std::ignore = hardware.has_cancel_request(); // return out of error state once the estop is disabled if (!estop_triggered()) { in_estop = false; @@ -197,9 +197,7 @@ class BrushedMotorInterruptHandler { } else if (estop_triggered()) { in_estop = true; cancel_and_clear_moves(can::ids::ErrorCode::estop_detected); - } else if (static_cast( - hardware.get_cancel_request().code) != - can::ids::ErrorCode::ok) { + } else if (hardware.has_cancel_request()) { if (!hardware.get_stay_enabled()) { hardware.set_motor_state(BrushedMotorState::UNHOMED); } diff --git a/include/motor-control/core/motor_hardware_interface.hpp b/include/motor-control/core/motor_hardware_interface.hpp index 647603250..9a979143d 100644 --- a/include/motor-control/core/motor_hardware_interface.hpp +++ b/include/motor-control/core/motor_hardware_interface.hpp @@ -72,11 +72,6 @@ class UsageEEpromConfig { size_t num_keys = 0; }; -struct __attribute__((packed)) CancelRequest { - uint8_t severity; - uint8_t code; -}; - class MotorHardwareIface { public: MotorHardwareIface() = default; @@ -95,7 +90,6 @@ class MotorHardwareIface { virtual void read_limit_switch() = 0; virtual void read_estop_in() = 0; virtual void read_sync_in() = 0; - virtual auto read_tmc_diag0() -> bool = 0; virtual auto get_encoder_pulses() -> int32_t = 0; virtual void reset_encoder_pulses() = 0; virtual void start_timer_interrupt() = 0; @@ -104,10 +98,8 @@ class MotorHardwareIface { virtual void enable_encoder() = 0; virtual void disable_encoder() = 0; - virtual auto get_cancel_request() -> CancelRequest = 0; - virtual void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) = 0; - virtual void clear_cancel_request() = 0; + virtual auto has_cancel_request() -> bool = 0; + virtual void request_cancel() = 0; virtual auto get_usage_eeprom_config() -> const UsageEEpromConfig& = 0; // This variable can remain public because the only public methods diff --git a/include/motor-control/core/stepper_motor/motion_controller.hpp b/include/motor-control/core/stepper_motor/motion_controller.hpp index 0f0203921..9cd1e9c4f 100644 --- a/include/motor-control/core/stepper_motor/motion_controller.hpp +++ b/include/motor-control/core/stepper_motor/motion_controller.hpp @@ -181,22 +181,13 @@ class MotionController { return update_queue.try_write(can_msg); } - void stop( - can::ids::ErrorSeverity error_severity = - can::ids::ErrorSeverity::warning, - can::ids::ErrorCode error_code = can::ids::ErrorCode::stop_requested) { + void stop() { queue.reset(); if (hardware.is_timer_interrupt_running()) { - hardware.set_cancel_request(error_severity, error_code); + hardware.request_cancel(); } } - void clear_cancel_request() { hardware.clear_cancel_request(); } - - auto is_timer_interrupt_running() -> bool { - return hardware.is_timer_interrupt_running(); - } - auto read_limit_switch() -> bool { return hardware.check_limit_switch(); } [[nodiscard]] auto read_motor_position() const { @@ -211,11 +202,9 @@ class MotionController { auto check_read_sync_line() -> bool { return hardware.check_sync_in(); } - auto read_tmc_diag0() -> bool { return hardware.read_tmc_diag0(); } - void enable_motor() { - hardware.start_timer_interrupt(); hardware.activate_motor(); + hardware.start_timer_interrupt(); enabled = true; } @@ -347,31 +336,20 @@ class PipetteMotionController { return false; } - void stop( - can::ids::ErrorSeverity error_severity = - can::ids::ErrorSeverity::warning, - can::ids::ErrorCode error_code = can::ids::ErrorCode::stop_requested) { + void stop() { queue.reset(); // if the timer interrupt is running, cancel it. if it isn't running, // don't submit a cancel because then the cancel won't be read until // the timer starts the next time. if (hardware.is_timer_interrupt_running()) { - hardware.set_cancel_request(error_severity, error_code); + hardware.request_cancel(); } } - void clear_cancel_request() { hardware.clear_cancel_request(); } - - auto is_timer_interrupt_running() -> bool { - return hardware.is_timer_interrupt_running(); - } - auto read_limit_switch() -> bool { return hardware.check_limit_switch(); } auto check_read_sync_line() -> bool { return hardware.check_sync_in(); } - auto read_tmc_diag0() -> bool { return hardware.read_tmc_diag0(); } - void enable_motor() { hardware.start_timer_interrupt(); hardware.activate_motor(); 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 8a1ffd607..fc47b9023 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -107,7 +107,6 @@ class MotorInterruptHandler { MotorInterruptHandler() = delete; MotorInterruptHandler(MoveQueue& incoming_move_queue, StatusClient& outgoing_queue, - DriverClient& driver_queue, MotorHardware& hardware_iface, stall_check::StallCheck& stall, UpdatePositionQueue& incoming_update_position_queue) @@ -123,7 +122,6 @@ class MotorInterruptHandler { SensorClient& sensor_queue) : move_queue(incoming_move_queue), status_queue_client(outgoing_queue), - driver_client(driver_queue), hardware(hardware_iface), stall_checker{stall}, update_position_queue(incoming_update_position_queue), @@ -251,8 +249,6 @@ class MotorInterruptHandler { void run_interrupt() { // handle various error states - motor_hardware::CancelRequest cancel_request = - hardware.get_cancel_request(); std::ignore = hardware.get_encoder_pulses(); if (clear_queue_until_empty) { // If we were executing a move when estop asserted, and @@ -272,11 +268,9 @@ class MotorInterruptHandler { } else if (estop_triggered()) { cancel_and_clear_moves(can::ids::ErrorCode::estop_detected); in_estop = true; - } else if (static_cast(cancel_request.code) != - can::ids::ErrorCode::ok) { - cancel_and_clear_moves( - static_cast(cancel_request.code), - static_cast(cancel_request.severity)); + } else if (hardware.has_cancel_request()) { + cancel_and_clear_moves(can::ids::ErrorCode::stop_requested, + can::ids::ErrorSeverity::warning); } else { // Normal Move logic run_normal_interrupt(); @@ -531,11 +525,6 @@ class MotorInterruptHandler { can::messages::ErrorMessage{.message_index = message_index, .severity = severity, .error_code = err_code}); - if (err_code == can::ids::ErrorCode::motor_driver_error_detected) { - driver_client.send_motor_driver_queue_isr( - can::messages::ReadMotorDriverErrorStatusRequest{ - .message_index = message_index}); - } if (err_code == can::ids::ErrorCode::collision_detected) { build_and_send_ack(AckMessageId::position_error); } @@ -761,7 +750,6 @@ class MotorInterruptHandler { q31_31 position_tracker{0}; MoveQueue& move_queue; StatusClient& status_queue_client; - DriverClient& driver_client; MotorHardware& hardware; stall_check::StallCheck& stall_checker; UpdatePositionQueue& update_position_queue; diff --git a/include/motor-control/core/stepper_motor/tmc2130_driver.hpp b/include/motor-control/core/stepper_motor/tmc2130_driver.hpp index 7c3a74e7d..fefe1f049 100644 --- a/include/motor-control/core/stepper_motor/tmc2130_driver.hpp +++ b/include/motor-control/core/stepper_motor/tmc2130_driver.hpp @@ -52,11 +52,10 @@ class TMC2130 { auto operator=(const TMC2130&& c) = delete; ~TMC2130() = default; - auto read(Registers addr, uint32_t command_data, uint32_t message_index, - uint8_t tags = 0) -> void { + auto read(Registers addr, uint32_t command_data, uint32_t message_index) + -> void { auto converted_addr = static_cast(addr); - uint32_t token = spi::utils::build_token(converted_addr, tags); - _spi_manager.read(token, command_data, _task_queue, _cs_intf, + _spi_manager.read(converted_addr, command_data, _task_queue, _cs_intf, message_index); } diff --git a/include/motor-control/core/stepper_motor/tmc2160.hpp b/include/motor-control/core/stepper_motor/tmc2160.hpp index 1590535fb..5f656e3f5 100644 --- a/include/motor-control/core/stepper_motor/tmc2160.hpp +++ b/include/motor-control/core/stepper_motor/tmc2160.hpp @@ -505,21 +505,6 @@ struct __attribute__((packed, __may_alias__)) DriveStatus { uint32_t stst : 1 = 0; }; -struct __attribute__((packed, __may_alias__)) DriveConf { - static constexpr Registers address = Registers::DRV_CONF; - static constexpr bool writable = true; - static constexpr uint32_t value_mask = (1 << 22) - 1; - - uint32_t bbm_time : 5 = 0; - uint32_t bit_padding_1 : 3 = 0; - uint32_t bbm_clks : 4 = 0; - uint32_t bit_padding_2 : 4 = 0; - // 00 = 150*C, 01 = 143*C, 10 = 136*C, 11 = 120*C - uint32_t ot_select : 2 = 0; - uint32_t drv_strength : 2 = 0; - uint32_t filt_isense : 2 = 0; -}; - /** * This register sets the control current for voltage PWM mode stealth chop. */ @@ -559,7 +544,6 @@ struct TMC2160RegisterMap { StealthChop pwmconf = {}; DriveStatus drvstatus = {}; GStatus gstat = {}; - DriveConf drvconf = {}; GlobalScaler glob_scale = {}; }; diff --git a/include/motor-control/core/stepper_motor/tmc2160_driver.hpp b/include/motor-control/core/stepper_motor/tmc2160_driver.hpp index 3958b917c..bc8574cee 100644 --- a/include/motor-control/core/stepper_motor/tmc2160_driver.hpp +++ b/include/motor-control/core/stepper_motor/tmc2160_driver.hpp @@ -53,11 +53,10 @@ class TMC2160 { auto operator=(const TMC2160&& c) = delete; ~TMC2160() = default; - auto read(Registers addr, uint32_t command_data, uint32_t message_index, - uint8_t tags = 0) -> void { + auto read(Registers addr, uint32_t command_data, uint32_t message_index) + -> void { auto converted_addr = static_cast(addr); - uint32_t token = spi::utils::build_token(converted_addr, tags); - _spi_manager.read(token, command_data, _task_queue, _cs_intf, + _spi_manager.read(converted_addr, command_data, _task_queue, _cs_intf, message_index); } @@ -106,9 +105,6 @@ class TMC2160 { if (!set_glob_scaler(_registers.glob_scale)) { return false; } - if (!set_drv_conf(_registers.drvconf)) { - return false; - } _initialized = true; return true; } @@ -276,22 +272,6 @@ class TMC2160 { return false; } - /** - * @brief Update DRV_CONF register - * @param reg New configuration register to set - * @param policy Instance of abstraction policy to use - * @return True if new register was set succesfully, false otherwise - */ - auto set_drv_conf(DriveConf reg) -> bool { - reg.bit_padding_1 = 0; - reg.bit_padding_2 = 0; - if (set_register(reg)) { - _registers.drvconf = reg; - return true; - } - return false; - } - /** * @brief Update GlobalScaler register * @param reg New configuration register to set diff --git a/include/motor-control/core/tasks/gear_tmc2160_motor_driver_task.hpp b/include/motor-control/core/tasks/gear_tmc2160_motor_driver_task.hpp index d9593d395..ce55d848c 100644 --- a/include/motor-control/core/tasks/gear_tmc2160_motor_driver_task.hpp +++ b/include/motor-control/core/tasks/gear_tmc2160_motor_driver_task.hpp @@ -59,24 +59,12 @@ class MotorDriverMessageHandler { auto data = driver.handle_spi_read( tmc2160::registers::Registers(static_cast(m.id.token)), m.rxBuffer); - if (spi::utils::tag_in_token( - m.id.token, spi::utils::ResponseTag::IS_ERROR_RESPONSE)) { - can::messages::ReadMotorDriverErrorStatusResponse response_msg{ - .message_index = m.id.message_index, - .reg_address = static_cast(m.id.token), - .data = data, - }; - can_client.send_can_message(can::ids::NodeId::host, - response_msg); - } else { - can::messages::ReadMotorDriverRegisterResponse response_msg{ - .message_index = m.id.message_index, - .reg_address = static_cast(m.id.token), - .data = data, - }; - can_client.send_can_message(can::ids::NodeId::host, - response_msg); - } + can::messages::ReadMotorDriverRegisterResponse response_msg{ + .message_index = m.id.message_index, + .reg_address = static_cast(m.id.token), + .data = data, + }; + can_client.send_can_message(can::ids::NodeId::host, response_msg); } } @@ -99,15 +87,6 @@ class MotorDriverMessageHandler { } } - void handle(const can::messages::ReadMotorDriverErrorStatusRequest& m) { - LOG("Received read motor driver error register request"); - uint32_t data = 0; - std::array tags{spi::utils::ResponseTag::IS_ERROR_RESPONSE}; - uint8_t tag_byte = spi::utils::byte_from_tags(tags); - driver.read(tmc2160::registers::Registers::DRVSTATUS, data, - m.message_index, tag_byte); - } - void handle(const can::messages::GearWriteMotorCurrentRequest& m) { LOG("Received gear write motor current request: hold_current=%d, " "run_current=%d", diff --git a/include/motor-control/core/tasks/messages.hpp b/include/motor-control/core/tasks/messages.hpp index dc3203f7f..759a28308 100644 --- a/include/motor-control/core/tasks/messages.hpp +++ b/include/motor-control/core/tasks/messages.hpp @@ -6,11 +6,6 @@ namespace motor_control_task_messages { -struct RouteMotorDriverInterrupt { - uint32_t message_index; - uint8_t debounce_count; -}; - #ifdef USE_SENSOR_MOVE using MotionControlTaskMessage = std::variant< std::monostate, can::messages::AddLinearMoveRequest, @@ -21,7 +16,7 @@ using MotionControlTaskMessage = std::variant< can::messages::HomeRequest, can::messages::UpdateMotorPositionEstimationRequest, can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest, - RouteMotorDriverInterrupt, can::messages::AddSensorMoveRequest>; + can::messages::AddSensorMoveRequest>; using MoveGroupTaskMessage = std::variant; + can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest>; using MoveGroupTaskMessage = std::variant; + can::messages::WriteMotorCurrentRequest>; using MoveStatusReporterTaskMessage = std::variant< std::monostate, motor_messages::Ack, motor_messages::UpdatePositionResponse, diff --git a/include/motor-control/core/tasks/motion_controller_task.hpp b/include/motor-control/core/tasks/motion_controller_task.hpp index 64f02ccc7..f8838703b 100644 --- a/include/motor-control/core/tasks/motion_controller_task.hpp +++ b/include/motor-control/core/tasks/motion_controller_task.hpp @@ -8,46 +8,26 @@ #include "motor-control/core/linear_motion_system.hpp" #include "motor-control/core/stepper_motor/motion_controller.hpp" #include "motor-control/core/tasks/messages.hpp" -#include "motor-control/core/tasks/tmc_motor_driver_common.hpp" - -constexpr uint32_t DIAG0_DEBOUNCE_REPS = 9; -constexpr uint32_t DIAG0_DEBOUNCE_DELAY = 100; namespace motion_controller_task { using TaskMessage = motor_control_task_messages::MotionControlTaskMessage; -/** - * Concept describing a class that can message this task. - * @tparam Client - */ -template -concept TaskClient = requires(Client client, const TaskMessage& m) { - {client.send_motion_controller_queue(m)}; -}; - /** * The message queue message handler. */ template + usage_storage_task::TaskClient UsageClient> class MotionControllerMessageHandler { public: using MotorControllerType = motion_controller::MotionController; MotionControllerMessageHandler(MotorControllerType& controller, CanClient& can_client, - UsageClient& usage_client, - DriverClient& driver_client, - MotionClient& motion_client, - std::atomic& diag0_debounced) + UsageClient& usage_client) : controller{controller}, can_client{can_client}, - usage_client{usage_client}, - driver_client{driver_client}, - motion_client{motion_client}, - diag0_debounced{diag0_debounced} {} + usage_client{usage_client} {} MotionControllerMessageHandler(const MotionControllerMessageHandler& c) = delete; MotionControllerMessageHandler(const MotionControllerMessageHandler&& c) = @@ -72,19 +52,9 @@ class MotionControllerMessageHandler { void handle(const can::messages::EnableMotorRequest& m) { LOG("Received enable motor request"); - if (controller.read_tmc_diag0()) { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = m.message_index, - .severity = can::ids::ErrorSeverity::unrecoverable, - .error_code = - can::ids::ErrorCode::motor_driver_error_detected}); - } else { - controller.enable_motor(); - can_client.send_can_message(can::ids::NodeId::host, - can::messages::ack_from_request(m)); - } + controller.enable_motor(); + can_client.send_can_message(can::ids::NodeId::host, + can::messages::ack_from_request(m)); } void handle(const can::messages::DisableMotorRequest& m) { @@ -122,17 +92,7 @@ class MotionControllerMessageHandler { "groupid=%d, seqid=%d, duration=%d, stopcondition=%d", m.velocity, m.acceleration, m.group_id, m.seq_id, m.duration, m.request_stop_condition); - if (controller.read_tmc_diag0()) { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = m.message_index, - .severity = can::ids::ErrorSeverity::unrecoverable, - .error_code = - can::ids::ErrorCode::motor_driver_error_detected}); - } else { - controller.move(m); - } + controller.move(m); } #ifdef USE_SENSOR_MOVE @@ -149,17 +109,7 @@ class MotionControllerMessageHandler { LOG("Motion Controller Received home request: velocity=%d, " "groupid=%d, seqid=%d\n", m.velocity, m.group_id, m.seq_id); - if (controller.read_tmc_diag0()) { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = m.message_index, - .severity = can::ids::ErrorSeverity::unrecoverable, - .error_code = - can::ids::ErrorCode::motor_driver_error_detected}); - } else { - controller.move(m); - } + controller.move(m); } void handle(const can::messages::ReadLimitSwitchRequest& m) { @@ -196,47 +146,10 @@ class MotionControllerMessageHandler { can_client.send_can_message(can::ids::NodeId::host, response); } } - void handle(const can::messages::GetMotorUsageRequest& m) { controller.send_usage_data(m.message_index, usage_client); } - void handle( - const motor_control_task_messages::RouteMotorDriverInterrupt& m) { - if (m.debounce_count > DIAG0_DEBOUNCE_REPS) { - if (controller.read_tmc_diag0()) { - controller.stop( - can::ids::ErrorSeverity::unrecoverable, - can::ids::ErrorCode::motor_driver_error_detected); - if (!controller.is_timer_interrupt_running()) { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = m.message_index, - .severity = can::ids::ErrorSeverity::unrecoverable, - .error_code = can::ids::ErrorCode:: - motor_driver_error_detected}); - driver_client.send_motor_driver_queue( - can::messages::ReadMotorDriverErrorStatusRequest{ - .message_index = m.message_index}); - } - } - diag0_debounced = false; - } else { - vTaskDelay(pdMS_TO_TICKS(DIAG0_DEBOUNCE_DELAY)); - motion_client.send_motion_controller_queue( - increment_message_debounce_count(m)); - } - } - - auto increment_message_debounce_count( - const motor_control_task_messages::RouteMotorDriverInterrupt& m) - -> motor_control_task_messages::RouteMotorDriverInterrupt { - return motor_control_task_messages::RouteMotorDriverInterrupt{ - .message_index = m.message_index, - .debounce_count = static_cast(m.debounce_count + 1)}; - } - void handle(const can::messages::MotorStatusRequest& m) { auto response = static_cast(controller.is_motor_enabled()); can::messages::MotorStatusResponse msg{.message_index = m.message_index, @@ -247,9 +160,6 @@ class MotionControllerMessageHandler { MotorControllerType& controller; CanClient& can_client; UsageClient& usage_client; - DriverClient& driver_client; - MotionClient& motion_client; - std::atomic& diag0_debounced; }; /** @@ -273,15 +183,12 @@ class MotionControllerTask { */ template + usage_storage_task::TaskClient UsageClient> [[noreturn]] void operator()( motion_controller::MotionController* controller, - CanClient* can_client, UsageClient* usage_client, - DriverClient* driver_client, MotionClient* motion_client) { - auto handler = MotionControllerMessageHandler{ - *controller, *can_client, *usage_client, - *driver_client, *motion_client, diag0_debounced}; + CanClient* can_client, UsageClient* usage_client) { + auto handler = MotionControllerMessageHandler{*controller, *can_client, + *usage_client}; TaskMessage message{}; bool first_run = true; for (;;) { @@ -297,18 +204,17 @@ class MotionControllerTask { [[nodiscard]] auto get_queue() const -> QueueType& { return queue; } - void run_diag0_interrupt() { - if (!diag0_debounced) { - static_cast(queue.try_write_isr( - motor_control_task_messages::RouteMotorDriverInterrupt{ - .message_index = 0, .debounce_count = 0})); - diag0_debounced = true; - } - } - private: QueueType& queue; - std::atomic diag0_debounced = false; +}; + +/** + * Concept describing a class that can message this task. + * @tparam Client + */ +template +concept TaskClient = requires(Client client, const TaskMessage& m) { + {client.send_motion_controller_queue(m)}; }; } // namespace motion_controller_task 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 526b0ebaf..82cff0e01 100644 --- a/include/motor-control/core/tasks/tmc2130_motor_driver_task.hpp +++ b/include/motor-control/core/tasks/tmc2130_motor_driver_task.hpp @@ -58,24 +58,12 @@ class MotorDriverMessageHandler { auto data = driver.handle_spi_read( tmc2130::registers::Registers(static_cast(m.id.token)), m.rxBuffer); - if (spi::utils::tag_in_token( - m.id.token, spi::utils::ResponseTag::IS_ERROR_RESPONSE)) { - can::messages::ReadMotorDriverErrorStatusResponse response_msg{ - .message_index = m.id.message_index, - .reg_address = static_cast(m.id.token), - .data = data, - }; - can_client.send_can_message(can::ids::NodeId::host, - response_msg); - } else { - can::messages::ReadMotorDriverRegisterResponse response_msg{ - .message_index = m.id.message_index, - .reg_address = static_cast(m.id.token), - .data = data, - }; - can_client.send_can_message(can::ids::NodeId::host, - response_msg); - } + can::messages::ReadMotorDriverRegisterResponse response_msg{ + .message_index = m.id.message_index, + .reg_address = static_cast(m.id.token), + .data = data, + }; + can_client.send_can_message(can::ids::NodeId::host, response_msg); } } @@ -98,15 +86,6 @@ class MotorDriverMessageHandler { } } - void handle(const can::messages::ReadMotorDriverErrorStatusRequest& m) { - LOG("Received read motor driver error register request"); - uint32_t data = 0; - std::array tags{spi::utils::ResponseTag::IS_ERROR_RESPONSE}; - uint8_t tag_byte = spi::utils::byte_from_tags(tags); - driver.read(tmc2130::registers::Registers::DRVSTATUS, data, - m.message_index, tag_byte); - } - void handle(const can::messages::WriteMotorCurrentRequest& m) { LOG("Received write motor current request: hold_current=%d, " "run_current=%d", @@ -175,7 +154,6 @@ 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 aec315ea7..9f4e69179 100644 --- a/include/motor-control/core/tasks/tmc2160_motor_driver_task.hpp +++ b/include/motor-control/core/tasks/tmc2160_motor_driver_task.hpp @@ -10,7 +10,6 @@ #include "motor-control/core/tasks/messages.hpp" #include "motor-control/core/tasks/tmc_motor_driver_common.hpp" #include "spi/core/messages.hpp" -#include "spi/core/utils.hpp" namespace tmc2160 { @@ -58,24 +57,12 @@ class MotorDriverMessageHandler { auto data = driver.handle_spi_read( tmc2160::registers::Registers(static_cast(m.id.token)), m.rxBuffer); - if (spi::utils::tag_in_token( - m.id.token, spi::utils::ResponseTag::IS_ERROR_RESPONSE)) { - can::messages::ReadMotorDriverErrorStatusResponse response_msg{ - .message_index = m.id.message_index, - .reg_address = static_cast(m.id.token), - .data = data, - }; - can_client.send_can_message(can::ids::NodeId::host, - response_msg); - } else { - can::messages::ReadMotorDriverRegisterResponse response_msg{ - .message_index = m.id.message_index, - .reg_address = static_cast(m.id.token), - .data = data, - }; - can_client.send_can_message(can::ids::NodeId::host, - response_msg); - } + can::messages::ReadMotorDriverRegisterResponse response_msg{ + .message_index = m.id.message_index, + .reg_address = static_cast(m.id.token), + .data = data, + }; + can_client.send_can_message(can::ids::NodeId::host, response_msg); } } @@ -98,15 +85,6 @@ class MotorDriverMessageHandler { } } - void handle(const can::messages::ReadMotorDriverErrorStatusRequest& m) { - LOG("Received read motor driver error register request"); - uint32_t data = 0; - std::array tags{spi::utils::ResponseTag::IS_ERROR_RESPONSE}; - uint8_t tag_byte = spi::utils::byte_from_tags(tags); - driver.read(tmc2160::registers::Registers::DRVSTATUS, data, - m.message_index, tag_byte); - } - void handle(const can::messages::WriteMotorCurrentRequest& m) { LOG("Received write motor current request: hold_current=%d, " "run_current=%d", @@ -168,16 +146,6 @@ class MotorDriverTask { QueueType& queue; }; -/** - * Concept describing a class that can message this task. - * @tparam Client - */ -template -concept TaskClient = requires(Client client, const TaskMessage& m) { - {client.send_motor_driver_queue(m)}; - {client.send_motor_driver_queue_isr(m)}; -}; - } // namespace tasks } // namespace tmc2160 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 0b0839348..191373466 100644 --- a/include/motor-control/core/tasks/tmc_motor_driver_common.hpp +++ b/include/motor-control/core/tasks/tmc_motor_driver_common.hpp @@ -8,14 +8,11 @@ namespace tmc { namespace tasks { using SpiResponseMessage = std::tuple; -using CanMessageTuple = - std::tuple; +using CanMessageTuple = std::tuple; using GearCanMessageTuple = std::tuple; using CanMessage = @@ -40,7 +37,6 @@ 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)}; }; /** @@ -50,7 +46,6 @@ concept TaskClient = requires(Client client, const TaskMessage& m) { template concept GearTaskClient = requires(Client client, const GearTaskMessage& m) { {client.send_motor_driver_queue(m)}; - {client.send_motor_driver_queue_isr(m)}; }; }; // namespace tasks }; // namespace tmc diff --git a/include/motor-control/firmware/brushed_motor/brushed_motor_hardware.hpp b/include/motor-control/firmware/brushed_motor/brushed_motor_hardware.hpp index 3049d8f41..986c9fe1d 100644 --- a/include/motor-control/firmware/brushed_motor/brushed_motor_hardware.hpp +++ b/include/motor-control/firmware/brushed_motor/brushed_motor_hardware.hpp @@ -62,7 +62,6 @@ class BrushedMotorHardware : public BrushedMotorHardwareIface { void read_limit_switch() final; void read_estop_in() final; void read_sync_in() final; - auto read_tmc_diag0() -> bool final; void grip() final; void ungrip() final; void stop_pwm() final; @@ -79,21 +78,10 @@ class BrushedMotorHardware : public BrushedMotorHardwareIface { void reset_control() final; void set_stay_enabled(bool state) final { stay_enabled = state; } auto get_stay_enabled() -> bool final { return stay_enabled; } - auto get_cancel_request() -> CancelRequest final { - CancelRequest exchange_request = {}; - return cancel_request.exchange(exchange_request); - } - void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) final { - CancelRequest update_request{ - .severity = static_cast(error_severity), - .code = static_cast(error_code)}; - cancel_request.store(update_request); - } - void clear_cancel_request() final { - CancelRequest clear_request = {}; - cancel_request.store(clear_request); + auto has_cancel_request() -> bool final { + return cancel_request.exchange(false); } + void request_cancel() final { cancel_request.store(true); } auto get_usage_eeprom_config() -> const UsageEEpromConfig& final { return eeprom_config; } @@ -113,7 +101,7 @@ class BrushedMotorHardware : public BrushedMotorHardwareIface { int32_t motor_encoder_overflow_count = 0; ot_utils::pid::PID controller_loop; std::atomic control_dir = ControlDirection::unset; - std::atomic cancel_request = {}; + std::atomic cancel_request = false; const UsageEEpromConfig& eeprom_config; void* stopwatch_handle; BrushedMotorState motor_state = BrushedMotorState::UNHOMED; diff --git a/include/motor-control/firmware/stepper_motor/motor_hardware.hpp b/include/motor-control/firmware/stepper_motor/motor_hardware.hpp index ca7be4974..e750a4f02 100644 --- a/include/motor-control/firmware/stepper_motor/motor_hardware.hpp +++ b/include/motor-control/firmware/stepper_motor/motor_hardware.hpp @@ -18,7 +18,6 @@ struct HardwareConfig { gpio::PinConfig led; gpio::PinConfig sync_in; gpio::PinConfig estop_in; - gpio::PinConfig diag0; std::optional ebrake = std::nullopt; }; @@ -51,28 +50,16 @@ class MotorHardware : public StepperMotorHardwareIface { void read_limit_switch() final; void read_estop_in() final; void read_sync_in() final; - auto read_tmc_diag0() -> bool final; void set_LED(bool status) final; auto get_encoder_pulses() -> int32_t final; void reset_encoder_pulses() final; + auto has_cancel_request() -> bool final { + return cancel_request.exchange(false); + } void disable_encoder() final; void enable_encoder() final; - auto get_cancel_request() -> CancelRequest final { - CancelRequest exchange_request = {}; - return cancel_request.exchange(exchange_request); - } - void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) final { - CancelRequest update_request{ - .severity = static_cast(error_severity), - .code = static_cast(error_code)}; - cancel_request.store(update_request); - } - void clear_cancel_request() final { - CancelRequest clear_request = {}; - cancel_request.store(clear_request); - } + void request_cancel() final { cancel_request.store(true); } auto get_usage_eeprom_config() -> const UsageEEpromConfig& final { return eeprom_config; @@ -80,8 +67,6 @@ class MotorHardware : public StepperMotorHardwareIface { // downward interface - call from timer overflow handler void encoder_overflow(int32_t direction); - auto get_pins() -> HardwareConfig { return pins; } - private: debouncer::Debouncer estop = debouncer::Debouncer{}; debouncer::Debouncer limit = debouncer::Debouncer{}; @@ -92,7 +77,7 @@ class MotorHardware : public StepperMotorHardwareIface { void* enc_handle; const UsageEEpromConfig& eeprom_config; std::atomic motor_encoder_overflow_count = 0; - std::atomic cancel_request = {}; + std::atomic cancel_request = false; static constexpr uint32_t ENCODER_OVERFLOW_PULSES_BIT = 0x1 << 31; }; diff --git a/include/motor-control/simulation/motor_interrupt_driver.hpp b/include/motor-control/simulation/motor_interrupt_driver.hpp index 6fef39218..f7dbb193d 100644 --- a/include/motor-control/simulation/motor_interrupt_driver.hpp +++ b/include/motor-control/simulation/motor_interrupt_driver.hpp @@ -9,8 +9,7 @@ namespace motor_interrupt_driver { -template +template class MotorInterruptDriver { using InterruptQueue = freertos_message_queue::FreeRTOSMessageQueue; @@ -19,7 +18,7 @@ class MotorInterruptDriver { can::messages::UpdateMotorPositionEstimationRequest>; using InterruptHandler = motor_handler::MotorInterruptHandler< freertos_message_queue::FreeRTOSMessageQueue, StatusClient, - DriverClient, MotorMoveMessage, MotorHardware>; + MotorMoveMessage, MotorHardware>; public: MotorInterruptDriver(InterruptQueue& q, InterruptHandler& h, diff --git a/include/motor-control/simulation/sim_motor_hardware_iface.hpp b/include/motor-control/simulation/sim_motor_hardware_iface.hpp index 01f45fb21..2a8dd67cc 100644 --- a/include/motor-control/simulation/sim_motor_hardware_iface.hpp +++ b/include/motor-control/simulation/sim_motor_hardware_iface.hpp @@ -51,7 +51,6 @@ class SimMotorHardwareIface : public motor_hardware::StepperMotorHardwareIface { void read_limit_switch() final {} void read_estop_in() final {} void read_sync_in() final {} - bool read_tmc_diag0() final { return false; } void set_LED(bool) final {} void trigger_limit_switch() { limit_switch_status = true; } bool check_sync_in() final { @@ -88,21 +87,10 @@ class SimMotorHardwareIface : public motor_hardware::StepperMotorHardwareIface { bool check_estop_in() final { return estop_detected; } void set_estop(bool estop_pressed) { estop_detected = estop_pressed; } - auto get_cancel_request() -> motor_hardware::CancelRequest final { - motor_hardware::CancelRequest exchange_request; - return cancel_request.exchange(exchange_request); - } - void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) final { - motor_hardware::CancelRequest update_request{ - .severity = static_cast(error_severity), - .code = static_cast(error_code)}; - cancel_request.store(update_request); - } - void clear_cancel_request() final { - motor_hardware::CancelRequest clear_request; - cancel_request.store(clear_request); + auto has_cancel_request() -> bool final { + return cancel_request.exchange(false); } + void request_cancel() final { cancel_request.store(true); } auto get_usage_eeprom_config() -> motor_hardware::UsageEEpromConfig & final { return eeprom_config; @@ -118,7 +106,7 @@ class SimMotorHardwareIface : public motor_hardware::StepperMotorHardwareIface { Direction _direction = Direction::POSITIVE; float _encoder_ticks_per_pulse = 0; bool estop_detected = false; - std::atomic cancel_request = {}; + std::atomic cancel_request = false; motor_hardware::UsageEEpromConfig eeprom_config = { std::array{UsageRequestSet{ .eeprom_key = 0, @@ -149,7 +137,6 @@ class SimBrushedMotorHardwareIface void read_limit_switch() final {} void read_estop_in() final {} void read_sync_in() final {} - bool read_tmc_diag0() final { return false; } void trigger_limit_switch() { limit_switch_status = true; } void grip() final {} void ungrip() final {} @@ -190,21 +177,11 @@ class SimBrushedMotorHardwareIface return ret; } - auto get_cancel_request() -> motor_hardware::CancelRequest final { - motor_hardware::CancelRequest exchange_request; - return cancel_request.exchange(exchange_request); - } - void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) final { - motor_hardware::CancelRequest update_request{ - .severity = static_cast(error_severity), - .code = static_cast(error_code)}; - cancel_request.store(update_request); - } - void clear_cancel_request() final { - motor_hardware::CancelRequest clear_request; - cancel_request.store(clear_request); + auto has_cancel_request() -> bool final { + return cancel_request.exchange(false); } + void request_cancel() final { cancel_request.store(true); } + void disable_encoder() final {} void enable_encoder() final {} @@ -224,7 +201,7 @@ class SimBrushedMotorHardwareIface StateManagerHandle _state_manager = nullptr; MoveMessageHardware _id; bool estop_detected = false; - std::atomic cancel_request = {}; + std::atomic cancel_request = false; BrushedMotorState motor_state = BrushedMotorState::UNHOMED; motor_hardware::UsageEEpromConfig eeprom_config{ std::array{UsageRequestSet{ @@ -258,7 +235,6 @@ class SimGearMotorHardwareIface void read_limit_switch() final {} void read_estop_in() final {} void read_sync_in() final {} - bool read_tmc_diag0() final { return false; } void set_LED(bool) final {} void trigger_limit_switch() { limit_switch_status = true; } bool check_sync_in() final { @@ -291,21 +267,10 @@ class SimGearMotorHardwareIface bool check_estop_in() final { return estop_detected; } void set_estop(bool estop_pressed) { estop_detected = estop_pressed; } - auto get_cancel_request() -> motor_hardware::CancelRequest final { - motor_hardware::CancelRequest exchange_request; - return cancel_request.exchange(exchange_request); - } - void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) final { - motor_hardware::CancelRequest update_request{ - .severity = static_cast(error_severity), - .code = static_cast(error_code)}; - cancel_request.store(update_request); - } - void clear_cancel_request() final { - motor_hardware::CancelRequest clear_request; - cancel_request.store(clear_request); + auto has_cancel_request() -> bool final { + return cancel_request.exchange(false); } + void request_cancel() final { cancel_request.store(true); } auto get_usage_eeprom_config() -> motor_hardware::UsageEEpromConfig & final { @@ -322,7 +287,7 @@ class SimGearMotorHardwareIface Direction _direction = Direction::POSITIVE; float _encoder_ticks_per_pulse = 0; bool estop_detected = false; - std::atomic cancel_request = {}; + std::atomic cancel_request = false; motor_hardware::UsageEEpromConfig eeprom_config = { std::array{UsageRequestSet{ .eeprom_key = 0, diff --git a/include/motor-control/tests/mock_brushed_motor_components.hpp b/include/motor-control/tests/mock_brushed_motor_components.hpp index ecfdd9b1d..410cc8632 100644 --- a/include/motor-control/tests/mock_brushed_motor_components.hpp +++ b/include/motor-control/tests/mock_brushed_motor_components.hpp @@ -42,7 +42,6 @@ class MockBrushedMotorHardware : public BrushedMotorHardwareIface { void stop_pwm() final { move_dir = PWM_DIRECTION::unset; } auto check_sync_in() -> bool final { return sync_val; } void read_sync_in() final {} - bool read_tmc_diag0() final { return diag0_val; } auto get_encoder_pulses() -> int32_t final { return (motor_encoder_overflow_count << 16) + enc_val; @@ -72,23 +71,12 @@ class MockBrushedMotorHardware : public BrushedMotorHardwareIface { PWM_DIRECTION get_direction() { return move_dir; } void set_stay_enabled(bool state) { stay_enabled = state; } auto get_stay_enabled() -> bool { return stay_enabled; } - auto get_cancel_request() -> CancelRequest final { - CancelRequest old_request = cancel_request; - CancelRequest exchange_request{}; - cancel_request = exchange_request; + auto has_cancel_request() -> bool final { + bool old_request = cancel_request; + cancel_request = false; return old_request; } - void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) final { - CancelRequest update_request{ - .severity = static_cast(error_severity), - .code = static_cast(error_code)}; - cancel_request = update_request; - } - void clear_cancel_request() final { - CancelRequest clear_request{}; - cancel_request = clear_request; - } + void request_cancel() final { cancel_request = true; } void set_timer_interrupt_running(bool is_running) { timer_interrupt_running = is_running; } @@ -109,7 +97,6 @@ class MockBrushedMotorHardware : public BrushedMotorHardwareIface { int32_t motor_encoder_overflow_count = 0; bool ls_val = false; bool sync_val = false; - bool diag0_val = false; bool estop_in_val = false; bool is_gripping = false; bool motor_enabled = false; @@ -121,7 +108,7 @@ class MockBrushedMotorHardware : public BrushedMotorHardwareIface { // when the "motor" instantly goes to top speed then instantly stops ot_utils::pid::PID controller_loop{0.008, 0.0045, 0.000015, 1.F / 32000.0, 7, -7}; - CancelRequest cancel_request = {}; + bool cancel_request = false; bool timer_interrupt_running = true; motor_hardware::UsageEEpromConfig eeprom_config = motor_hardware::UsageEEpromConfig{std::array{ diff --git a/include/motor-control/tests/mock_motor_driver_client.hpp b/include/motor-control/tests/mock_motor_driver_client.hpp deleted file mode 100644 index b4fb715ca..000000000 --- a/include/motor-control/tests/mock_motor_driver_client.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -#include "motor-control/core/tasks/tmc_motor_driver_common.hpp" - -namespace test_mocks { - -struct MockMotorDriverClient { - void send_motor_driver_queue(const tmc::tasks::TaskMessage& m) { - messages.push_back(m); - } - - void send_motor_driver_queue_isr(const tmc::tasks::TaskMessage& m) { - messages.push_back(m); - } - - std::vector messages{}; -}; - -} // namespace test_mocks diff --git a/include/motor-control/tests/mock_motor_hardware.hpp b/include/motor-control/tests/mock_motor_hardware.hpp index fc04f03b2..ff6e0bd69 100644 --- a/include/motor-control/tests/mock_motor_hardware.hpp +++ b/include/motor-control/tests/mock_motor_hardware.hpp @@ -30,7 +30,6 @@ class MockMotorHardware : public motor_hardware::StepperMotorHardwareIface { void read_limit_switch() final {} void read_estop_in() final {} void read_sync_in() final {} - bool read_tmc_diag0() final { return mock_diag0_value; } void set_LED(bool) final {} void set_mock_lim_sw(bool value) { mock_lim_sw_value = value; } void set_mock_estop_in(bool value) { mock_estop_in_value = value; } @@ -40,23 +39,12 @@ class MockMotorHardware : public motor_hardware::StepperMotorHardwareIface { void reset_encoder_pulses() final { test_pulses = 0; } int32_t get_encoder_pulses() final { return test_pulses; } void sim_set_encoder_pulses(int32_t pulses) { test_pulses = pulses; } - auto get_cancel_request() -> motor_hardware::CancelRequest final { - motor_hardware::CancelRequest old_request = cancel_request; - motor_hardware::CancelRequest exchange_request{}; - cancel_request = exchange_request; + auto has_cancel_request() -> bool final { + bool old_request = cancel_request; + cancel_request = false; return old_request; } - void set_cancel_request(can::ids::ErrorSeverity error_severity, - can::ids::ErrorCode error_code) final { - motor_hardware::CancelRequest update_request{ - .severity = static_cast(error_severity), - .code = static_cast(error_code)}; - cancel_request = update_request; - } - void clear_cancel_request() final { - motor_hardware::CancelRequest clear_request{}; - cancel_request = clear_request; - } + void request_cancel() final { cancel_request = true; } void sim_set_timer_interrupt_running(bool is_running) { mock_timer_interrupt_running = is_running; } @@ -73,12 +61,11 @@ class MockMotorHardware : public motor_hardware::StepperMotorHardwareIface { bool mock_lim_sw_value = false; bool mock_estop_in_value = false; bool mock_sync_value = false; - bool mock_diag0_value = false; bool mock_sr_value = false; bool mock_dir_value = false; uint8_t finished_move_id = 0x0; int32_t test_pulses = 0x0; - motor_hardware::CancelRequest cancel_request = {}; + bool cancel_request = false; bool mock_timer_interrupt_running = true; motor_hardware::UsageEEpromConfig eeprom_config = motor_hardware::UsageEEpromConfig{ diff --git a/include/pipettes/core/dispatch_builder.hpp b/include/pipettes/core/dispatch_builder.hpp index 7c82b97f7..e5d0950c6 100644 --- a/include/pipettes/core/dispatch_builder.hpp +++ b/include/pipettes/core/dispatch_builder.hpp @@ -23,22 +23,19 @@ using TMC2130MotorDispatchTarget = can::dispatch::DispatchParseTarget< linear_motor_tasks::tmc2130_driver::QueueClient>, can::messages::ReadMotorDriverRegister, can::messages::WriteMotorDriverRegister, - can::messages::WriteMotorCurrentRequest, - can::messages::ReadMotorDriverErrorStatusRequest>; + can::messages::WriteMotorCurrentRequest>; using TMC2160MotorDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::motor::MotorHandler< linear_motor_tasks::tmc2160_driver::QueueClient>, can::messages::ReadMotorDriverRegister, can::messages::WriteMotorDriverRegister, - can::messages::WriteMotorCurrentRequest, - can::messages::ReadMotorDriverErrorStatusRequest>; + can::messages::WriteMotorCurrentRequest>; using GearMotorDispatchTarget = can::dispatch::DispatchParseTarget< can::message_handlers::motor::GearMotorHandler< gear_motor_tasks::QueueClient>, can::messages::GearReadMotorDriverRegister, - can::messages::ReadMotorDriverErrorStatusRequest, can::messages::GearWriteMotorDriverRegister, can::messages::GearWriteMotorCurrentRequest>; diff --git a/include/pipettes/core/gear_motor_tasks.hpp b/include/pipettes/core/gear_motor_tasks.hpp index 6f4edc169..292f73b4d 100644 --- a/include/pipettes/core/gear_motor_tasks.hpp +++ b/include/pipettes/core/gear_motor_tasks.hpp @@ -31,7 +31,7 @@ using CanWriterTask = can::message_writer_task::MessageWriterTask< using SPIWriterClient = spi::writer::Writer; -auto start_tasks( +void start_tasks( CanWriterTask& can_writer, interfaces::gear_motor::GearMotionControl& motion_controllers, SPIWriterClient& spi_writer, @@ -39,10 +39,7 @@ auto start_tasks( can::ids::NodeId id, interfaces::gear_motor::GearMotorHardwareTasks& gmh_tsks, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) - -> std::tuple; - -void call_run_diag0_interrupt(); + tail_accessor); /** * Access to all the gear motion tasks. @@ -76,9 +73,6 @@ 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/interfaces.hpp b/include/pipettes/core/interfaces.hpp index abca79a9f..999e5f7ea 100644 --- a/include/pipettes/core/interfaces.hpp +++ b/include/pipettes/core/interfaces.hpp @@ -36,8 +36,6 @@ struct HighThroughputInterruptQueues { UpdatePositionQueue left_update_queue; }; -extern "C" using diag0_handler = void(*)(); - namespace gear_motor { struct UnavailableGearHardware {}; diff --git a/include/pipettes/core/linear_motor_tasks.hpp b/include/pipettes/core/linear_motor_tasks.hpp index c4511567a..ae20e52d8 100644 --- a/include/pipettes/core/linear_motor_tasks.hpp +++ b/include/pipettes/core/linear_motor_tasks.hpp @@ -12,7 +12,6 @@ #include "motor-control/core/tasks/move_status_reporter_task.hpp" #include "motor-control/core/tasks/tmc2130_motor_driver_task.hpp" #include "motor-control/core/tasks/tmc2160_motor_driver_task.hpp" -#include "pipettes/core/interfaces.hpp" #include "pipettes/core/sensor_tasks.hpp" #include "spi/core/writer.hpp" @@ -32,7 +31,7 @@ using SPIWriterClient = spi::writer::Writer; // single channel/8 channel linear motor tasks -auto start_tasks( +void start_tasks( CanWriterTask& can_writer, motion_controller::MotionController& motion_controller, @@ -40,10 +39,10 @@ auto start_tasks( tmc2130::configs::TMC2130DriverConfig& linear_driver_configs, can::ids::NodeId, motor_hardware_task::MotorHardwareTask& lmh_tsk, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) -> interfaces::diag0_handler; + tail_accessor); // 96/384 linear motor tasks -auto start_tasks( +void start_tasks( CanWriterTask& can_writer, motion_controller::MotionController& motion_controller, @@ -51,9 +50,7 @@ auto start_tasks( tmc2160::configs::TMC2160DriverConfig& linear_driver_configs, can::ids::NodeId, motor_hardware_task::MotorHardwareTask& lmh_tsk, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) -> interfaces::diag0_handler; - -void call_run_diag0_interrupt(); + tail_accessor); /** * Access to all the linear motion task queues on the pipette. @@ -137,11 +134,6 @@ 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}; }; @@ -181,11 +173,6 @@ 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 149beb395..2a53bc335 100644 --- a/include/pipettes/core/tasks.hpp +++ b/include/pipettes/core/tasks.hpp @@ -49,8 +49,6 @@ 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/pipettes/core/tasks/messages.hpp b/include/pipettes/core/tasks/messages.hpp index ed827881f..7dcd6388d 100644 --- a/include/pipettes/core/tasks/messages.hpp +++ b/include/pipettes/core/tasks/messages.hpp @@ -10,11 +10,6 @@ namespace task_messages { namespace motor_control_task_messages { -struct RouteMotorDriverInterrupt { - uint32_t message_index; - uint8_t debounce_count; -}; - using MotionControlTaskMessage = std::variant< std::monostate, can::messages::TipActionRequest, can::messages::GearDisableMotorRequest, @@ -22,7 +17,7 @@ using MotionControlTaskMessage = std::variant< can::messages::GetMotionConstraintsRequest, can::messages::SetMotionConstraints, can::messages::StopRequest, can::messages::ReadLimitSwitchRequest, can::messages::GetMotorUsageRequest, - can::messages::MotorStatusRequest, RouteMotorDriverInterrupt>; + can::messages::MotorStatusRequest>; using MoveStatusReporterTaskMessage = std::variant -concept TaskClient = requires(Client client, const TaskMessage& m) { - {client.send_motion_controller_queue(m)}; -}; - /** * The message queue message handler. */ template + usage_storage_task::TaskClient UsageClient> class MotionControllerMessageHandler { public: using MotorControllerType = pipette_motion_controller::PipetteMotionController; MotionControllerMessageHandler(MotorControllerType& controller, CanClient& can_client, - UsageClient& usage_client, - DriverClient& driver_client, - MotionClient& motion_client, - std::atomic& diag0_debounced) + UsageClient& usage_client) : controller{controller}, can_client{can_client}, - usage_client{usage_client}, - driver_client{driver_client}, - motion_client{motion_client}, - diag0_debounced{diag0_debounced} {} + usage_client{usage_client} {} MotionControllerMessageHandler(const MotionControllerMessageHandler& c) = delete; MotionControllerMessageHandler(const MotionControllerMessageHandler&& c) = @@ -78,19 +61,9 @@ class MotionControllerMessageHandler { LOG("Received enable motor request"); // TODO only toggle the enable pin once since all motors share // a single enable pin line. - if (controller.read_tmc_diag0()) { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = m.message_index, - .severity = can::ids::ErrorSeverity::unrecoverable, - .error_code = - can::ids::ErrorCode::motor_driver_error_detected}); - } else { - controller.enable_motor(); - can_client.send_can_message(can::ids::NodeId::host, - can::messages::ack_from_request(m)); - } + controller.enable_motor(); + can_client.send_can_message(can::ids::NodeId::host, + can::messages::ack_from_request(m)); } void handle(const can::messages::GearDisableMotorRequest& m) { @@ -129,17 +102,7 @@ class MotionControllerMessageHandler { LOG("Motion Controller Received a tip action request: velocity=%d, " "acceleration=%d, groupid=%d, seqid=%d\n", m.velocity, m.acceleration, m.group_id, m.seq_id); - if (controller.read_tmc_diag0()) { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = m.message_index, - .severity = can::ids::ErrorSeverity::unrecoverable, - .error_code = - can::ids::ErrorCode::motor_driver_error_detected}); - } else { - controller.move(m); - } + controller.move(m); } void handle(const can::messages::ReadLimitSwitchRequest& m) { @@ -154,44 +117,6 @@ class MotionControllerMessageHandler { controller.send_usage_data(m.message_index, usage_client); } - void handle(const pipettes::task_messages::motor_control_task_messages:: - RouteMotorDriverInterrupt& m) { - if (m.debounce_count > 9) { - if (controller.read_tmc_diag0()) { - controller.stop( - can::ids::ErrorSeverity::unrecoverable, - can::ids::ErrorCode::motor_driver_error_detected); - if (!controller.is_timer_interrupt_running()) { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = m.message_index, - .severity = can::ids::ErrorSeverity::unrecoverable, - .error_code = can::ids::ErrorCode:: - motor_driver_error_detected}); - driver_client.send_motor_driver_queue( - can::messages::ReadMotorDriverErrorStatusRequest{ - .message_index = m.message_index}); - } - } - diag0_debounced = false; - } else { - vTaskDelay(pdMS_TO_TICKS(100)); - motion_client.send_motion_controller_queue( - increment_message_debounce_count(m)); - } - } - - auto increment_message_debounce_count( - const pipettes::task_messages::motor_control_task_messages:: - RouteMotorDriverInterrupt& m) -> pipettes::task_messages:: - motor_control_task_messages::RouteMotorDriverInterrupt { - return pipettes::task_messages::motor_control_task_messages:: - RouteMotorDriverInterrupt{ - .message_index = m.message_index, - .debounce_count = static_cast(m.debounce_count + 1)}; - } - void handle(const can::messages::MotorStatusRequest& m) { auto response = static_cast(controller.is_motor_enabled()); can::messages::GearMotorStatusResponse msg{ @@ -202,9 +127,6 @@ class MotionControllerMessageHandler { MotorControllerType& controller; CanClient& can_client; UsageClient& usage_client; - DriverClient& driver_client; - MotionClient& motion_client; - std::atomic& diag0_debounced; }; /** @@ -228,16 +150,13 @@ class MotionControllerTask { */ template + usage_storage_task::TaskClient UsageClient> [[noreturn]] void operator()( pipette_motion_controller::PipetteMotionController* controller, - CanClient* can_client, UsageClient* usage_client, - DriverClient* driver_client, MotionClient* motion_client) { - auto handler = MotionControllerMessageHandler{ - *controller, *can_client, *usage_client, - *driver_client, *motion_client, diag0_debounced}; + CanClient* can_client, UsageClient* usage_client) { + auto handler = MotionControllerMessageHandler{*controller, *can_client, + *usage_client}; TaskMessage message{}; for (;;) { if (queue.try_read(&message, queue.max_delay)) { @@ -248,19 +167,17 @@ class MotionControllerTask { [[nodiscard]] auto get_queue() const -> QueueType& { return queue; } - void run_diag0_interrupt() { - if (!diag0_debounced) { - static_cast(queue.try_write_isr( - pipettes::task_messages::motor_control_task_messages:: - RouteMotorDriverInterrupt{.message_index = 0, - .debounce_count = 0})); - diag0_debounced = true; - } - } - private: QueueType& queue; - std::atomic diag0_debounced = false; +}; + +/** + * Concept describing a class that can message this task. + * @tparam Client + */ +template +concept TaskClient = requires(Client client, const TaskMessage& m) { + {client.send_motion_controller_queue(m)}; }; } // namespace motion_controller_task diff --git a/include/pipettes/firmware/interfaces.hpp b/include/pipettes/firmware/interfaces.hpp index d4982a2ff..665da11ed 100644 --- a/include/pipettes/firmware/interfaces.hpp +++ b/include/pipettes/firmware/interfaces.hpp @@ -34,7 +34,7 @@ using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler< #endif template using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler< - freertos_message_queue::FreeRTOSMessageQueue, Client, Client, + freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::GearMotorMove, motor_hardware::MotorHardware>; template diff --git a/include/pipettes/firmware/interfaces_g4.hpp b/include/pipettes/firmware/interfaces_g4.hpp index 376151874..b22915939 100644 --- a/include/pipettes/firmware/interfaces_g4.hpp +++ b/include/pipettes/firmware/interfaces_g4.hpp @@ -43,7 +43,7 @@ using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler< #endif template using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler< - freertos_message_queue::FreeRTOSMessageQueue, Client, Client, + freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::GearMotorMove, motor_hardware::MotorHardware>; template diff --git a/include/pipettes/simulator/interfaces.hpp b/include/pipettes/simulator/interfaces.hpp index 369c65f0e..b646bf55e 100644 --- a/include/pipettes/simulator/interfaces.hpp +++ b/include/pipettes/simulator/interfaces.hpp @@ -12,14 +12,14 @@ namespace interfaces { -template +template using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler< - freertos_message_queue::FreeRTOSMessageQueue, Client, DriverClient, - motor_messages::Move, sim_motor_hardware_iface::SimMotorHardwareIface>; + freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::Move, + sim_motor_hardware_iface::SimMotorHardwareIface>; template using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler< - freertos_message_queue::FreeRTOSMessageQueue, Client, Client, + freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::GearMotorMove, sim_motor_hardware_iface::SimGearMotorHardwareIface>; @@ -61,39 +61,16 @@ auto get_interrupt_queues() namespace linear_motor { auto get_interrupt(sim_motor_hardware_iface::SimMotorHardwareIface& hw, - LowThroughputInterruptQueues& queues, - stall_check::StallCheck& stall) - -> MotorInterruptHandlerType< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2130_driver::QueueClient>; - -auto get_interrupt(sim_motor_hardware_iface::SimMotorHardwareIface& hw, - HighThroughputInterruptQueues& queues, - stall_check::StallCheck& stall) - -> MotorInterruptHandlerType< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2160_driver::QueueClient>; - -auto get_interrupt_driver( - sim_motor_hardware_iface::SimMotorHardwareIface& hw, - LowThroughputInterruptQueues& queues, - MotorInterruptHandlerType& - handler) - -> motor_interrupt_driver::MotorInterruptDriver< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2130_driver::QueueClient, motor_messages::Move, - sim_motor_hardware_iface::SimMotorHardwareIface>; + MoveQueue& queue, stall_check::StallCheck& stall, + UpdatePositionQueue& update_queue) + -> MotorInterruptHandlerType; auto get_interrupt_driver( - sim_motor_hardware_iface::SimMotorHardwareIface& hw, - HighThroughputInterruptQueues& queues, - MotorInterruptHandlerType& - handler) + sim_motor_hardware_iface::SimMotorHardwareIface& hw, MoveQueue& queue, + MotorInterruptHandlerType& handler, + UpdatePositionQueue& update_queue) -> motor_interrupt_driver::MotorInterruptDriver< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2160_driver::QueueClient, motor_messages::Move, + linear_motor_tasks::QueueClient, motor_messages::Move, sim_motor_hardware_iface::SimMotorHardwareIface>; auto get_motor_hardware() -> sim_motor_hardware_iface::SimMotorHardwareIface; @@ -116,13 +93,11 @@ struct GearInterruptHandlers { struct GearInterruptDrivers { motor_interrupt_driver::MotorInterruptDriver< - gear_motor_tasks::QueueClient, gear_motor_tasks::QueueClient, - motor_messages::GearMotorMove, + gear_motor_tasks::QueueClient, motor_messages::GearMotorMove, sim_motor_hardware_iface::SimGearMotorHardwareIface> left; motor_interrupt_driver::MotorInterruptDriver< - gear_motor_tasks::QueueClient, gear_motor_tasks::QueueClient, - motor_messages::GearMotorMove, + gear_motor_tasks::QueueClient, motor_messages::GearMotorMove, sim_motor_hardware_iface::SimGearMotorHardwareIface> right; }; diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index 85a98d8f0..9a398f2d6 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -365,13 +365,6 @@ class MMR920 { if (sensor_buffer_index < SENSOR_BUFFER_SIZE) { (*p_buff).at(sensor_buffer_index) = pressure; sensor_buffer_index++; - } else { - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ErrorMessage{ - .message_index = 0, - .severity = can::ids::ErrorSeverity::warning, - .error_code = can::ids::ErrorCode::stop_requested}); } #else can_client.send_can_message( @@ -518,9 +511,13 @@ class MMR920 { * exceed the threshold for the entirety of this period. */ static constexpr uint16_t MAX_PRESSURE_TIME_MS = 200; - +#ifdef USE_PRESSURE_MOVE mmr920::MeasurementRate measurement_mode_rate = mmr920::MeasurementRate::MEASURE_1; +#else + mmr920::MeasurementRate measurement_mode_rate = + mmr920::MeasurementRate::MEASURE_4; +#endif bool _initialized = false; bool echoing = false; diff --git a/include/spi/core/utils.hpp b/include/spi/core/utils.hpp index 0f28e89fa..e41b4468f 100644 --- a/include/spi/core/utils.hpp +++ b/include/spi/core/utils.hpp @@ -16,39 +16,6 @@ struct ChipSelectInterface { void* GPIO_handle; }; -// Bit positions to pack in an 8 bit response tag -enum class ResponseTag : size_t { - IS_ERROR_RESPONSE = 0, -}; - -[[nodiscard]] constexpr auto byte_from_tag(ResponseTag tag) -> uint8_t { - return (1 << static_cast(tag)); -} - -template -[[nodiscard]] auto byte_from_tags(const Tags& tags) -> uint8_t { - uint8_t result = 0; - for (auto tag : tags) { - result |= byte_from_tag(tag); - } - return result; -} - -[[nodiscard]] inline constexpr auto tag_in_token(uint32_t token, - ResponseTag tag) -> bool { - return bool(token & - (1 << (static_cast(tag) + static_cast(8)))); -} - -[[nodiscard]] inline constexpr auto build_token(uint8_t reg, uint8_t tags = 0) - -> uint32_t { - return (static_cast(tags) << 8) | (reg); -} - -template -[[nodiscard]] inline constexpr auto reg_from_token(uint32_t id) -> RegType { - return static_cast(static_cast(id & 0xff)); -} } // namespace utils -} // namespace spi +} // namespace spi \ No newline at end of file diff --git a/include/spi/core/writer.hpp b/include/spi/core/writer.hpp index cf887f4b6..a3e2e1710 100644 --- a/include/spi/core/writer.hpp +++ b/include/spi/core/writer.hpp @@ -46,13 +46,13 @@ class Writer { * @return A success boolean */ template - auto read(uint32_t token, uint32_t command_data, RQType& response_queue, - utils::ChipSelectInterface cs_intf, uint32_t message_index) - -> bool { - auto txBuffer = build_message(utils::reg_from_token(token), - spi::hardware::Mode::READ, command_data); + auto read(uint8_t register_addr, uint32_t command_data, + RQType& response_queue, utils::ChipSelectInterface cs_intf, + uint32_t message_index) -> bool { + auto txBuffer = build_message(register_addr, spi::hardware::Mode::READ, + command_data); TransactionIdentifier _transaction_id{ - .token = token, + .token = register_addr, .command_type = static_cast(spi::hardware::Mode::READ), .requires_response = false, .message_index = message_index}; @@ -83,7 +83,7 @@ class Writer { auto txBuffer = build_message(register_addr, spi::hardware::Mode::WRITE, command_data); TransactionIdentifier _transaction_id{ - .token = utils::build_token(register_addr), + .token = register_addr, .command_type = static_cast(spi::hardware::Mode::WRITE), .requires_response = true}; Transact message{ diff --git a/motor-control/firmware/brushed_motor/brushed_motor_hardware.cpp b/motor-control/firmware/brushed_motor/brushed_motor_hardware.cpp index 1d7690cfd..2b5d1314d 100644 --- a/motor-control/firmware/brushed_motor/brushed_motor_hardware.cpp +++ b/motor-control/firmware/brushed_motor/brushed_motor_hardware.cpp @@ -58,8 +58,6 @@ void BrushedMotorHardware::read_sync_in() { sync.debounce_update(gpio::is_set(pins.sync_in)); } -bool BrushedMotorHardware::read_tmc_diag0() { return 0; } - int32_t BrushedMotorHardware::get_encoder_pulses() { if (!enc_handle) { return 0; diff --git a/motor-control/firmware/motor_control_hardware.c b/motor-control/firmware/motor_control_hardware.c index d4cdb534a..a6275b459 100644 --- a/motor-control/firmware/motor_control_hardware.c +++ b/motor-control/firmware/motor_control_hardware.c @@ -133,7 +133,7 @@ uint16_t motor_hardware_get_stopwatch_pulses(void* stopwatch_handle, uint8_t cle } void motor_hardware_delay(uint32_t delay) { - HAL_Delay(delay); + vTaskDelay(delay); } diff --git a/motor-control/firmware/stepper_motor/motor_hardware.cpp b/motor-control/firmware/stepper_motor/motor_hardware.cpp index 7cee57b34..76c64faa1 100644 --- a/motor-control/firmware/stepper_motor/motor_hardware.cpp +++ b/motor-control/firmware/stepper_motor/motor_hardware.cpp @@ -50,8 +50,6 @@ void MotorHardware::read_estop_in() { void MotorHardware::read_sync_in() { sync = gpio::is_set(pins.sync_in); } -bool MotorHardware::read_tmc_diag0() { return gpio::is_set(pins.diag0); } - void MotorHardware::set_LED(bool status) { if (status) { gpio::set(pins.led); diff --git a/motor-control/tests/test_brushed_motor_interrupt_handler.cpp b/motor-control/tests/test_brushed_motor_interrupt_handler.cpp index 9f1e9e7a7..578754c46 100644 --- a/motor-control/tests/test_brushed_motor_interrupt_handler.cpp +++ b/motor-control/tests/test_brushed_motor_interrupt_handler.cpp @@ -523,9 +523,7 @@ SCENARIO("handler recovers from error state") { test_objs.handler.error_handled = true; WHEN("a cancel request is received") { - test_objs.hw.set_cancel_request( - can::ids::ErrorSeverity::warning, - can::ids::ErrorCode::stop_requested); + test_objs.hw.request_cancel(); test_objs.handler.run_interrupt(); THEN( "motor state should become un-homed only if stay engaged is " diff --git a/motor-control/tests/test_limit_switch.cpp b/motor-control/tests/test_limit_switch.cpp index 962874bee..8dbd107a2 100644 --- a/motor-control/tests/test_limit_switch.cpp +++ b/motor-control/tests/test_limit_switch.cpp @@ -2,7 +2,6 @@ #include "common/tests/mock_message_queue.hpp" #include "motor-control/core/motor_messages.hpp" #include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" -#include "motor-control/tests/mock_motor_driver_client.hpp" #include "motor-control/tests/mock_motor_hardware.hpp" #include "motor-control/tests/mock_move_status_reporter_client.hpp" @@ -17,12 +16,11 @@ struct HandlerContainer { can::messages::UpdateMotorPositionEstimationRequest> update_position_queue{}; test_mocks::MockMoveStatusReporterClient reporter{}; - test_mocks::MockMotorDriverClient driver{}; stall_check::StallCheck stall{10, 10, 10}; - MotorInterruptHandler< - test_mocks::MockMessageQueue, test_mocks::MockMoveStatusReporterClient, - test_mocks::MockMotorDriverClient, Move, test_mocks::MockMotorHardware> - handler{queue, reporter, driver, hw, stall, update_position_queue}; + MotorInterruptHandler + handler{queue, reporter, hw, stall, update_position_queue}; }; static constexpr sq0_31 default_velocity = diff --git a/motor-control/tests/test_limit_switch_backoff.cpp b/motor-control/tests/test_limit_switch_backoff.cpp index df1e462a1..c4967c890 100644 --- a/motor-control/tests/test_limit_switch_backoff.cpp +++ b/motor-control/tests/test_limit_switch_backoff.cpp @@ -2,7 +2,6 @@ #include "common/tests/mock_message_queue.hpp" #include "motor-control/core/motor_messages.hpp" #include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" -#include "motor-control/tests/mock_motor_driver_client.hpp" #include "motor-control/tests/mock_motor_hardware.hpp" #include "motor-control/tests/mock_move_status_reporter_client.hpp" @@ -17,12 +16,11 @@ struct HandlerContainer { can::messages::UpdateMotorPositionEstimationRequest> update_position_queue{}; test_mocks::MockMoveStatusReporterClient reporter{}; - test_mocks::MockMotorDriverClient driver{}; stall_check::StallCheck stall{10, 10, 10}; - MotorInterruptHandler< - test_mocks::MockMessageQueue, test_mocks::MockMoveStatusReporterClient, - test_mocks::MockMotorDriverClient, Move, test_mocks::MockMotorHardware> - handler{queue, reporter, driver, hw, stall, update_position_queue}; + MotorInterruptHandler + handler{queue, reporter, hw, stall, update_position_queue}; }; SCENARIO( diff --git a/motor-control/tests/test_motor_interrupt_handler.cpp b/motor-control/tests/test_motor_interrupt_handler.cpp index 3c44db5f4..cb83e8443 100644 --- a/motor-control/tests/test_motor_interrupt_handler.cpp +++ b/motor-control/tests/test_motor_interrupt_handler.cpp @@ -3,7 +3,6 @@ #include "common/tests/mock_message_queue.hpp" #include "motor-control/core/motor_messages.hpp" #include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" -#include "motor-control/tests/mock_motor_driver_client.hpp" #include "motor-control/tests/mock_motor_hardware.hpp" #include "motor-control/tests/mock_move_status_reporter_client.hpp" @@ -16,13 +15,11 @@ struct MotorContainer { can::messages::UpdateMotorPositionEstimationRequest> update_position_queue{}; test_mocks::MockMoveStatusReporterClient reporter{}; - test_mocks::MockMotorDriverClient driver{}; stall_check::StallCheck st{1, 1, 10}; MotorInterruptHandler - handler{queue, reporter, driver, hw, st, update_position_queue}; + handler{queue, reporter, hw, st, update_position_queue}; }; SCENARIO("a move is cancelled due to a stop request") { @@ -44,9 +41,7 @@ SCENARIO("a move is cancelled due to a stop request") { test_objs.handler.run_interrupt(); test_objs.handler.run_interrupt(); CHECK(test_objs.hw.steps_taken() == 1); - test_objs.hw.set_cancel_request( - can::ids::ErrorSeverity::warning, - can::ids::ErrorCode::stop_requested); + test_objs.hw.request_cancel(); test_objs.handler.run_interrupt(); THEN("An error and increase error count is sent") { REQUIRE(test_objs.reporter.messages.size() == 2); diff --git a/motor-control/tests/test_motor_interrupt_queue.cpp b/motor-control/tests/test_motor_interrupt_queue.cpp index 906da0ebd..9d3de068e 100644 --- a/motor-control/tests/test_motor_interrupt_queue.cpp +++ b/motor-control/tests/test_motor_interrupt_queue.cpp @@ -2,7 +2,6 @@ #include "catch2/catch.hpp" #include "common/tests/mock_message_queue.hpp" #include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" -#include "motor-control/tests/mock_motor_driver_client.hpp" #include "motor-control/tests/mock_motor_hardware.hpp" #include "motor-control/tests/mock_move_status_reporter_client.hpp" @@ -16,11 +15,10 @@ TEST_CASE("motor interrupt handler queue functionality") { can::messages::UpdateMotorPositionEstimationRequest> update_position_queue; test_mocks::MockMoveStatusReporterClient reporter{}; - test_mocks::MockMotorDriverClient driver{}; test_mocks::MockMotorHardware hardware; stall_check::StallCheck stall(10, 10, 10); - auto handler = MotorInterruptHandler(queue, reporter, driver, hardware, - stall, update_position_queue); + auto handler = MotorInterruptHandler(queue, reporter, hardware, stall, + update_position_queue); WHEN("add multiple moves to the queue") { THEN("all the moves should exist in order") { diff --git a/motor-control/tests/test_motor_pulse.cpp b/motor-control/tests/test_motor_pulse.cpp index 312aa86d2..856edaad1 100644 --- a/motor-control/tests/test_motor_pulse.cpp +++ b/motor-control/tests/test_motor_pulse.cpp @@ -1,7 +1,6 @@ #include "catch2/catch.hpp" #include "common/tests/mock_message_queue.hpp" #include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" -#include "motor-control/tests/mock_motor_driver_client.hpp" #include "motor-control/tests/mock_motor_hardware.hpp" #include "motor-control/tests/mock_move_status_reporter_client.hpp" @@ -22,12 +21,11 @@ struct HandlerContainer { can::messages::UpdateMotorPositionEstimationRequest> update_position_queue{}; test_mocks::MockMoveStatusReporterClient reporter{}; - test_mocks::MockMotorDriverClient driver{}; stall_check::StallCheck stall{tick_per_um, tick_per_um, stall_threshold_um}; - MotorInterruptHandler< - test_mocks::MockMessageQueue, test_mocks::MockMoveStatusReporterClient, - test_mocks::MockMotorDriverClient, Move, test_mocks::MockMotorHardware> - handler{queue, reporter, driver, hw, stall, update_position_queue}; + MotorInterruptHandler + handler{queue, reporter, hw, stall, update_position_queue}; }; sq0_31 convert_velocity(float f) { diff --git a/motor-control/tests/test_motor_stall_handling.cpp b/motor-control/tests/test_motor_stall_handling.cpp index f75b2db23..07ddb5006 100644 --- a/motor-control/tests/test_motor_stall_handling.cpp +++ b/motor-control/tests/test_motor_stall_handling.cpp @@ -2,7 +2,6 @@ #include "common/tests/mock_message_queue.hpp" #include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" #include "motor-control/core/usage_messages.hpp" -#include "motor-control/tests/mock_motor_driver_client.hpp" #include "motor-control/tests/mock_motor_hardware.hpp" #include "motor-control/tests/mock_move_status_reporter_client.hpp" @@ -22,12 +21,11 @@ struct HandlerContainer { can::messages::UpdateMotorPositionEstimationRequest> update_position_queue{}; test_mocks::MockMoveStatusReporterClient reporter{}; - test_mocks::MockMotorDriverClient driver{}; stall_check::StallCheck stall{tick_per_um, tick_per_um, stall_threshold_um}; - MotorInterruptHandler< - test_mocks::MockMessageQueue, test_mocks::MockMoveStatusReporterClient, - test_mocks::MockMotorDriverClient, Move, test_mocks::MockMotorHardware> - handler{queue, reporter, driver, hw, stall, update_position_queue}; + MotorInterruptHandler + handler{queue, reporter, hw, stall, update_position_queue}; }; SCENARIO("motor handler stall detection") { diff --git a/motor-control/tests/test_sync_handling.cpp b/motor-control/tests/test_sync_handling.cpp index f35e21d0c..aa59325a5 100644 --- a/motor-control/tests/test_sync_handling.cpp +++ b/motor-control/tests/test_sync_handling.cpp @@ -2,7 +2,6 @@ #include "common/tests/mock_message_queue.hpp" #include "motor-control/core/motor_messages.hpp" #include "motor-control/core/stepper_motor/motor_interrupt_handler.hpp" -#include "motor-control/tests/mock_motor_driver_client.hpp" #include "motor-control/tests/mock_motor_hardware.hpp" #include "motor-control/tests/mock_move_status_reporter_client.hpp" @@ -17,12 +16,11 @@ struct HandlerContainer { can::messages::UpdateMotorPositionEstimationRequest> update_position_queue{}; test_mocks::MockMoveStatusReporterClient reporter{}; - test_mocks::MockMotorDriverClient driver{}; stall_check::StallCheck stall{10, 10, 10}; - MotorInterruptHandler< - test_mocks::MockMessageQueue, test_mocks::MockMoveStatusReporterClient, - test_mocks::MockMotorDriverClient, Move, test_mocks::MockMotorHardware> - handler{queue, reporter, driver, hw, stall, update_position_queue}; + MotorInterruptHandler + handler{queue, reporter, hw, stall, update_position_queue}; }; static constexpr sq0_31 default_velocity = diff --git a/pipettes/core/gear_motor_tasks.cpp b/pipettes/core/gear_motor_tasks.cpp index 43e4d5585..c5caabc5d 100644 --- a/pipettes/core/gear_motor_tasks.cpp +++ b/pipettes/core/gear_motor_tasks.cpp @@ -37,21 +37,7 @@ static auto move_status_task_builder_right = freertos_task::TaskStarter< static auto left_usage_storage_task_builder = freertos_task::TaskStarter<256, usage_storage_task::UsageStorageTask>{}; -void call_run_diag0_left_interrupt() { - if (gear_motor_tasks::get_left_gear_tasks().motion_controller) { - return gear_motor_tasks::get_left_gear_tasks() - .motion_controller->run_diag0_interrupt(); - } -} - -void call_run_diag0_right_interrupt() { - if (gear_motor_tasks::get_right_gear_tasks().motion_controller) { - return gear_motor_tasks::get_right_gear_tasks() - .motion_controller->run_diag0_interrupt(); - } -} - -auto gear_motor_tasks::start_tasks( +void gear_motor_tasks::start_tasks( gear_motor_tasks::CanWriterTask& can_writer, interfaces::gear_motor::GearMotionControl& motion_controllers, gear_motor_tasks::SPIWriterClient& spi_writer, @@ -59,8 +45,7 @@ auto gear_motor_tasks::start_tasks( can::ids::NodeId id, interfaces::gear_motor::GearMotorHardwareTasks& gmh_tsks, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) - -> std::tuple { + tail_accessor) { left_queue_client.set_node_id(id); right_queue_client.set_node_id(id); @@ -70,9 +55,9 @@ auto gear_motor_tasks::start_tasks( auto& right_tasks = gear_motor_tasks::get_right_gear_tasks(); // Left Gear Motor Tasks - auto& motion_left = mc_task_builder_left.start( - 5, "motion controller", motion_controllers.left, left_queues, - left_queues, left_queues, left_queues); + auto& motion_left = mc_task_builder_left.start(5, "motion controller", + motion_controllers.left, + left_queues, left_queues); auto& tmc2160_driver_left = tmc2160_driver_task_builder_left.start( 5, "tmc2160 driver", gear_driver_configs.left_gear_motor, left_queues, spi_writer); @@ -102,7 +87,7 @@ auto gear_motor_tasks::start_tasks( // Right Gear Motor Tasks auto& motion_right = mc_task_builder_right.start( 5, "motion controller", motion_controllers.right, right_queues, - right_queues, right_queues, right_queues); + right_queues); auto& tmc2160_driver_right = tmc2160_driver_task_builder_right.start( 5, "tmc2160 driver", gear_driver_configs.right_gear_motor, right_queues, spi_writer); @@ -131,9 +116,6 @@ auto gear_motor_tasks::start_tasks( gmh_tsks.left.start_task(); gmh_tsks.right.start_task(); - - return std::make_tuple(call_run_diag0_left_interrupt, - call_run_diag0_right_interrupt); } gear_motor_tasks::QueueClient::QueueClient() @@ -151,11 +133,6 @@ 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); diff --git a/pipettes/core/linear_motor_tasks.cpp b/pipettes/core/linear_motor_tasks.cpp index 86bd526e3..67909454b 100644 --- a/pipettes/core/linear_motor_tasks.cpp +++ b/pipettes/core/linear_motor_tasks.cpp @@ -31,7 +31,7 @@ static auto linear_usage_storage_task_builder = static auto eeprom_data_rev_update_builder = freertos_task::TaskStarter<256, eeprom::data_rev_task::UpdateDataRevTask>{}; -auto linear_motor_tasks::start_tasks( +void linear_motor_tasks::start_tasks( linear_motor_tasks::CanWriterTask& can_writer, motion_controller::MotionController& motion_controller, @@ -39,7 +39,7 @@ auto linear_motor_tasks::start_tasks( tmc2130::configs::TMC2130DriverConfig& linear_driver_configs, can::ids::NodeId id, motor_hardware_task::MotorHardwareTask& lmh_tsk, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) -> interfaces::diag0_handler { + tail_accessor) { tmc2130_queue_client.set_node_id(id); motion_queue_client.set_node_id(id); @@ -49,9 +49,8 @@ auto linear_motor_tasks::start_tasks( auto& motion_tasks = linear_motor_tasks::get_tasks(); // Linear Motor Tasks - auto& motion = - mc_task_builder.start(5, "motion controller", motion_controller, queues, - queues, tmc2130_queues, queues); + auto& motion = mc_task_builder.start(5, "motion controller", + motion_controller, queues, queues); auto& tmc2130_driver = tmc2130_driver_task_builder.start( 5, "tmc2130 driver", linear_driver_configs, queues, spi_writer); auto& move_group = @@ -81,11 +80,9 @@ auto linear_motor_tasks::start_tasks( queues.move_status_report_queue = &move_status_reporter.get_queue(); queues.usage_storage_queue = &usage_storage_task.get_queue(); lmh_tsk.start_task(); - - return linear_motor_tasks::call_run_diag0_interrupt; } -auto linear_motor_tasks::start_tasks( +void linear_motor_tasks::start_tasks( linear_motor_tasks::CanWriterTask& can_writer, motion_controller::MotionController& motion_controller, @@ -93,7 +90,7 @@ auto linear_motor_tasks::start_tasks( tmc2160::configs::TMC2160DriverConfig& linear_driver_configs, can::ids::NodeId id, motor_hardware_task::MotorHardwareTask& lmh_tsk, eeprom::dev_data::DevDataTailAccessor& - tail_accessor) -> interfaces::diag0_handler { + tail_accessor) { tmc2160_queue_client.set_node_id(id); motion_queue_client.set_node_id(id); @@ -103,9 +100,8 @@ auto linear_motor_tasks::start_tasks( auto& motion_tasks = linear_motor_tasks::get_tasks(); // Linear Motor Tasks - auto& motion = - mc_task_builder.start(5, "motion controller", motion_controller, queues, - queues, tmc2160_queues, queues); + auto& motion = mc_task_builder.start(5, "motion controller", + motion_controller, queues, queues); auto& tmc2160_driver = tmc2160_driver_task_builder.start( 5, "tmc2160 driver", linear_driver_configs, queues, spi_writer); auto& move_group = @@ -137,15 +133,6 @@ auto linear_motor_tasks::start_tasks( queues.usage_storage_queue = &usage_storage_task.get_queue(); lmh_tsk.start_task(); - - return linear_motor_tasks::call_run_diag0_interrupt; -} - -void linear_motor_tasks::call_run_diag0_interrupt() { - if (linear_motor_tasks::get_tasks().motion_controller) { - return linear_motor_tasks::get_tasks() - .motion_controller->run_diag0_interrupt(); - } } linear_motor_tasks::QueueClient::QueueClient() diff --git a/pipettes/firmware/hardware_config.c b/pipettes/firmware/hardware_config.c index b4ada4b98..336feaad2 100644 --- a/pipettes/firmware/hardware_config.c +++ b/pipettes/firmware/hardware_config.c @@ -42,9 +42,6 @@ IRQn_Type get_interrupt_line(GPIOInterruptBlock gpio_pin_type) { // Tip sense line for the 96 channel (rear) // PC7 -> GPIO_EXTI6 (EXTI9_5_IRQn) - - // Diag0 line for the 96 channel - // PB6 -> GPIO_EXTI6 (EXTI9_5_IRQn) return EXTI9_5_IRQn; case gpio_block_15_10: // Data ready line for 96 channel (front) @@ -52,9 +49,6 @@ IRQn_Type get_interrupt_line(GPIOInterruptBlock gpio_pin_type) { // Tip sense line for the 96 channel (front) // PC12 -> GPIO_EXTI11 (EXTI15_10_IRQn) - - // Diag0 line for single and eight channel - // PC11 -> GPIO_EXTI11 (EXTI15_10_IRQn) return EXTI15_10_IRQn; case gpio_block_3: // Single channel data ready line @@ -178,7 +172,8 @@ static uint16_t get_motor_driver_pins_lt(GPIO_TypeDef* for_handle) { * Step Pin -> PC7 * Enable Pin -> PA10 * - * VREF (TMC2130) -> PA5 + * VREF (TMC2130) + * PA5 */ switch((uint32_t)for_handle) { case (uint32_t)GPIOA: return GPIO_PIN_10; @@ -224,15 +219,3 @@ uint16_t pipette_hardware_motor_driver_pins(const PipetteType pipette_type, GPIO return get_motor_driver_pins_lt(for_handle); } } - -uint16_t pipette_hardware_motor_driver_diag0_pin(const PipetteType pipette_type) { - switch (pipette_type) { - case NINETY_SIX_CHANNEL: - case THREE_EIGHTY_FOUR_CHANNEL: - return GPIO_PIN_6; - case SINGLE_CHANNEL: - case EIGHT_CHANNEL: - default: - return GPIO_PIN_11; - } -} diff --git a/pipettes/firmware/hardware_config.h b/pipettes/firmware/hardware_config.h index 730cd48e2..d203ddb49 100644 --- a/pipettes/firmware/hardware_config.h +++ b/pipettes/firmware/hardware_config.h @@ -1,5 +1,4 @@ #pragma once -#include #include "pipettes/core/pipette_type.h" #include "platform_specific_hal_conf.h" @@ -26,6 +25,5 @@ typedef enum { uint16_t pipette_hardware_spi_pins(const PipetteType pipette_type, GPIO_TypeDef* which_handle); uint16_t pipette_hardware_motor_driver_pins(const PipetteType pipette_type, GPIO_TypeDef* for_handle); -uint16_t pipette_hardware_motor_driver_diag0_pin(const PipetteType pipette_type); PipetteHardwarePin pipette_hardware_get_gpio(const PipetteType pipette_type, PipetteHardwareDevice device); IRQn_Type get_interrupt_line(GPIOInterruptBlock gpio_pin_type); diff --git a/pipettes/firmware/interfaces.cpp b/pipettes/firmware/interfaces.cpp index 309db9df2..55fbccbc1 100644 --- a/pipettes/firmware/interfaces.cpp +++ b/pipettes/firmware/interfaces.cpp @@ -139,12 +139,10 @@ auto gear_motor::get_interrupts(gear_motor::GearHardware& hw, return gear_motor::GearInterruptHandlers{ .left = motor_handler::MotorInterruptHandler( queues.left_motor_queue, gear_motor_tasks::get_left_gear_queues(), - gear_motor_tasks::get_left_gear_queues(), hw.left, stall.left, - queues.left_update_queue), + hw.left, stall.left, queues.left_update_queue), .right = motor_handler::MotorInterruptHandler( queues.right_motor_queue, gear_motor_tasks::get_right_gear_queues(), - gear_motor_tasks::get_right_gear_queues(), hw.right, stall.right, - queues.right_update_queue)}; + hw.right, stall.right, queues.right_update_queue)}; } auto gear_motor::get_interrupts(gear_motor::UnavailableGearHardware&, diff --git a/pipettes/firmware/main.cpp b/pipettes/firmware/main.cpp index fd28b4064..84ef3c5a0 100644 --- a/pipettes/firmware/main.cpp +++ b/pipettes/firmware/main.cpp @@ -46,10 +46,6 @@ constexpr auto PIPETTE_TYPE = get_pipette_type(); static auto iWatchdog = iwdg::IndependentWatchDog{}; -static interfaces::diag0_handler call_linear_diag0_handler = nullptr; -static interfaces::diag0_handler call_left_gear_diag0_handler = nullptr; -static interfaces::diag0_handler call_right_gear_diag0_handler = nullptr; - static auto can_bus_1 = can::hal::bus::HalCanBus( can_get_device_handle(), utility_configs::led_gpio(PIPETTE_TYPE)); @@ -150,22 +146,6 @@ extern "C" void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { sensor_queue_client.tip_notification_queue_rear->try_write_isr( sensors::tip_presence::TipStatusChangeDetected{})); } - } else if (GPIO_Pin == linear_motor_hardware.get_pins().diag0.pin) { - if (call_linear_diag0_handler != nullptr) { - if (*call_linear_diag0_handler != nullptr) { - (*call_linear_diag0_handler)(); - } - } - if (call_left_gear_diag0_handler != nullptr) { - if (*call_left_gear_diag0_handler != nullptr) { - (*call_left_gear_diag0_handler)(); - } - } - if (call_right_gear_diag0_handler != nullptr) { - if (*call_right_gear_diag0_handler != nullptr) { - (*call_right_gear_diag0_handler)(); - } - } } } @@ -218,15 +198,13 @@ auto initialize_motor_tasks( initialize_linear_timer(plunger_callback); initialize_gear_timer(gear_callback_wrapper); initialize_enc_timer(encoder_callback); - call_linear_diag0_handler = linear_motor_tasks::start_tasks( + linear_motor_tasks::start_tasks( *central_tasks::get_tasks().can_writer, linear_motion_control, peripheral_tasks::get_spi_client(), conf.linear_motor, id, lmh_tsk, tail_accessor); - std::tie(call_left_gear_diag0_handler, call_right_gear_diag0_handler) = - gear_motor_tasks::start_tasks(*central_tasks::get_tasks().can_writer, - gear_motion, - peripheral_tasks::get_spi_client(), conf, - id, gmh_tsks, tail_accessor); + gear_motor_tasks::start_tasks( + *central_tasks::get_tasks().can_writer, gear_motion, + peripheral_tasks::get_spi_client(), conf, id, gmh_tsks, tail_accessor); } auto initialize_motor_tasks( can::ids::NodeId id, @@ -257,7 +235,7 @@ auto initialize_motor_tasks( initialize_linear_timer(plunger_callback); initialize_enc_timer(encoder_callback); - call_linear_diag0_handler = linear_motor_tasks::start_tasks( + linear_motor_tasks::start_tasks( *central_tasks::get_tasks().can_writer, linear_motion_control, peripheral_tasks::get_spi_client(), conf.linear_motor, id, lmh_tsk, tail_accessor); diff --git a/pipettes/firmware/motor_configurations.cpp b/pipettes/firmware/motor_configurations.cpp index 70c96da5e..425cd544b 100644 --- a/pipettes/firmware/motor_configurations.cpp +++ b/pipettes/firmware/motor_configurations.cpp @@ -11,7 +11,7 @@ auto motor_configs::driver_config_by_axis(TMC2160PipetteAxis which) switch (which) { case TMC2160PipetteAxis::left_gear_motor: return tmc2160::configs::TMC2160DriverConfig{ - .registers = {.gconfig = {.en_pwm_mode = 1, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 1}, .ihold_irun = {.hold_current = 16, .run_current = 31, .hold_current_delay = 0x7}, @@ -24,7 +24,6 @@ auto motor_configs::driver_config_by_axis(TMC2160PipetteAxis which) .tbl = 0x2, .mres = 0x4}, .coolconf = {.sgt = 0x6}, - .drvconf = {.ot_select = 0}, .glob_scale = {.global_scaler = 0xa7}}, .current_config = { @@ -38,7 +37,7 @@ auto motor_configs::driver_config_by_axis(TMC2160PipetteAxis which) }}; case TMC2160PipetteAxis::right_gear_motor: return tmc2160::configs::TMC2160DriverConfig{ - .registers = {.gconfig = {.en_pwm_mode = 1, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 1}, .ihold_irun = {.hold_current = 16, .run_current = 31, .hold_current_delay = 0x7}, @@ -51,7 +50,6 @@ auto motor_configs::driver_config_by_axis(TMC2160PipetteAxis which) .tbl = 0x2, .mres = 0x4}, .coolconf = {.sgt = 0x6}, - .drvconf = {.ot_select = 0}, .glob_scale = {.global_scaler = 0xa7}}, .current_config = { @@ -66,7 +64,7 @@ auto motor_configs::driver_config_by_axis(TMC2160PipetteAxis which) case TMC2160PipetteAxis::linear_motor: default: return tmc2160::configs::TMC2160DriverConfig{ - .registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 0}, .ihold_irun = {.hold_current = 16, .run_current = 31, .hold_current_delay = 0x7}, @@ -81,7 +79,6 @@ auto motor_configs::driver_config_by_axis(TMC2160PipetteAxis which) .mres = 0x4, .intpol = 0x1}, .coolconf = {.sgt = 0x6}, - .drvconf = {.ot_select = 0}, .glob_scale = {.global_scaler = 0xff}}, .current_config = { @@ -102,7 +99,7 @@ auto motor_configs::driver_config_by_axis(TMC2130PipetteAxis which) case TMC2130PipetteAxis::linear_motor: default: return tmc2130::configs::TMC2130DriverConfig{ - .registers = {.gconfig = {.en_pwm_mode = 1, .diag0_error = 1}, + .registers = {.gconfig = {.en_pwm_mode = 1}, .ihold_irun = {.hold_current = 0x2, .run_current = 0x10, .hold_current_delay = 0x7}, @@ -166,11 +163,6 @@ auto motor_configs::hardware_config_by_axis(TMC2130PipetteAxis which) .port = GPIOC, .pin = GPIO_PIN_12, .active_setting = GPIO_PIN_RESET}, - .diag0 = - {// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOC, - .pin = GPIO_PIN_11, - .active_setting = GPIO_PIN_RESET}, }; } } @@ -207,11 +199,6 @@ auto motor_configs::hardware_config_by_axis(TMC2160PipetteAxis which) .port = GPIOB, .pin = GPIO_PIN_9, .active_setting = GPIO_PIN_RESET}, - .diag0 = - {// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOB, - .pin = GPIO_PIN_6, - .active_setting = GPIO_PIN_RESET}, }; case TMC2160PipetteAxis::left_gear_motor: return motor_hardware::HardwareConfig{ @@ -242,11 +229,6 @@ auto motor_configs::hardware_config_by_axis(TMC2160PipetteAxis which) .port = GPIOB, .pin = GPIO_PIN_9, .active_setting = GPIO_PIN_RESET}, - .diag0 = - {// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOB, - .pin = GPIO_PIN_6, - .active_setting = GPIO_PIN_RESET}, }; case TMC2160PipetteAxis::linear_motor: default: @@ -283,11 +265,6 @@ auto motor_configs::hardware_config_by_axis(TMC2160PipetteAxis which) .port = GPIOB, .pin = GPIO_PIN_9, .active_setting = GPIO_PIN_RESET}, - .diag0 = - {// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - .port = GPIOB, - .pin = GPIO_PIN_6, - .active_setting = GPIO_PIN_RESET}, }; } } diff --git a/pipettes/firmware/motor_hardware.c b/pipettes/firmware/motor_hardware.c index 867a7d4fd..0792f25d5 100644 --- a/pipettes/firmware/motor_hardware.c +++ b/pipettes/firmware/motor_hardware.c @@ -94,10 +94,6 @@ void motor_driver_gpio_init() { // Enable Dir/Step pin GPIO_InitStruct.Pin = pipette_hardware_motor_driver_pins(pipette_type, GPIOA); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - // Diag0 pin - GPIO_InitStruct.Pin = pipette_hardware_motor_driver_diag0_pin(pipette_type); - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); } else { // Enable Dir/Step pin GPIO_InitStruct.Pin = pipette_hardware_motor_driver_pins(pipette_type, GPIOA); @@ -105,10 +101,7 @@ void motor_driver_gpio_init() { // Enable/Dir/Step pin GPIO_InitStruct.Pin = pipette_hardware_motor_driver_pins(pipette_type, GPIOB); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - // Diag0 pin - GPIO_InitStruct.Pin = pipette_hardware_motor_driver_diag0_pin(pipette_type); - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + } } diff --git a/pipettes/firmware/stm32g4xx_it.c b/pipettes/firmware/stm32g4xx_it.c index de067fdd2..953d30404 100644 --- a/pipettes/firmware/stm32g4xx_it.c +++ b/pipettes/firmware/stm32g4xx_it.c @@ -125,8 +125,6 @@ void EXTI2_IRQHandler(void) { void EXTI9_5_IRQHandler(void) { if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_7)) { HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7); - } else if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_6)) { - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); } } @@ -134,8 +132,6 @@ void EXTI9_5_IRQHandler(void) { void EXTI15_10_IRQHandler(void) { if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_12)) { HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_12); - } else if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_11)) { - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_11); } } diff --git a/pipettes/firmware/utility_gpio.c b/pipettes/firmware/utility_gpio.c index 3d0f40bb0..e5c76a8d6 100644 --- a/pipettes/firmware/utility_gpio.c +++ b/pipettes/firmware/utility_gpio.c @@ -59,16 +59,6 @@ static void nvic_priority_enable_init() { /* EXTI interrupt init block tip sense*/ HAL_NVIC_SetPriority(block_2, 10, 0); HAL_NVIC_EnableIRQ(block_2); - - IRQn_Type block_15_10 = get_interrupt_line(gpio_block_15_10); - /* EXTI interrupt init block diag0*/ - HAL_NVIC_SetPriority(block_15_10, 5, 0); - HAL_NVIC_EnableIRQ(block_15_10); - } else { - IRQn_Type block_9_5 = get_interrupt_line(gpio_block_9_5); - /* EXTI interrupt init block diag0*/ - HAL_NVIC_SetPriority(block_9_5, 5, 0); - HAL_NVIC_EnableIRQ(block_9_5); } } diff --git a/pipettes/simulator/interfaces.cpp b/pipettes/simulator/interfaces.cpp index 445349858..de84136d0 100644 --- a/pipettes/simulator/interfaces.cpp +++ b/pipettes/simulator/interfaces.cpp @@ -45,27 +45,11 @@ auto interfaces::get_interrupt_queues() } auto linear_motor::get_interrupt( - sim_motor_hardware_iface::SimMotorHardwareIface& hw, - LowThroughputInterruptQueues& queues, stall_check::StallCheck& stall) - -> MotorInterruptHandlerType< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2130_driver::QueueClient> { - return motor_handler::MotorInterruptHandler( - queues.plunger_queue, linear_motor_tasks::get_queues(), - linear_motor_tasks::tmc2130_driver::get_queues(), hw, stall, - queues.plunger_update_queue); -} - -auto linear_motor::get_interrupt( - sim_motor_hardware_iface::SimMotorHardwareIface& hw, - HighThroughputInterruptQueues& queues, stall_check::StallCheck& stall) - -> MotorInterruptHandlerType< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2160_driver::QueueClient> { + sim_motor_hardware_iface::SimMotorHardwareIface& hw, MoveQueue& queue, + stall_check::StallCheck& stall, UpdatePositionQueue& update_queue) + -> MotorInterruptHandlerType { return motor_handler::MotorInterruptHandler( - queues.plunger_queue, linear_motor_tasks::get_queues(), - linear_motor_tasks::tmc2160_driver::get_queues(), hw, stall, - queues.plunger_update_queue); + queue, linear_motor_tasks::get_queues(), hw, stall, update_queue); } auto linear_motor::get_interrupt_driver( @@ -76,14 +60,11 @@ auto linear_motor::get_interrupt_driver( handler) #ifdef USE_SENSOR_MOVE -> motor_interrupt_driver::MotorInterruptDriver< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2130_driver::QueueClient, - motor_messages::SensorSyncMove, + linear_motor_tasks::QueueClient, motor_messages::SensorSyncMove, sim_motor_hardware_iface::SimMotorHardwareIface> { #else -> motor_interrupt_driver::MotorInterruptDriver< - linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2130_driver::QueueClient, motor_messages::Move, + linear_motor_tasks::QueueClient, motor_messages::Move, sim_motor_hardware_iface::SimMotorHardwareIface> { #endif return motor_interrupt_driver::MotorInterruptDriver( @@ -99,13 +80,12 @@ auto linear_motor::get_interrupt_driver( #ifdef USE_SENSOR_MOVE -> motor_interrupt_driver::MotorInterruptDriver< linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2160_driver::QueueClient, motor_messages::SensorSyncMove, sim_motor_hardware_iface::SimMotorHardwareIface> { #else -> motor_interrupt_driver::MotorInterruptDriver< linear_motor_tasks::QueueClient, - linear_motor_tasks::tmc2160_driver::QueueClient, motor_messages::Move, + motor_messages::Move, sim_motor_hardware_iface::SimMotorHardwareIface> { #endif return motor_interrupt_driver::MotorInterruptDriver( @@ -152,12 +132,10 @@ auto gear_motor::get_interrupts(gear_motor::GearHardware& hw, return gear_motor::GearInterruptHandlers{ .left = motor_handler::MotorInterruptHandler( queues.left_motor_queue, gear_motor_tasks::get_left_gear_queues(), - gear_motor_tasks::get_left_gear_queues(), hw.left, stall.left, - queues.left_update_queue), + hw.left, stall.left, queues.left_update_queue), .right = motor_handler::MotorInterruptHandler( queues.right_motor_queue, gear_motor_tasks::get_right_gear_queues(), - gear_motor_tasks::get_right_gear_queues(), hw.right, stall.right, - queues.right_update_queue), + hw.right, stall.right, queues.right_update_queue), }; } diff --git a/pipettes/simulator/main.cpp b/pipettes/simulator/main.cpp index c3da9d98b..37b1f86cc 100644 --- a/pipettes/simulator/main.cpp +++ b/pipettes/simulator/main.cpp @@ -60,10 +60,12 @@ static auto gear_stall_check = interfaces::gear_motor::GearStallCheck{ static auto linear_motor_hardware = interfaces::linear_motor::get_motor_hardware(); static auto plunger_interrupt = interfaces::linear_motor::get_interrupt( - linear_motor_hardware, interrupt_queues, linear_stall_check); + linear_motor_hardware, interrupt_queues.plunger_queue, linear_stall_check, + interrupt_queues.plunger_update_queue); static auto plunger_interrupt_driver = interfaces::linear_motor::get_interrupt_driver( - linear_motor_hardware, interrupt_queues, plunger_interrupt); + linear_motor_hardware, interrupt_queues.plunger_queue, + plunger_interrupt, interrupt_queues.plunger_update_queue); static auto linear_motion_control = interfaces::linear_motor::get_motion_control(linear_motor_hardware, interrupt_queues); diff --git a/push b/push index c0d319d1f..9eb3939f3 100755 --- a/push +++ b/push @@ -16,10 +16,32 @@ from itertools import chain from zipfile import ZipFile import tempfile from contextlib import contextmanager +import json +import re _DEFAULT_EXTRAS = {'stdout': sys.stdout, 'stderr': sys.stderr} _SSH_EXTRA_OPTS = ['-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null'] +_ROBOT_MANIFEST_FILE_PATH = "/usr/lib/firmware/opentrons-firmware.json" +TARGETS = [ + "pipettes", + "pipettes-rev1", + "pipettes-single", + "pipettes-multi", + "pipettes-96", + "gripper", + "hepa-uv", + "gantry", + "gantry-x", + "gantry-y", + "head", + "rear-panel", + "bootloader", +] +_MULTI_SUBSYSTEM_TARGETS = { + "pipettes": ["pipettes-single", "pipettes-multi", "pipettes-96"], + "gantry": ["gantry-x", "gantry-y"] +} class CantFindUtilityException(RuntimeError): def __init__(self, which_util): @@ -36,10 +58,17 @@ def _scp_to_robot(scp_util, host, local, remote, **extras): _cmd( [scp_util] + _SSH_EXTRA_OPTS - + [local, 'root@{host}:{remote}'.format(host=host, remote=remote)], + + [local, f'root@{host}:{remote}'], **extras ) +def _scp_from_robot(scp_util, host, local, remote, **extras): + _cmd( + [scp_util] + + _SSH_EXTRA_OPTS + + [f'root@{host}:{remote}', local], + **extras + ) def _cmd(cmdlist, **extras): _extras = {k: v for k, v in chain(_DEFAULT_EXTRAS.items(), extras.items())} @@ -54,12 +83,47 @@ def _controlled_tempdir(): finally: shutil.rmtree(td) -def _build_fw(zip_path, apps_path): - with ZipFile(zip_path, 'w') as zf: - for fname in os.listdir(apps_path): - zf.write(os.path.join(apps_path, fname), fname) +def _build_fw(zip_path, apps_path, targets): + if targets: + regex_list = [re.compile(f"{target}" + r"(.*)(.hex|.bin)") for target in targets] + with ZipFile(zip_path, 'w') as zf: + for fname in os.listdir(apps_path): + # only write to zip file to be copied if filename matches target + if any([reg.search(fname) for reg in regex_list]): + zf.write(os.path.join(apps_path, fname), fname) + else: + with ZipFile(zip_path, 'w') as zf: + for fname in os.listdir(apps_path): + # write all image files to zip file + zf.write(os.path.join(apps_path, fname), fname) + + +def _subsystems_from_targets(targets): + # assuming all targets are valid at this point, convert + # presets that encompass multiple subsystems to their + # respective subsystems + for t in targets: + if t in _MULTI_SUBSYSTEM_TARGETS: + t_index = targets.index(t) + # replace the target with multiple subsystems + targets[t_index:t_index+1] = tuple(_MULTI_SUBSYSTEM_TARGETS[t]) + return targets + + +def _update_shortsha(scp, host, json_data_path, targets): + shortsha = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).decode().strip() + # copy data to local file + _scp_from_robot(scp, host, json_data_path, _ROBOT_MANIFEST_FILE_PATH) + with open(json_data_path, 'r+') as output_file: + manifest = json.load(output_file) + for target in _subsystems_from_targets(targets): + manifest['subsystems'][target]['shortsha'] = shortsha + output_file.seek(0) + json.dump(manifest, output_file) + # copy updated subsystem data to the robot + _scp_to_robot(scp, host, json_data_path, _ROBOT_MANIFEST_FILE_PATH) -def _transfer_firmware(host, repo_path, scp, ssh, sensors): +def _transfer_firmware(host, repo_path, scp, ssh, sensors, targets): dist_dir = "dist" if sensors: dist_dir = dist_dir+"-sensor" @@ -67,18 +131,30 @@ def _transfer_firmware(host, repo_path, scp, ssh, sensors): with _controlled_tempdir() as td: local_zip_path = os.path.join(td, 'fw.zip') robot_zip_path = '/tmp/fw.zip' - _build_fw(local_zip_path, apps_path) + _build_fw(local_zip_path, apps_path, targets) + if targets: + local_temp_manifest_path = os.path.join(td, 'temp_manifest.json') + _update_shortsha(scp, host, local_temp_manifest_path, targets) _scp_to_robot(scp, host, local_zip_path, robot_zip_path) _ssh(ssh, host, 'unzip -o {zip_path} -d /usr/lib/firmware/'.format(zip_path=robot_zip_path)) _ssh(ssh, host, 'rm {zip_path}'.format(zip_path=robot_zip_path)) -def _prep_firmware(repo_path, cmake, sensors): - preset = "firmware-g4" +def _prep_firmware(repo_path, cmake, sensors, targets): working_dir = "./build-cross" + full_build_preset = "firmware-g4" + if sensors: - preset = preset+"-sensors" working_dir = working_dir+"-sensor" - _cmd([cmake, '--build', f'--preset={preset}', '--target', 'firmware-applications', 'firmware-images'], cwd=repo_path) + full_build_preset = full_build_preset+"-sensors" + # if sensors is true, disregard targets within the scope of this function + targets = None + if targets: + for target in targets: + _cmd([cmake, '--build', 'build-cross', '--target', f'{target}-images'], cwd=repo_path) + else: + _cmd([cmake, '--build', f'--preset={full_build_preset}', '--target', 'firmware-applications', 'firmware-images'], cwd=repo_path) + + _cmd([cmake, '--install', f'{working_dir}', '--component', 'Applications'], cwd=repo_path) @contextmanager @@ -101,22 +177,36 @@ def _find_utils(): raise CantFindUtilityException('cmake') return ssh, scp, cmake +def _check_targets(targets): + for t in targets: + if t not in TARGETS: + print(f"preset {t} is not in target options, ignoring") + targets.remove(t) + return targets + def _restart_robot(host, ssh): _ssh(ssh, host, 'nohup systemctl restart opentrons-robot-server &') -def _do_push(host, repo_path, build, restart, sensors): +def _do_push(host, repo_path, build, restart, sensors, targets): + ssh, scp, cmake = _find_utils() + if targets: + targets = _check_targets(targets) if build: - _prep_firmware(repo_path, cmake, sensors) + _prep_firmware(repo_path, cmake, sensors, targets) with _prep_robot(host, ssh): - _transfer_firmware(host, repo_path, scp, ssh, sensors) + _transfer_firmware(host, repo_path, scp, ssh, sensors, targets) if restart: _restart_robot(host, ssh) -def push(host, repo_path=None, build=True, restart=True, sensors=False): +def push(host, repo_path=None, build=True, restart=True, sensors=False, targets=[]): + # sensors is logically independent from targets here- if you specify both: + # - all hex files under firmware-g4-sensors will be built and installed, but + # - only the targets selected will actually be copied over to the robot + repo = repo_path or os.dirname(__file__) try: - _do_push(host, repo, build, restart, sensors) + _do_push(host, repo, build, restart, sensors, targets) return 0 except subprocess.CalledProcessError as e: print( @@ -133,7 +223,7 @@ def _push_from_argparse(args): if args.key: _SSH_EXTRA_OPTS.append('-i') _SSH_EXTRA_OPTS.append(args.key) - return push(args.host, os.path.abspath(args.repo_path), not args.no_build, not args.no_restart, args.sensors) + return push(args.host, os.path.abspath(args.repo_path), not args.no_build, not args.no_restart, args.sensors, args.targets) def _arg_parser(parent=None): parents = [] @@ -169,6 +259,10 @@ def _arg_parser(parent=None): action='store_true', help='Private SSH key to use' ) + parser.add_argument( + '--targets', + nargs='*' + ) return parser def _main(): diff --git a/sensors/tests/CMakeLists.txt b/sensors/tests/CMakeLists.txt index b96edd688..b00f035c7 100644 --- a/sensors/tests/CMakeLists.txt +++ b/sensors/tests/CMakeLists.txt @@ -35,7 +35,7 @@ target_compile_options(sensors $<$:-fno-rtti> ) -target_link_libraries(sensors PUBLIC Catch2::Catch2 Boost::boost Boost::program_options Boost::date_time common-core motor-utils common-simulation) +target_link_libraries(sensors PUBLIC Catch2::Catch2 common-core motor-utils common-simulation) target_i2c_simlib(sensors)