BV: move version and bootloader command to HiZ mode to reduce menu size in other modes

This commit is contained in:
King Kévin 2018-03-15 19:20:27 +01:00
parent 6391674bb7
commit af666455bd
4 changed files with 51 additions and 41 deletions

View File

@ -120,11 +120,6 @@ static void command_reset(void* argument);
/** command to reboot into bootloader
* @param[in] argument no argument required
*/
static void command_bootloader(void* argument);
/** command to show version
* @param[in] argument no argument required
*/
static void command_version(void* argument);
/** list of all supported commands */
static const struct menu_command_t menu_commands[] = {
@ -152,22 +147,6 @@ static const struct menu_command_t menu_commands[] = {
NULL,
&command_reset,
},
{
'b',
"bootloader",
"reboot into DFU bootloader",
MENU_ARGUMENT_NONE,
NULL,
&command_bootloader,
},
{
'v',
"version",
"show hardware and firmware version",
MENU_ARGUMENT_NONE,
NULL,
&command_version,
},
{
'h',
"help",
@ -183,7 +162,7 @@ static void command_help(void* argument)
(void)argument; // we won't use the argument
printf("available commands:\n");
menu_print_commands(menu_commands, LENGTH(menu_commands)); // print global commands
menu_print_commands(busvoodoo_global_commands, LENGTH(busvoodoo_global_commands)); // print BusVoodoo global commands
menu_print_commands(busvoodoo_global_commands, busvoodoo_global_commands_nb); // print BusVoodoo global commands
menu_print_commands(busvoodoo_mode->commands, busvoodoo_mode->commands_nb); // print BusVoodoo mode commands
}
@ -222,23 +201,6 @@ static void command_reset(void* argument)
while (true); // wait for the reset to happen
}
static void command_bootloader(void* argument)
{
(void)argument; // we won't use the argument
RCC_CSR |= RCC_CSR_RMVF; // clear reset flags
scb_reset_core(); // reset core (the bootloader will interpret it as starting into DFU)
while (true); // wait for the reset to happen
}
static void command_version(void* argument)
{
(void)argument; // we won't use the argument
printf("hardware flavor: %s\n", busvoodoo_full ? "full" : "light");
printf("board version: %c\n", busvoodoo_version);
printf("firmware date: %04u-%02u-%02u\n", BUILD_YEAR, BUILD_MONTH, BUILD_DAY);
printf("device ID: %08x%08x%08x\n", DESIG_UNIQUE_ID0, DESIG_UNIQUE_ID1, DESIG_UNIQUE_ID2);
}
/** process user command
* @param[in] str user command string (\0 ended)
*/
@ -261,7 +223,7 @@ static void process_command(char* str)
return;
}
if (!menu_handle_command(str, busvoodoo_mode->commands, busvoodoo_mode->commands_nb)) {
if (!menu_handle_command(str, busvoodoo_global_commands, LENGTH(busvoodoo_global_commands))) {
if (!menu_handle_command(str, busvoodoo_global_commands, busvoodoo_global_commands_nb)) {
if (!menu_handle_command(str, menu_commands, LENGTH(menu_commands))) {
printf("command not recognized. enter help to list commands\n");
}

View File

@ -698,6 +698,8 @@ const struct menu_command_t busvoodoo_global_commands[] = {
},
};
const uint8_t busvoodoo_global_commands_nb = LENGTH(busvoodoo_global_commands);
/** interrupt service routine called on LED timeout */
void TIM_ISR(BUSVOODOO_LED_TIMER)(void)
{

View File

@ -128,7 +128,9 @@ extern bool busvoodoo_full;
/** version of the hardware board */
extern char busvoodoo_version;
/** list of supported commands */
extern const struct menu_command_t busvoodoo_global_commands[4];
extern const struct menu_command_t busvoodoo_global_commands[];
/** number supported commands */
extern const uint8_t busvoodoo_global_commands_nb;
/** I/O connector pinout */
extern const char* busvoodoo_global_pinout_io[10];

View File

@ -22,6 +22,7 @@
#include <math.h> // math utilities
/* STM32 (including CM3) libraries */
#include <libopencmsis/core_cm3.h> // Cortex M3 utilities
#include <libopencm3/stm32/gpio.h> // general purpose input output library
#include <libopencm3/stm32/rcc.h> // real-time control clock library
#include <libopencm3/stm32/dbgmcu.h> // debug utilities
@ -934,6 +935,33 @@ error:
}
// command handlers
/** switch to DFU bootloader
* @param[in] argument not used
* @note this handler is in HiZ mode only to save shortcut space and reduce menu size
*/
static void busvoodoo_hiz_bootloader(void* argument)
{
(void)argument; // we won't use the argument
RCC_CSR |= RCC_CSR_RMVF; // clear reset flags
scb_reset_core(); // reset core (the bootloader will interpret it as starting into DFU)
while (true); // wait for the reset to happen
}
/** show BusVoodoo version
* @param[in] argument not used
* @note this handler is in HiZ mode only to save shortcut space and reduce menu size
*/
static void busvoodoo_hiz_version(void* argument)
{
(void)argument; // we won't use the argument
printf("BusVoodoo flavor: %s\n", busvoodoo_full ? "full" : "light");
printf("hardware version: %c\n", busvoodoo_version);
printf("firmware date: %04u-%02u-%02u\n", BUILD_YEAR, BUILD_MONTH, BUILD_DAY);
printf("device ID: %08x%08x%08x\n", DESIG_UNIQUE_ID0, DESIG_UNIQUE_ID1, DESIG_UNIQUE_ID2);
}
/** command to perform board self-test
* @param[in] argument no argument required
*/
@ -979,6 +1007,22 @@ static void busvoodoo_hiz_command_test_pins(void* argument)
}
static const struct menu_command_t busvoodoo_hiz_commands[] = {
{
'v',
"version",
"show hardware and firmware version",
MENU_ARGUMENT_NONE,
NULL,
&busvoodoo_hiz_version,
},
{
'b',
"bootloader",
"reboot into DFU bootloader",
MENU_ARGUMENT_NONE,
NULL,
&busvoodoo_hiz_bootloader,
},
{
's',
"self-test",