BV: support full only modes
This commit is contained in:
parent
9fe271f40a
commit
5dc18f91a2
|
@ -43,7 +43,7 @@
|
||||||
#include "busvoodoo_spi.h" // BusVoodoo SPI mode
|
#include "busvoodoo_spi.h" // BusVoodoo SPI mode
|
||||||
|
|
||||||
/** all supported BusVoodoo modes */
|
/** all supported BusVoodoo modes */
|
||||||
static struct busvoodoo_mode_t* busvoodoo_modes[] = {
|
static const struct busvoodoo_mode_t* busvoodoo_modes[] = {
|
||||||
&busvoodoo_hiz_mode,
|
&busvoodoo_hiz_mode,
|
||||||
&busvoodoo_uart_mode,
|
&busvoodoo_uart_mode,
|
||||||
&busvoodoo_i2c_mode,
|
&busvoodoo_i2c_mode,
|
||||||
|
@ -51,7 +51,7 @@ static struct busvoodoo_mode_t* busvoodoo_modes[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** current BusVoodoo mode */
|
/** current BusVoodoo mode */
|
||||||
static struct busvoodoo_mode_t* busvoodoo_mode = NULL;
|
static struct busvoodoo_mode_t const * busvoodoo_mode = NULL;
|
||||||
/** is mode setup complete */
|
/** is mode setup complete */
|
||||||
static bool busvoodoo_mode_complete = false;
|
static bool busvoodoo_mode_complete = false;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ size_t putc(char c)
|
||||||
/** switch BusVoddoo mode
|
/** switch BusVoddoo mode
|
||||||
* @param[in] mode mode to switch to
|
* @param[in] mode mode to switch to
|
||||||
*/
|
*/
|
||||||
static void switch_mode(struct busvoodoo_mode_t* mode)
|
static void switch_mode(const struct busvoodoo_mode_t* mode)
|
||||||
{
|
{
|
||||||
if (busvoodoo_mode) {
|
if (busvoodoo_mode) {
|
||||||
(*busvoodoo_mode->exit)(); // exit current mode
|
(*busvoodoo_mode->exit)(); // exit current mode
|
||||||
|
@ -124,36 +124,36 @@ static void command_reset(void* argument);
|
||||||
/** list of all supported commands */
|
/** list of all supported commands */
|
||||||
static const struct menu_command_t menu_commands[] = {
|
static const struct menu_command_t menu_commands[] = {
|
||||||
{
|
{
|
||||||
'm',
|
.shortcut = 'm',
|
||||||
"mode",
|
.name = "mode",
|
||||||
"select mode",
|
.command_description = "select mode",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
"[mode]",
|
.argument_description = "[mode]",
|
||||||
&command_mode,
|
.command_handler = &command_mode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'q',
|
.shortcut = 'q',
|
||||||
"quit",
|
.name = "quit",
|
||||||
"quit current mode",
|
.command_description = "quit current mode",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&command_quit,
|
.command_handler = &command_quit,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'r',
|
.shortcut = 'R',
|
||||||
"reset",
|
.name = "reset",
|
||||||
"reset board",
|
.command_description = "reset board",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&command_reset,
|
.command_handler = &command_reset,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'h',
|
.shortcut = 'h',
|
||||||
"help",
|
.name = "help",
|
||||||
"display help",
|
.command_description = "display help",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&command_help,
|
.command_handler = &command_help,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -163,7 +163,12 @@ static void command_help(void* argument)
|
||||||
printf("available commands:\n");
|
printf("available commands:\n");
|
||||||
menu_print_commands(menu_commands, LENGTH(menu_commands)); // print global commands
|
menu_print_commands(menu_commands, LENGTH(menu_commands)); // print global commands
|
||||||
menu_print_commands(busvoodoo_global_commands, busvoodoo_global_commands_nb); // 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
|
if (busvoodoo_full) {
|
||||||
|
menu_print_commands(busvoodoo_global_full_commands, busvoodoo_global_full_commands_nb); // print BusVoodoo global commands
|
||||||
|
}
|
||||||
|
if (!busvoodoo_mode->full_only || busvoodoo_full) {
|
||||||
|
menu_print_commands(busvoodoo_mode->commands, busvoodoo_mode->commands_nb); // print BusVoodoo mode commands
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void command_mode(void* argument)
|
static void command_mode(void* argument)
|
||||||
|
@ -171,13 +176,19 @@ static void command_mode(void* argument)
|
||||||
if (NULL==argument || 0==strlen(argument)) { // no mode provided: list all modes
|
if (NULL==argument || 0==strlen(argument)) { // no mode provided: list all modes
|
||||||
printf("available modes:\n");
|
printf("available modes:\n");
|
||||||
for (uint8_t i=0; i<LENGTH(busvoodoo_modes); i++) { // go through all modes
|
for (uint8_t i=0; i<LENGTH(busvoodoo_modes); i++) { // go through all modes
|
||||||
printf("%s\t%s\n", busvoodoo_modes[i]->name, busvoodoo_modes[i]->description); // display mode information
|
if (!busvoodoo_modes[i]->full_only || busvoodoo_full) {
|
||||||
|
printf("%s\t%s\n", busvoodoo_modes[i]->name, busvoodoo_modes[i]->description); // display mode information
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { // mode provided
|
} else { // mode provided
|
||||||
bool mode_found = false; // to know if we found the matching mode
|
bool mode_found = false; // to know if we found the matching mode
|
||||||
for (uint8_t i=0; i<LENGTH(busvoodoo_modes); i++) { // go through all modes
|
for (uint8_t i=0; i<LENGTH(busvoodoo_modes); i++) { // go through all modes
|
||||||
if (0==strcmp(argument, busvoodoo_modes[i]->name)) { // check for corresponding mode
|
if (0==strcmp(argument, busvoodoo_modes[i]->name)) { // check for corresponding mode
|
||||||
switch_mode(busvoodoo_modes[i]); // switch to mode
|
if (!busvoodoo_mode->full_only || busvoodoo_full) {
|
||||||
|
switch_mode(busvoodoo_modes[i]); // switch to mode
|
||||||
|
} else {
|
||||||
|
printf("mode only available for BusVoodoo full\n");
|
||||||
|
}
|
||||||
mode_found = true; // remember we found the mode
|
mode_found = true; // remember we found the mode
|
||||||
break; // stop searching for mode
|
break; // stop searching for mode
|
||||||
}
|
}
|
||||||
|
@ -217,17 +228,26 @@ static void process_command(char* str)
|
||||||
if (!busvoodoo_mode_complete) { // mode setup is not complete
|
if (!busvoodoo_mode_complete) { // mode setup is not complete
|
||||||
busvoodoo_mode_complete = (*busvoodoo_mode->setup)(&terminal_prefix, str); // continue setup
|
busvoodoo_mode_complete = (*busvoodoo_mode->setup)(&terminal_prefix, str); // continue setup
|
||||||
terminal_send(0); // update the terminal prompt
|
terminal_send(0); // update the terminal prompt
|
||||||
} else {
|
} else { // mode setup is complete
|
||||||
// don't handle empty lines
|
// don't handle empty lines
|
||||||
if (!str || 0==strlen(str)) {
|
if (!str || 0==strlen(str)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!menu_handle_command(str, busvoodoo_mode->commands, busvoodoo_mode->commands_nb)) {
|
bool command_handled = false;
|
||||||
if (!menu_handle_command(str, busvoodoo_global_commands, busvoodoo_global_commands_nb)) {
|
if (!busvoodoo_mode->full_only || busvoodoo_full) {
|
||||||
if (!menu_handle_command(str, menu_commands, LENGTH(menu_commands))) {
|
command_handled = menu_handle_command(str, busvoodoo_mode->commands, busvoodoo_mode->commands_nb); // try if the mode can handle this command
|
||||||
printf("command not recognized. enter help to list commands\n");
|
}
|
||||||
}
|
if (!command_handled && busvoodoo_full) {
|
||||||
}
|
command_handled = menu_handle_command(str, busvoodoo_global_full_commands, busvoodoo_global_full_commands_nb); // try if full BusVoodoo can handle this command
|
||||||
|
}
|
||||||
|
if (!command_handled) {
|
||||||
|
command_handled = menu_handle_command(str, busvoodoo_global_commands, busvoodoo_global_commands_nb); // try if the base BusVoodoo can handle this command
|
||||||
|
}
|
||||||
|
if (!command_handled) {
|
||||||
|
command_handled = menu_handle_command(str, menu_commands, LENGTH(menu_commands)); // try if this is not a global command
|
||||||
|
}
|
||||||
|
if (!command_handled) {
|
||||||
|
printf("command not recognized. enter help to list commands\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -723,44 +723,48 @@ static void busvoodoo_global_pinout(void* argument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** list of supported commands */
|
|
||||||
const struct menu_command_t busvoodoo_global_commands[] = {
|
const struct menu_command_t busvoodoo_global_commands[] = {
|
||||||
{
|
{
|
||||||
'P',
|
.shortcut = 'p',
|
||||||
"power",
|
.name = "pinout",
|
||||||
"switch 3V3 and 5V power rails on/off, or read internal voltages",
|
.command_description = "show connector pinout",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
"[on|off]",
|
.argument_description = NULL,
|
||||||
&busvoodoo_global_power,
|
.command_handler = &busvoodoo_global_pinout,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'L',
|
.shortcut = 'P',
|
||||||
"LV",
|
.name = "power",
|
||||||
"set voltage on low voltage power rail (0, 0.3-4.8, 5V), or read voltage on pin",
|
.command_description = "switch 3V3 and 5V power rails on/off, or read internal voltages",
|
||||||
MENU_ARGUMENT_FLOAT,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
"[voltage]",
|
.argument_description = "[on|off]",
|
||||||
&busvoodoo_global_lv,
|
.command_handler = &busvoodoo_global_power,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'H',
|
.shortcut = 'L',
|
||||||
"HV",
|
.name = "LV",
|
||||||
"set voltage on high voltage power rail (0, 3.3-24V), or read voltage on pin",
|
.command_description = "set voltage on low voltage power rail (0, 0.3-4.8, 5V), or read voltage on pin",
|
||||||
MENU_ARGUMENT_FLOAT,
|
.argument = MENU_ARGUMENT_FLOAT,
|
||||||
"[voltage]",
|
.argument_description = "[voltage]",
|
||||||
&busvoodoo_global_hv,
|
.command_handler = &busvoodoo_global_lv,
|
||||||
},
|
|
||||||
{
|
|
||||||
'p',
|
|
||||||
"pinout",
|
|
||||||
"show connector pinout",
|
|
||||||
MENU_ARGUMENT_NONE,
|
|
||||||
NULL,
|
|
||||||
&busvoodoo_global_pinout,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t busvoodoo_global_commands_nb = LENGTH(busvoodoo_global_commands);
|
const uint8_t busvoodoo_global_commands_nb = LENGTH(busvoodoo_global_commands);
|
||||||
|
|
||||||
|
const struct menu_command_t busvoodoo_global_full_commands[] = {
|
||||||
|
{
|
||||||
|
.shortcut = 'H',
|
||||||
|
.name = "HV",
|
||||||
|
.command_description = "set voltage on high voltage power rail (0, 3.3-24V), or read voltage on pin",
|
||||||
|
.argument = MENU_ARGUMENT_FLOAT,
|
||||||
|
.argument_description = "[voltage]",
|
||||||
|
.command_handler = &busvoodoo_global_hv,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t busvoodoo_global_full_commands_nb = LENGTH(busvoodoo_global_full_commands);
|
||||||
|
|
||||||
/** interrupt service routine called on LED timeout */
|
/** interrupt service routine called on LED timeout */
|
||||||
void TIM_ISR(BUSVOODOO_LED_TIMER)(void)
|
void TIM_ISR(BUSVOODOO_LED_TIMER)(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
struct busvoodoo_mode_t {
|
struct busvoodoo_mode_t {
|
||||||
const char* name; /**< name of the mode (i.e. protocol shortcut for the menu) */
|
const char* name; /**< name of the mode (i.e. protocol shortcut for the menu) */
|
||||||
const char* description; /**< human readable description of the mode (i.e. full protocol name) */
|
const char* description; /**< human readable description of the mode (i.e. full protocol name) */
|
||||||
|
const bool full_only; /**< if this mode is available only for BusVoodoo full flavor */
|
||||||
bool (*setup)(char** prefix, const char* line); /**< function to setup mode (menu prefix can be used to ask parameter, and line will be the user provided response)*/
|
bool (*setup)(char** prefix, const char* line); /**< function to setup mode (menu prefix can be used to ask parameter, and line will be the user provided response)*/
|
||||||
const struct menu_command_t* commands; /**< list of menu commands provided by mode */
|
const struct menu_command_t* commands; /**< list of menu commands provided by mode */
|
||||||
const uint8_t commands_nb; /**< number of menu commands provided by mode */
|
const uint8_t commands_nb; /**< number of menu commands provided by mode */
|
||||||
|
@ -130,10 +131,14 @@ extern const uint8_t busvoodoo_io_groups[13]; /**< which I/O pin (group) does th
|
||||||
extern bool busvoodoo_full;
|
extern bool busvoodoo_full;
|
||||||
/** version of the hardware board */
|
/** version of the hardware board */
|
||||||
extern char busvoodoo_version;
|
extern char busvoodoo_version;
|
||||||
/** list of supported commands */
|
/** list of supported commands for base BusVoodoo */
|
||||||
extern const struct menu_command_t busvoodoo_global_commands[];
|
extern const struct menu_command_t busvoodoo_global_commands[];
|
||||||
/** number supported commands */
|
/** number supported commands for base BusVoodoo */
|
||||||
extern const uint8_t busvoodoo_global_commands_nb;
|
extern const uint8_t busvoodoo_global_commands_nb;
|
||||||
|
/** list of supported commands for BusVoodoo full only */
|
||||||
|
extern const struct menu_command_t busvoodoo_global_full_commands[];
|
||||||
|
/** number supported commands for BusVoodoo full only */
|
||||||
|
extern const uint8_t busvoodoo_global_full_commands_nb;
|
||||||
|
|
||||||
/** I/O connector pinout */
|
/** I/O connector pinout */
|
||||||
extern const char* busvoodoo_global_pinout_io[10];
|
extern const char* busvoodoo_global_pinout_io[10];
|
||||||
|
|
|
@ -63,7 +63,7 @@ static bool busvoodoo_hiz_setup(char** prefix, const char* line)
|
||||||
for (uint8_t i=0; i<LENGTH(pinout_rscan) && i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
for (uint8_t i=0; i<LENGTH(pinout_rscan) && i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
||||||
busvoodoo_global_pinout_rscan[i] = pinout_rscan[i]; // set pin names
|
busvoodoo_global_pinout_rscan[i] = pinout_rscan[i]; // set pin names
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
busvoodoo_oled_text_pinout(busvoodoo_global_pinout_io, true); // set pinout on display
|
busvoodoo_oled_text_pinout(busvoodoo_global_pinout_io, true); // set pinout on display
|
||||||
busvoodoo_oled_update(); // update display to show text and pinout
|
busvoodoo_oled_update(); // update display to show text and pinout
|
||||||
return true;
|
return true;
|
||||||
|
@ -860,44 +860,45 @@ static void busvoodoo_hiz_command_test_pins(void* argument)
|
||||||
/** HiZ menu commands */
|
/** HiZ menu commands */
|
||||||
static const struct menu_command_t busvoodoo_hiz_commands[] = {
|
static const struct menu_command_t busvoodoo_hiz_commands[] = {
|
||||||
{
|
{
|
||||||
'v',
|
.shortcut = 'v',
|
||||||
"version",
|
.name = "version",
|
||||||
"show hardware and firmware version",
|
.command_description = "show hardware and firmware version",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_hiz_version,
|
.command_handler = &busvoodoo_hiz_version,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'b',
|
.shortcut = 'b',
|
||||||
"bootloader",
|
.name = "bootloader",
|
||||||
"reboot into DFU bootloader",
|
.command_description = "reboot into DFU bootloader",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_hiz_bootloader,
|
.command_handler = &busvoodoo_hiz_bootloader,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
's',
|
.shortcut = 's',
|
||||||
"self-test [halt]",
|
.name = "self-test [halt]",
|
||||||
"perform board self-test (optional halt on error)",
|
.command_description = "perform board self-test (optional halt on error)",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_hiz_command_test_self,
|
.command_handler = &busvoodoo_hiz_command_test_self,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
't',
|
.shortcut = 't',
|
||||||
"pins-test [halt]",
|
.name = "pins-test [halt]",
|
||||||
"perform connector pins test (optional halt on error)",
|
.command_description = "perform connector pins test (optional halt on error)",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_hiz_command_test_pins,
|
.command_handler = &busvoodoo_hiz_command_test_pins,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct busvoodoo_mode_t busvoodoo_hiz_mode = {
|
const struct busvoodoo_mode_t busvoodoo_hiz_mode = {
|
||||||
"hiz",
|
.name = "hiz",
|
||||||
"High Impedance (Z)",
|
.description = "High Impedance (Z)",
|
||||||
&busvoodoo_hiz_setup,
|
.full_only = false,
|
||||||
busvoodoo_hiz_commands,
|
.setup = &busvoodoo_hiz_setup,
|
||||||
LENGTH(busvoodoo_hiz_commands),
|
.commands = busvoodoo_hiz_commands,
|
||||||
&busvoodoo_hiz_exit,
|
.commands_nb = LENGTH(busvoodoo_hiz_commands),
|
||||||
|
.exit = &busvoodoo_hiz_exit,
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,4 +19,4 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** HiZ mode interface definition */
|
/** HiZ mode interface definition */
|
||||||
extern struct busvoodoo_mode_t busvoodoo_hiz_mode;
|
extern const struct busvoodoo_mode_t busvoodoo_hiz_mode;
|
||||||
|
|
|
@ -129,6 +129,12 @@ static bool busvoodoo_i2c_setup(char** prefix, const char* line)
|
||||||
for (uint8_t i=0; i<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
for (uint8_t i=0; i<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
||||||
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
|
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
|
||||||
}
|
}
|
||||||
|
if (busvoodoo_full) {
|
||||||
|
const char* pinout_rscan[5] = {"HV", NULL, NULL, NULL, NULL}; // HiZ mode RS/CAN pinout
|
||||||
|
for (uint8_t i=0; i<LENGTH(pinout_rscan) && i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
||||||
|
busvoodoo_global_pinout_rscan[i] = pinout_rscan[i]; // set pin names
|
||||||
|
}
|
||||||
|
}
|
||||||
busvoodoo_oled_text_pinout(pinout_io, true); // set pinout on display
|
busvoodoo_oled_text_pinout(pinout_io, true); // set pinout on display
|
||||||
busvoodoo_oled_update(); // update display to show text and pinout
|
busvoodoo_oled_update(); // update display to show text and pinout
|
||||||
complete = true; // configuration is complete
|
complete = true; // configuration is complete
|
||||||
|
@ -171,7 +177,7 @@ static void busvoodoo_i2c_read(void)
|
||||||
printf("not in receive mode");
|
printf("not in receive mode");
|
||||||
break;
|
break;
|
||||||
case I2C_MASTER_RC_BUS_ERROR:
|
case I2C_MASTER_RC_BUS_ERROR:
|
||||||
printf("error detected on bus (flush I2C peripheral to correct)");
|
printf("error detected on bus (reset I2C peripheral to correct)");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("error");
|
printf("error");
|
||||||
|
@ -203,7 +209,7 @@ static void busvoodoo_i2c_write(uint8_t data)
|
||||||
printf("not in transmit mode");
|
printf("not in transmit mode");
|
||||||
break;
|
break;
|
||||||
case I2C_MASTER_RC_BUS_ERROR:
|
case I2C_MASTER_RC_BUS_ERROR:
|
||||||
printf("error detected on bus (flush I2C peripheral to correct)");
|
printf("error detected on bus (reset I2C peripheral to correct)");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("error");
|
printf("error");
|
||||||
|
@ -242,7 +248,7 @@ static void busvoodoo_i2c_select(uint16_t slave, bool write)
|
||||||
printf("not in transmit mode");
|
printf("not in transmit mode");
|
||||||
break;
|
break;
|
||||||
case I2C_MASTER_RC_BUS_ERROR:
|
case I2C_MASTER_RC_BUS_ERROR:
|
||||||
printf("error detected on bus (flush I2C peripheral to correct)");
|
printf("error detected on bus (reset I2C peripheral to correct)");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("error");
|
printf("error");
|
||||||
|
@ -517,36 +523,37 @@ static void busvoodoo_i2c_command_scan(void* argument)
|
||||||
/** I2C menu commands */
|
/** I2C menu commands */
|
||||||
static const struct menu_command_t busvoodoo_i2c_commands[] = {
|
static const struct menu_command_t busvoodoo_i2c_commands[] = {
|
||||||
{
|
{
|
||||||
'f',
|
.shortcut = 'r',
|
||||||
"flush",
|
.name = "reset_i2c",
|
||||||
"flush I2C peripheral",
|
.command_description = "reset I2C peripheral",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_i2c_command_reset,
|
.command_handler = &busvoodoo_i2c_command_reset,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'a',
|
.shortcut = 'a',
|
||||||
"action",
|
.name = "action",
|
||||||
"perform protocol actions",
|
.command_description = "perform protocol actions",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
"[actions]",
|
.argument_description = "[actions]",
|
||||||
&busvoodoo_i2c_command_actions,
|
.command_handler = &busvoodoo_i2c_command_actions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
's',
|
.shortcut = 's',
|
||||||
"scan",
|
.name = "scan",
|
||||||
"scan for slave devices",
|
.command_description = "scan for slave devices",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_i2c_command_scan,
|
.command_handler = &busvoodoo_i2c_command_scan,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct busvoodoo_mode_t busvoodoo_i2c_mode = {
|
const struct busvoodoo_mode_t busvoodoo_i2c_mode = {
|
||||||
"i2c",
|
.name = "i2c",
|
||||||
"Inter-Integrated Circuit",
|
.description = "Inter-Integrated Circuit",
|
||||||
&busvoodoo_i2c_setup,
|
.full_only = false,
|
||||||
busvoodoo_i2c_commands,
|
.setup = &busvoodoo_i2c_setup,
|
||||||
LENGTH(busvoodoo_i2c_commands),
|
.commands = busvoodoo_i2c_commands,
|
||||||
&busvoodoo_i2c_exit,
|
.commands_nb = LENGTH(busvoodoo_i2c_commands),
|
||||||
|
.exit = &busvoodoo_i2c_exit,
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,4 +20,4 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** I2C mode interface definition */
|
/** I2C mode interface definition */
|
||||||
extern struct busvoodoo_mode_t busvoodoo_i2c_mode;
|
extern const struct busvoodoo_mode_t busvoodoo_i2c_mode;
|
||||||
|
|
|
@ -252,6 +252,12 @@ static bool busvoodoo_spi_setup(char** prefix, const char* line)
|
||||||
for (uint8_t i=0; i<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
for (uint8_t i=0; i<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
||||||
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
|
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
|
||||||
}
|
}
|
||||||
|
if (busvoodoo_full) {
|
||||||
|
const char* pinout_rscan[5] = {"HV", NULL, NULL, NULL, NULL}; // HiZ mode RS/CAN pinout
|
||||||
|
for (uint8_t i=0; i<LENGTH(pinout_rscan) && i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
||||||
|
busvoodoo_global_pinout_rscan[i] = pinout_rscan[i]; // set pin names
|
||||||
|
}
|
||||||
|
}
|
||||||
busvoodoo_oled_text_pinout(pinout_io, true); // set pinout on display
|
busvoodoo_oled_text_pinout(pinout_io, true); // set pinout on display
|
||||||
busvoodoo_oled_update(); // update display to show text and pinout
|
busvoodoo_oled_update(); // update display to show text and pinout
|
||||||
complete = true; // configuration is complete
|
complete = true; // configuration is complete
|
||||||
|
@ -481,20 +487,21 @@ static void busvoodoo_spi_command_actions(void* argument)
|
||||||
/** SPI menu commands */
|
/** SPI menu commands */
|
||||||
static const struct menu_command_t busvoodoo_spi_commands[] = {
|
static const struct menu_command_t busvoodoo_spi_commands[] = {
|
||||||
{
|
{
|
||||||
'a',
|
.shortcut = 'a',
|
||||||
"action",
|
.name = "action",
|
||||||
"perform protocol actions",
|
.command_description = "perform protocol actions",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
"[actions]",
|
.argument_description = "[actions]",
|
||||||
&busvoodoo_spi_command_actions,
|
.command_handler = &busvoodoo_spi_command_actions,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct busvoodoo_mode_t busvoodoo_spi_mode = {
|
const struct busvoodoo_mode_t busvoodoo_spi_mode = {
|
||||||
"spi",
|
.name = "spi",
|
||||||
"Serial Peripheral Interface",
|
.description = "Serial Peripheral Interface",
|
||||||
&busvoodoo_spi_setup,
|
.full_only = false,
|
||||||
busvoodoo_spi_commands,
|
.setup = &busvoodoo_spi_setup,
|
||||||
LENGTH(busvoodoo_spi_commands),
|
.commands = busvoodoo_spi_commands,
|
||||||
&busvoodoo_spi_exit,
|
.commands_nb = LENGTH(busvoodoo_spi_commands),
|
||||||
|
.exit = &busvoodoo_spi_exit,
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,4 +20,4 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** SPI mode interface definition */
|
/** SPI mode interface definition */
|
||||||
extern struct busvoodoo_mode_t busvoodoo_spi_mode;
|
extern const struct busvoodoo_mode_t busvoodoo_spi_mode;
|
||||||
|
|
|
@ -243,6 +243,12 @@ static bool busvoodoo_uart_setup(char** prefix, const char* line)
|
||||||
for (uint8_t i=0; i<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
for (uint8_t i=0; i<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
||||||
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
|
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
|
||||||
}
|
}
|
||||||
|
if (busvoodoo_full) {
|
||||||
|
const char* pinout_rscan[5] = {"HV", NULL, NULL, NULL, NULL}; // HiZ mode RS/CAN pinout
|
||||||
|
for (uint8_t i=0; i<LENGTH(pinout_rscan) && i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
||||||
|
busvoodoo_global_pinout_rscan[i] = pinout_rscan[i]; // set pin names
|
||||||
|
}
|
||||||
|
}
|
||||||
busvoodoo_oled_text_pinout((const char**)pinout_io, true); // set pinout on display
|
busvoodoo_oled_text_pinout((const char**)pinout_io, true); // set pinout on display
|
||||||
busvoodoo_oled_update(); // update display to show text and pinout
|
busvoodoo_oled_update(); // update display to show text and pinout
|
||||||
complete = true; // configuration is complete
|
complete = true; // configuration is complete
|
||||||
|
@ -636,52 +642,53 @@ static void busvoodoo_uart_command_error(void* argument)
|
||||||
/** UART menu commands */
|
/** UART menu commands */
|
||||||
static const struct menu_command_t busvoodoo_uart_commands[] = {
|
static const struct menu_command_t busvoodoo_uart_commands[] = {
|
||||||
{
|
{
|
||||||
'a',
|
.shortcut = 'a',
|
||||||
"action",
|
.name = "action",
|
||||||
"perform protocol actions",
|
.command_description = "perform protocol actions",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
"[actions]",
|
.argument_description = "[actions]",
|
||||||
&busvoodoo_uart_command_actions,
|
.command_handler = &busvoodoo_uart_command_actions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'r',
|
.shortcut = 'r',
|
||||||
"receive",
|
.name = "receive",
|
||||||
"show incoming data [in hexadecimal or binary]",
|
.command_description = "show incoming data [in hexadecimal or binary]",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
"[hex|bin]",
|
.argument_description = "[hex|bin]",
|
||||||
&busvoodoo_uart_command_receive,
|
.command_handler = &busvoodoo_uart_command_receive,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
't',
|
.shortcut = 't',
|
||||||
"transmit",
|
.name = "transmit",
|
||||||
"transmit ASCII text (empty for CR+LF)",
|
.command_description = "transmit ASCII text (empty for CR+LF)",
|
||||||
MENU_ARGUMENT_STRING,
|
.argument = MENU_ARGUMENT_STRING,
|
||||||
"[text]",
|
.argument_description = "[text]",
|
||||||
&busvoodoo_uart_command_transmit,
|
.command_handler = &busvoodoo_uart_command_transmit,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'x',
|
.shortcut = 'x',
|
||||||
"transceive",
|
.name = "transceive",
|
||||||
"transmit and receive data",
|
.command_description = "transmit and receive data",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_uart_command_transceive,
|
.command_handler = &busvoodoo_uart_command_transceive,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'e',
|
.shortcut = 'e',
|
||||||
"error",
|
.name = "error",
|
||||||
"verify incoming transmission for errors",
|
.command_description = "verify incoming transmission for errors",
|
||||||
MENU_ARGUMENT_NONE,
|
.argument = MENU_ARGUMENT_NONE,
|
||||||
NULL,
|
.argument_description = NULL,
|
||||||
&busvoodoo_uart_command_error,
|
.command_handler = &busvoodoo_uart_command_error,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct busvoodoo_mode_t busvoodoo_uart_mode = {
|
const struct busvoodoo_mode_t busvoodoo_uart_mode = {
|
||||||
"uart",
|
.name = "uart",
|
||||||
"Universal Asynchronous Receiver-Transmitter",
|
.description = "Universal Asynchronous Receiver-Transmitter",
|
||||||
&busvoodoo_uart_setup,
|
.full_only = false,
|
||||||
busvoodoo_uart_commands,
|
.setup = &busvoodoo_uart_setup,
|
||||||
LENGTH(busvoodoo_uart_commands),
|
.commands = busvoodoo_uart_commands,
|
||||||
&busvoodoo_uart_exit,
|
.commands_nb = LENGTH(busvoodoo_uart_commands),
|
||||||
|
.exit = &busvoodoo_uart_exit,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue