|
1 | | -/** |
2 | | - * @file boot_menu.c |
3 | | - * @brief Interactive UART-based boot menu |
4 | | - */ |
5 | | - |
6 | | -#include "eos_boot_menu.h" |
7 | | -#include "eos_hal.h" |
8 | | -#include "eos_bootctl.h" |
9 | | -#include <string.h> |
10 | | - |
11 | | -static void uart_puts(uint8_t port, const char *str) |
12 | | -{ |
13 | | - eos_hal_uart_write(port, (const uint8_t *)str, strlen(str)); |
14 | | -} |
15 | | - |
16 | | -static int uart_getc(uint8_t port, uint32_t timeout_ms) |
17 | | -{ |
18 | | - uint8_t ch; |
19 | | - int rc = eos_hal_uart_read(port, &ch, 1, timeout_ms); |
20 | | - return (rc == EOS_OK) ? (int)ch : -1; |
21 | | -} |
22 | | - |
23 | | -void eos_boot_menu_print_status(uint8_t uart_port) |
24 | | -{ |
25 | | - uart_puts(uart_port, "\r\n=== eBootloader Status ===\r\n"); |
26 | | - uart_puts(uart_port, " Firmware: eBootloader v0.2.0\r\n"); |
27 | | - uart_puts(uart_port, "==========================\r\n"); |
28 | | -} |
29 | | - |
30 | | -eos_menu_choice_t eos_boot_menu_run(const eos_boot_menu_config_t *cfg) |
31 | | -{ |
32 | | - if (!cfg) return EOS_MENU_TIMEOUT; |
33 | | - |
34 | | - uint8_t port = cfg->uart_port; |
35 | | - |
36 | | - uart_puts(port, "\r\n"); |
37 | | - uart_puts(port, "╔══════════════════════════════╗\r\n"); |
38 | | - uart_puts(port, "║ eBootloader Menu ║\r\n"); |
39 | | - uart_puts(port, "╠══════════════════════════════╣\r\n"); |
40 | | - uart_puts(port, "║ 1. Boot Default ║\r\n"); |
41 | | - uart_puts(port, "║ 2. Boot Slot A ║\r\n"); |
42 | | - uart_puts(port, "║ 3. Boot Slot B ║\r\n"); |
43 | | - uart_puts(port, "║ 4. Recovery Mode ║\r\n"); |
44 | | - uart_puts(port, "║ 5. Run Diagnostics ║\r\n"); |
45 | | - uart_puts(port, "║ 6. View Boot Log ║\r\n"); |
46 | | - uart_puts(port, "║ 7. Reboot ║\r\n"); |
47 | | - uart_puts(port, "╚══════════════════════════════╝\r\n"); |
48 | | - uart_puts(port, "Select [1-7]: "); |
49 | | - |
50 | | - int ch = uart_getc(port, cfg->timeout_ms); |
51 | | - |
52 | | - switch (ch) { |
53 | | - case '1': return EOS_MENU_BOOT_DEFAULT; |
54 | | - case '2': return EOS_MENU_BOOT_SLOT_A; |
55 | | - case '3': return EOS_MENU_BOOT_SLOT_B; |
56 | | - case '4': return EOS_MENU_RECOVERY; |
57 | | - case '5': return EOS_MENU_DIAGNOSTICS; |
58 | | - case '6': return EOS_MENU_VIEW_LOG; |
59 | | - case '7': return EOS_MENU_REBOOT; |
60 | | - default: return EOS_MENU_TIMEOUT; |
61 | | - } |
62 | | -} |
| 1 | +/** |
| 2 | + * @file boot_menu.c |
| 3 | + * @brief Interactive UART-based boot menu |
| 4 | + */ |
| 5 | + |
| 6 | +#include "eos_boot_menu.h" |
| 7 | +#include "eos_hal.h" |
| 8 | +#include "eos_bootctl.h" |
| 9 | +#include <string.h> |
| 10 | + |
| 11 | +static void uart_puts(uint8_t port, const char *str) |
| 12 | +{ |
| 13 | + eos_hal_uart_write(port, (const uint8_t *)str, strlen(str)); |
| 14 | +} |
| 15 | + |
| 16 | +static int uart_getc(uint8_t port, uint32_t timeout_ms) |
| 17 | +{ |
| 18 | + uint8_t ch; |
| 19 | + int rc = eos_hal_uart_read(port, &ch, 1, timeout_ms); |
| 20 | + return (rc == EOS_OK) ? (int)ch : -1; |
| 21 | +} |
| 22 | + |
| 23 | +void eos_boot_menu_print_status(uint8_t uart_port) |
| 24 | +{ |
| 25 | + uart_puts(uart_port, "\r\n=== eBootloader Status ===\r\n"); |
| 26 | + uart_puts(uart_port, " Firmware: eBootloader v0.3.0\r\n"); |
| 27 | + uart_puts(uart_port, "==========================\r\n"); |
| 28 | +} |
| 29 | + |
| 30 | +eos_menu_choice_t eos_boot_menu_run(const eos_boot_menu_config_t *cfg) |
| 31 | +{ |
| 32 | + if (!cfg) return EOS_MENU_TIMEOUT; |
| 33 | + |
| 34 | + uint8_t port = cfg->uart_port; |
| 35 | + |
| 36 | + uart_puts(port, "\r\n"); |
| 37 | + uart_puts(port, "╔══════════════════════════════╗\r\n"); |
| 38 | + uart_puts(port, "║ eBootloader Menu ║\r\n"); |
| 39 | + uart_puts(port, "╠══════════════════════════════╣\r\n"); |
| 40 | + uart_puts(port, "║ 1. Boot Default ║\r\n"); |
| 41 | + uart_puts(port, "║ 2. Boot Slot A ║\r\n"); |
| 42 | + uart_puts(port, "║ 3. Boot Slot B ║\r\n"); |
| 43 | + uart_puts(port, "║ 4. Recovery Mode ║\r\n"); |
| 44 | + uart_puts(port, "║ 5. Run Diagnostics ║\r\n"); |
| 45 | + uart_puts(port, "║ 6. View Boot Log ║\r\n"); |
| 46 | + uart_puts(port, "║ 7. Reboot ║\r\n"); |
| 47 | + uart_puts(port, "╚══════════════════════════════╝\r\n"); |
| 48 | + uart_puts(port, "Select [1-7]: "); |
| 49 | + |
| 50 | + int ch = uart_getc(port, cfg->timeout_ms); |
| 51 | + |
| 52 | + switch (ch) { |
| 53 | + case '1': return EOS_MENU_BOOT_DEFAULT; |
| 54 | + case '2': return EOS_MENU_BOOT_SLOT_A; |
| 55 | + case '3': return EOS_MENU_BOOT_SLOT_B; |
| 56 | + case '4': return EOS_MENU_RECOVERY; |
| 57 | + case '5': return EOS_MENU_DIAGNOSTICS; |
| 58 | + case '6': return EOS_MENU_VIEW_LOG; |
| 59 | + case '7': return EOS_MENU_REBOOT; |
| 60 | + default: return EOS_MENU_TIMEOUT; |
| 61 | + } |
| 62 | +} |
0 commit comments