busvoodoo: add HiZ mode interface
This commit is contained in:
parent
d2734a6fd7
commit
8b7b262065
|
@ -93,6 +93,10 @@ static void command_reset(void* argument);
|
|||
* @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[] = {
|
||||
|
@ -128,6 +132,14 @@ static const struct menu_command_t menu_commands[] = {
|
|||
NULL,
|
||||
&command_bootloader,
|
||||
},
|
||||
{
|
||||
'V',
|
||||
"version",
|
||||
"show hardware and firmware version",
|
||||
MENU_ARGUMENT_NONE,
|
||||
NULL,
|
||||
&command_version,
|
||||
},
|
||||
};
|
||||
|
||||
static void command_help(void* argument)
|
||||
|
@ -136,7 +148,7 @@ static void command_help(void* 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_hiz_commands, LENGTH(busvoodoo_hiz_commands)); // print BusVoodoo HiZ commands
|
||||
menu_print_commands(busvoodoo_hiz_mode.commands, busvoodoo_hiz_mode.commands_nb); // print BusVoodoo HiZ commands
|
||||
}
|
||||
|
||||
static void command_led(void* argument)
|
||||
|
@ -177,6 +189,13 @@ static void command_bootloader(void* argument)
|
|||
while (true); // wait for the reset to happen
|
||||
}
|
||||
|
||||
static void command_version(void* argument)
|
||||
{
|
||||
(void)argument; // we won't use the argument
|
||||
printf("BusVoodoo board: %s\n", busvoodoo_full ? "full" : "light");
|
||||
printf("firmware date: %s\n", __DATE__);
|
||||
}
|
||||
|
||||
/** process user command
|
||||
* @param[in] str user command string (\0 ended)
|
||||
*/
|
||||
|
@ -191,7 +210,7 @@ static void process_command(char* str)
|
|||
return;
|
||||
}
|
||||
// handle user input
|
||||
if (!menu_handle_command(str, busvoodoo_hiz_commands, LENGTH(busvoodoo_hiz_commands))) {
|
||||
if (!menu_handle_command(str, busvoodoo_hiz_mode.commands, busvoodoo_hiz_mode.commands_nb)) {
|
||||
if (!menu_handle_command(str, busvoodoo_global_commands, LENGTH(busvoodoo_global_commands))) {
|
||||
if (!menu_handle_command(str, menu_commands, LENGTH(menu_commands))) {
|
||||
printf("command not recognized. enter help to list commands\n");
|
||||
|
@ -229,10 +248,14 @@ void main(void)
|
|||
}
|
||||
printf(" version)\n");
|
||||
|
||||
// main loop
|
||||
terminal_prefix = "BV: "; // set terminal prefix
|
||||
terminal_process = &process_command;
|
||||
// setup default HiZ mode
|
||||
(*busvoodoo_hiz_mode.setup)(&terminal_prefix, NULL);
|
||||
|
||||
// setup terminal
|
||||
terminal_process = &process_command; // set central function to process commands
|
||||
terminal_setup(); // start terminal
|
||||
|
||||
// main loop
|
||||
bool action = false; // if an action has been performed don't go to sleep
|
||||
button_flag = false; // reset button flag
|
||||
char c = '\0'; // to store received character
|
||||
|
@ -240,20 +263,17 @@ void main(void)
|
|||
while (true) { // infinite loop
|
||||
while (uart_received) { // data received over UART
|
||||
action = true; // action has been performed
|
||||
led_toggle(); // toggle LED
|
||||
c = uart_getchar(); // store receive character
|
||||
char_flag = true; // notify character has been received
|
||||
}
|
||||
while (usb_cdcacm_received) { // data received over USB
|
||||
action = true; // action has been performed
|
||||
led_toggle(); // toggle LED
|
||||
c = usb_cdcacm_getchar(); // store receive character
|
||||
char_flag = true; // notify character has been received
|
||||
}
|
||||
while (char_flag) { // user data received
|
||||
char_flag = false; // reset flag
|
||||
action = true; // action has been performed
|
||||
// printf("%02x\n", c);
|
||||
terminal_send(c); // send received character to terminal
|
||||
}
|
||||
while (button_flag) { // user pressed button
|
||||
|
|
|
@ -40,6 +40,25 @@
|
|||
#define BUSVOODOO_12V_DEFAULT (1.25*(1+100.0/10.0)) /**< default (when not driven) 12V voltage regulator output voltage based on R1 and R2 */
|
||||
#define BUSVOODOO_12V_TEST 12.0 /**< target 12V output voltage to test if we can set control the 12V voltage regulator */
|
||||
|
||||
/** setup HiZ mode
|
||||
* @param[out] prefix terminal prompt prefix
|
||||
* @param[in] line terminal prompt line to configure mode
|
||||
* @return if setup is complete
|
||||
*/
|
||||
static bool busvoodoo_hiz_setup(char** prefix, const char* line)
|
||||
{
|
||||
(void)line; // no configuration is required
|
||||
*prefix = "HiZ: "; // set command line prefix
|
||||
return true;
|
||||
}
|
||||
|
||||
/** exit HiZ mode
|
||||
*/
|
||||
static void busvoodoo_hiz_exit(void)
|
||||
{
|
||||
// there is nothing to do
|
||||
}
|
||||
|
||||
/** perform self tests
|
||||
* @return if self tests passed
|
||||
*/
|
||||
|
@ -655,7 +674,7 @@ static void busvoodoo_hiz_command_test_pins(void* argument)
|
|||
}
|
||||
}
|
||||
|
||||
const struct menu_command_t busvoodoo_hiz_commands[] = {
|
||||
static const struct menu_command_t busvoodoo_hiz_commands[] = {
|
||||
{
|
||||
's',
|
||||
"self-test",
|
||||
|
@ -673,3 +692,10 @@ const struct menu_command_t busvoodoo_hiz_commands[] = {
|
|||
&busvoodoo_hiz_command_test_pins,
|
||||
},
|
||||
};
|
||||
|
||||
const struct busvoodoo_mode_t busvoodoo_hiz_mode = {
|
||||
&busvoodoo_hiz_setup,
|
||||
busvoodoo_hiz_commands,
|
||||
LENGTH(busvoodoo_hiz_commands),
|
||||
&busvoodoo_hiz_exit,
|
||||
};
|
||||
|
|
|
@ -18,5 +18,5 @@
|
|||
* @date 2018
|
||||
*/
|
||||
|
||||
/** list of supported commands */
|
||||
extern const struct menu_command_t busvoodoo_hiz_commands[2];
|
||||
/** HiZ mode interface definition */
|
||||
extern const struct busvoodoo_mode_t busvoodoo_hiz_mode;
|
||||
|
|
Loading…
Reference in New Issue