diff --git a/blackmagic/bm_if.c b/blackmagic/bm_if.c index 1df45d9b..c4530c65 100644 --- a/blackmagic/bm_if.c +++ b/blackmagic/bm_if.c @@ -577,6 +577,16 @@ int bm_reboot(void) { return ret; } +/** + * Halt target execution. + */ +void bm_halt_req(void) { + if (cur_target) { + target_print_en = false; + target_halt_request(cur_target); + } +} + /** * Leave debug mode of NRF5x device. Will reduce the sleep power consumption * significantly. diff --git a/blackmagic/bm_if.h b/blackmagic/bm_if.h index d7aeb83e..e2ae1e3b 100644 --- a/blackmagic/bm_if.h +++ b/blackmagic/bm_if.h @@ -31,6 +31,7 @@ int bm_erase_flash_all(void); int bm_write_flash(uint32_t addr, const void *data, uint32_t len); int bm_mem_read(uint32_t addr, void *data, uint32_t len); int bm_reboot(void); +void bm_halt_req(void); void bm_leave_nrf_debug_mode(void); void bm_disconnect(void); void bm_change_swd_pins(stm32_gpio_t *swdio_port, int swdio_pin, diff --git a/commands.c b/commands.c index 4c121cf6..590f6219 100644 --- a/commands.c +++ b/commands.c @@ -462,7 +462,7 @@ void commands_process_packet(unsigned char *data, unsigned int len, } break; case COMM_SET_MCCONF: { -#ifndef HW_MCCONF_READ_ONLY +#ifndef HW_MCCONF_READ_ONLY mc_configuration *mcconf = mempools_alloc_mcconf(); *mcconf = *mc_interface_get_configuration(); @@ -525,7 +525,7 @@ void commands_process_packet(unsigned char *data, unsigned int len, } break; case COMM_SET_APPCONF: { -#ifndef HW_APPCONF_READ_ONLY +#ifndef HW_APPCONF_READ_ONLY app_configuration *appconf = mempools_alloc_appconf(); *appconf = *app_get_configuration(); @@ -1904,6 +1904,16 @@ static THD_FUNCTION(blocking_thread, arg) { } } break; + case COMM_BM_HALT_REQ: { + bm_halt_req(); + + int32_t ind = 0; + send_buffer[ind++] = packet_id; + if (send_func_blocking) { + send_func_blocking(send_buffer, ind); + } + } break; + case COMM_BM_DISCONNECT: { bm_disconnect(); bm_leave_nrf_debug_mode(); diff --git a/datatypes.h b/datatypes.h index bacaa835..47fad36a 100644 --- a/datatypes.h +++ b/datatypes.h @@ -968,6 +968,7 @@ typedef enum { COMM_BMS_FWD_CAN_RX, COMM_BMS_HW_DATA, COMM_GET_BATTERY_CUT, + COMM_BM_HALT_REQ, } COMM_PACKET_ID; // CAN commands