mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 09:08:36 -07:00
Fix merge issues
This commit is contained in:
4
applications/external/dap_link/gui/scenes/config/dap_scene_config.h
vendored
Normal file
4
applications/external/dap_link/gui/scenes/config/dap_scene_config.h
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
ADD_SCENE(dap, main, Main)
|
||||
ADD_SCENE(dap, config, Config)
|
||||
ADD_SCENE(dap, help, Help)
|
||||
ADD_SCENE(dap, about, About)
|
||||
107
applications/external/dap_link/gui/scenes/dap_scene_config.c
vendored
Normal file
107
applications/external/dap_link/gui/scenes/dap_scene_config.c
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "../dap_gui_i.h"
|
||||
|
||||
static const char* swd_pins[] = {[DapSwdPinsPA7PA6] = "2,3", [DapSwdPinsPA14PA13] = "10,12"};
|
||||
static const char* uart_pins[] = {[DapUartTypeUSART1] = "13,14", [DapUartTypeLPUART1] = "15,16"};
|
||||
static const char* uart_swap[] = {[DapUartTXRXNormal] = "No", [DapUartTXRXSwap] = "Yes"};
|
||||
|
||||
static void swd_pins_cb(VariableItem* item) {
|
||||
DapGuiApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, swd_pins[index]);
|
||||
|
||||
DapConfig* config = dap_app_get_config(app->dap_app);
|
||||
config->swd_pins = index;
|
||||
dap_app_set_config(app->dap_app, config);
|
||||
}
|
||||
|
||||
static void uart_pins_cb(VariableItem* item) {
|
||||
DapGuiApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, uart_pins[index]);
|
||||
|
||||
DapConfig* config = dap_app_get_config(app->dap_app);
|
||||
config->uart_pins = index;
|
||||
dap_app_set_config(app->dap_app, config);
|
||||
}
|
||||
|
||||
static void uart_swap_cb(VariableItem* item) {
|
||||
DapGuiApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, uart_swap[index]);
|
||||
|
||||
DapConfig* config = dap_app_get_config(app->dap_app);
|
||||
config->uart_swap = index;
|
||||
dap_app_set_config(app->dap_app, config);
|
||||
}
|
||||
|
||||
static void ok_cb(void* context, uint32_t index) {
|
||||
DapGuiApp* app = context;
|
||||
switch(index) {
|
||||
case 3:
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, DapAppCustomEventHelp);
|
||||
break;
|
||||
case 4:
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, DapAppCustomEventAbout);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dap_scene_config_on_enter(void* context) {
|
||||
DapGuiApp* app = context;
|
||||
VariableItemList* var_item_list = app->var_item_list;
|
||||
VariableItem* item;
|
||||
DapConfig* config = dap_app_get_config(app->dap_app);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "SWC SWD Pins", COUNT_OF(swd_pins), swd_pins_cb, app);
|
||||
variable_item_set_current_value_index(item, config->swd_pins);
|
||||
variable_item_set_current_value_text(item, swd_pins[config->swd_pins]);
|
||||
|
||||
item =
|
||||
variable_item_list_add(var_item_list, "UART Pins", COUNT_OF(uart_pins), uart_pins_cb, app);
|
||||
variable_item_set_current_value_index(item, config->uart_pins);
|
||||
variable_item_set_current_value_text(item, uart_pins[config->uart_pins]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "Swap TX RX", COUNT_OF(uart_swap), uart_swap_cb, app);
|
||||
variable_item_set_current_value_index(item, config->uart_swap);
|
||||
variable_item_set_current_value_text(item, uart_swap[config->uart_swap]);
|
||||
|
||||
variable_item_list_add(var_item_list, "Help and Pinout", 0, NULL, NULL);
|
||||
variable_item_list_add(var_item_list, "About", 0, NULL, NULL);
|
||||
|
||||
variable_item_list_set_selected_item(
|
||||
var_item_list, scene_manager_get_scene_state(app->scene_manager, DapSceneConfig));
|
||||
|
||||
variable_item_list_set_enter_callback(var_item_list, ok_cb, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DapGuiAppViewVarItemList);
|
||||
}
|
||||
|
||||
bool dap_scene_config_on_event(void* context, SceneManagerEvent event) {
|
||||
DapGuiApp* app = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == DapAppCustomEventHelp) {
|
||||
scene_manager_next_scene(app->scene_manager, DapSceneHelp);
|
||||
return true;
|
||||
} else if(event.event == DapAppCustomEventAbout) {
|
||||
scene_manager_next_scene(app->scene_manager, DapSceneAbout);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void dap_scene_config_on_exit(void* context) {
|
||||
DapGuiApp* app = context;
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DapSceneConfig,
|
||||
variable_item_list_get_selected_item_index(app->var_item_list));
|
||||
variable_item_list_reset(app->var_item_list);
|
||||
}
|
||||
102
applications/external/dap_link/gui/scenes/dap_scene_help.c
vendored
Normal file
102
applications/external/dap_link/gui/scenes/dap_scene_help.c
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
#include "../dap_gui_i.h"
|
||||
|
||||
void dap_scene_help_on_enter(void* context) {
|
||||
DapGuiApp* app = context;
|
||||
DapConfig* config = dap_app_get_config(app->dap_app);
|
||||
FuriString* string = furi_string_alloc();
|
||||
|
||||
furi_string_cat(string, "CMSIS DAP/DAP Link v2\r\n");
|
||||
furi_string_cat_printf(string, "Serial: %s\r\n", dap_app_get_serial(app->dap_app));
|
||||
furi_string_cat(
|
||||
string,
|
||||
"Pinout:\r\n"
|
||||
"\e#SWD:\r\n");
|
||||
|
||||
switch(config->swd_pins) {
|
||||
case DapSwdPinsPA7PA6:
|
||||
furi_string_cat(
|
||||
string,
|
||||
" SWC: 2 [A7]\r\n"
|
||||
" SWD: 3 [A6]\r\n");
|
||||
break;
|
||||
case DapSwdPinsPA14PA13:
|
||||
furi_string_cat(
|
||||
string,
|
||||
" SWC: 10 [SWC]\r\n"
|
||||
" SWD: 12 [SIO]\r\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
furi_string_cat(string, "\e#JTAG:\r\n");
|
||||
switch(config->swd_pins) {
|
||||
case DapSwdPinsPA7PA6:
|
||||
furi_string_cat(
|
||||
string,
|
||||
" TCK: 2 [A7]\r\n"
|
||||
" TMS: 3 [A6]\r\n"
|
||||
" RST: 4 [A4]\r\n"
|
||||
" TDO: 5 [B3]\r\n"
|
||||
" TDI: 6 [B2]\r\n");
|
||||
break;
|
||||
case DapSwdPinsPA14PA13:
|
||||
furi_string_cat(
|
||||
string,
|
||||
" RST: 4 [A4]\r\n"
|
||||
" TDO: 5 [B3]\r\n"
|
||||
" TDI: 6 [B2]\r\n"
|
||||
" TCK: 10 [SWC]\r\n"
|
||||
" TMS: 12 [SIO]\r\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
furi_string_cat(string, "\e#UART:\r\n");
|
||||
switch(config->uart_pins) {
|
||||
case DapUartTypeUSART1:
|
||||
if(config->uart_swap == DapUartTXRXNormal) {
|
||||
furi_string_cat(
|
||||
string,
|
||||
" TX: 13 [TX]\r\n"
|
||||
" RX: 14 [RX]\r\n");
|
||||
} else {
|
||||
furi_string_cat(
|
||||
string,
|
||||
" RX: 13 [TX]\r\n"
|
||||
" TX: 14 [RX]\r\n");
|
||||
}
|
||||
break;
|
||||
case DapUartTypeLPUART1:
|
||||
if(config->uart_swap == DapUartTXRXNormal) {
|
||||
furi_string_cat(
|
||||
string,
|
||||
" TX: 15 [C1]\r\n"
|
||||
" RX: 16 [C0]\r\n");
|
||||
} else {
|
||||
furi_string_cat(
|
||||
string,
|
||||
" RX: 15 [C1]\r\n"
|
||||
" TX: 16 [C0]\r\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
widget_add_text_scroll_element(app->widget, 0, 0, 128, 64, furi_string_get_cstr(string));
|
||||
furi_string_free(string);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DapGuiAppViewWidget);
|
||||
}
|
||||
|
||||
bool dap_scene_help_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void dap_scene_help_on_exit(void* context) {
|
||||
DapGuiApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
154
applications/external/dap_link/gui/scenes/dap_scene_main.c
vendored
Normal file
154
applications/external/dap_link/gui/scenes/dap_scene_main.c
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
#include "../dap_gui_i.h"
|
||||
#include "../../dap_link.h"
|
||||
|
||||
typedef struct {
|
||||
DapState dap_state;
|
||||
bool dap_active;
|
||||
bool tx_active;
|
||||
bool rx_active;
|
||||
} DapSceneMainState;
|
||||
|
||||
static bool process_dap_state(DapGuiApp* app) {
|
||||
DapSceneMainState* state =
|
||||
(DapSceneMainState*)scene_manager_get_scene_state(app->scene_manager, DapSceneMain);
|
||||
if(state == NULL) return true;
|
||||
|
||||
DapState* prev_state = &state->dap_state;
|
||||
DapState next_state;
|
||||
dap_app_get_state(app->dap_app, &next_state);
|
||||
bool need_to_update = false;
|
||||
|
||||
if(prev_state->dap_mode != next_state.dap_mode) {
|
||||
switch(next_state.dap_mode) {
|
||||
case DapModeDisconnected:
|
||||
dap_main_view_set_mode(app->main_view, DapMainViewModeDisconnected);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
break;
|
||||
case DapModeSWD:
|
||||
dap_main_view_set_mode(app->main_view, DapMainViewModeSWD);
|
||||
notification_message(app->notifications, &sequence_blink_start_blue);
|
||||
break;
|
||||
case DapModeJTAG:
|
||||
dap_main_view_set_mode(app->main_view, DapMainViewModeJTAG);
|
||||
notification_message(app->notifications, &sequence_blink_start_magenta);
|
||||
break;
|
||||
}
|
||||
need_to_update = true;
|
||||
}
|
||||
|
||||
if(prev_state->dap_version != next_state.dap_version) {
|
||||
switch(next_state.dap_version) {
|
||||
case DapVersionUnknown:
|
||||
dap_main_view_set_version(app->main_view, DapMainViewVersionUnknown);
|
||||
break;
|
||||
case DapVersionV1:
|
||||
dap_main_view_set_version(app->main_view, DapMainViewVersionV1);
|
||||
break;
|
||||
case DapVersionV2:
|
||||
dap_main_view_set_version(app->main_view, DapMainViewVersionV2);
|
||||
break;
|
||||
}
|
||||
need_to_update = true;
|
||||
}
|
||||
|
||||
if(prev_state->usb_connected != next_state.usb_connected) {
|
||||
dap_main_view_set_usb_connected(app->main_view, next_state.usb_connected);
|
||||
need_to_update = true;
|
||||
}
|
||||
|
||||
if(prev_state->dap_counter != next_state.dap_counter) {
|
||||
if(!state->dap_active) {
|
||||
state->dap_active = true;
|
||||
dap_main_view_set_dap(app->main_view, state->dap_active);
|
||||
need_to_update = true;
|
||||
}
|
||||
} else {
|
||||
if(state->dap_active) {
|
||||
state->dap_active = false;
|
||||
dap_main_view_set_dap(app->main_view, state->dap_active);
|
||||
need_to_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(prev_state->cdc_baudrate != next_state.cdc_baudrate) {
|
||||
dap_main_view_set_baudrate(app->main_view, next_state.cdc_baudrate);
|
||||
need_to_update = true;
|
||||
}
|
||||
|
||||
if(prev_state->cdc_tx_counter != next_state.cdc_tx_counter) {
|
||||
if(!state->tx_active) {
|
||||
state->tx_active = true;
|
||||
dap_main_view_set_tx(app->main_view, state->tx_active);
|
||||
need_to_update = true;
|
||||
notification_message(app->notifications, &sequence_blink_start_red);
|
||||
}
|
||||
} else {
|
||||
if(state->tx_active) {
|
||||
state->tx_active = false;
|
||||
dap_main_view_set_tx(app->main_view, state->tx_active);
|
||||
need_to_update = true;
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
}
|
||||
}
|
||||
|
||||
if(prev_state->cdc_rx_counter != next_state.cdc_rx_counter) {
|
||||
if(!state->rx_active) {
|
||||
state->rx_active = true;
|
||||
dap_main_view_set_rx(app->main_view, state->rx_active);
|
||||
need_to_update = true;
|
||||
notification_message(app->notifications, &sequence_blink_start_green);
|
||||
}
|
||||
} else {
|
||||
if(state->rx_active) {
|
||||
state->rx_active = false;
|
||||
dap_main_view_set_rx(app->main_view, state->rx_active);
|
||||
need_to_update = true;
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
}
|
||||
}
|
||||
|
||||
if(need_to_update) {
|
||||
dap_main_view_update(app->main_view);
|
||||
}
|
||||
|
||||
*prev_state = next_state;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void dap_scene_main_on_left(void* context) {
|
||||
DapGuiApp* app = (DapGuiApp*)context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, DapAppCustomEventConfig);
|
||||
}
|
||||
|
||||
void dap_scene_main_on_enter(void* context) {
|
||||
DapGuiApp* app = context;
|
||||
DapSceneMainState* state = malloc(sizeof(DapSceneMainState));
|
||||
dap_main_view_set_left_callback(app->main_view, dap_scene_main_on_left, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DapGuiAppViewMainView);
|
||||
scene_manager_set_scene_state(app->scene_manager, DapSceneMain, (uint32_t)state);
|
||||
}
|
||||
|
||||
bool dap_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
DapGuiApp* app = context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == DapAppCustomEventConfig) {
|
||||
scene_manager_next_scene(app->scene_manager, DapSceneConfig);
|
||||
return true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
return process_dap_state(app);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void dap_scene_main_on_exit(void* context) {
|
||||
DapGuiApp* app = context;
|
||||
DapSceneMainState* state =
|
||||
(DapSceneMainState*)scene_manager_get_scene_state(app->scene_manager, DapSceneMain);
|
||||
scene_manager_set_scene_state(app->scene_manager, DapSceneMain, (uint32_t)NULL);
|
||||
FURI_SW_MEMBARRIER();
|
||||
free(state);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
}
|
||||
Reference in New Issue
Block a user