|
47 | 47 | #if defined(CONFIG_MOSH_WORKER_THREADS) |
48 | 48 | #include "th/th_ctrl.h" |
49 | 49 | #endif |
| 50 | +#include "mosh_defines.h" |
50 | 51 |
|
51 | 52 | /* global variables */ |
52 | 53 | struct modem_param_info modem_param; |
| 54 | +struct k_poll_signal mosh_signal; |
| 55 | + |
53 | 56 | /** |
54 | 57 | * @brief Global shell pointer that can be used for printing. |
55 | 58 | * |
@@ -87,6 +90,17 @@ static void mosh_print_version_info(void) |
87 | 90 |
|
88 | 91 | static void button_handler(uint32_t button_states, uint32_t has_changed) |
89 | 92 | { |
| 93 | + if (has_changed & button_states & DK_BTN1_MSK) { |
| 94 | + shell_print(shell_global, "Button 1 pressed - raising a kill signal"); |
| 95 | + k_poll_signal_raise(&mosh_signal, MOSH_SIGNAL_KILL); |
| 96 | +#if defined(CONFIG_MOSH_WORKER_THREADS) |
| 97 | + th_ctrl_kill_em_all(); |
| 98 | +#endif |
| 99 | + } else if (has_changed & ~button_states & DK_BTN1_MSK) { |
| 100 | + shell_print(shell_global, "Button 1 released - resetting a kill signal"); |
| 101 | + k_poll_signal_reset(&mosh_signal); |
| 102 | + } |
| 103 | + |
90 | 104 | if (has_changed & button_states & DK_BTN2_MSK) { |
91 | 105 | shell_print(shell_global, "Button 2 pressed, toggling UART power state"); |
92 | 106 | uart_toggle_power_state(shell_global); |
@@ -182,6 +196,7 @@ void main(void) |
182 | 196 | #if defined(CONFIG_BOOTLOADER_MCUBOOT) |
183 | 197 | boot_write_img_confirmed(); |
184 | 198 | #endif |
| 199 | + k_poll_signal_init(&mosh_signal); |
185 | 200 |
|
186 | 201 | /* Resize terminal width and height of the shell to have proper command editing. */ |
187 | 202 | shell_execute_cmd(shell_global, "resize"); |
|
0 commit comments