application: add signal type determination

This commit is contained in:
King Kévin 2021-03-11 11:21:22 +01:00
parent 66f26f3093
commit 312da80d6b
1 changed files with 45 additions and 0 deletions

View File

@ -231,6 +231,43 @@ static void command_voltages(void* argument)
}
}
/** identify if signal is an input or output
* @param[in] argument no argument required
*/
static void command_types(void* argument)
{
(void)argument; // we won't use the argument
float* voltages;
print_voltage_target(); // print target voltage (also sets measurement conditions)
puts("signal voltage pulled pulled\n");
puts(" pin raw down up \n");
// just to be sure, reset measurement conditions
gpio_set(GPIO_PORT(SIGNAL_PD_PIN), GPIO_PIN(SIGNAL_PD_PIN)); // ensure pull-down is not active
gpio_set(GPIO_PORT(SIGNAL_PU_PIN), GPIO_PIN(SIGNAL_PU_PIN)); // ensure pull-up is not active
gpio_set(GPIO_PORT(TARGET_EN), GPIO_PIN(TARGET_EN)); // ensure the level shifters pulling up the signals are not enabled
for (uint8_t i = 0; i < SIGNAL_NUMBERS; i++) {
puts(signal_names[i]);
puts(" ");
mux_select(i); // select the channel
voltages = measure_voltages(); // measure raw voltages
print_voltage(voltages[2], 2);
puts(" ");
gpio_clear(GPIO_PORT(SIGNAL_PD_PIN), GPIO_PIN(SIGNAL_PD_PIN)); // pull-down signal
voltages = measure_voltages(); // measure pulled down voltages
print_voltage(voltages[2], 2);
gpio_set(GPIO_PORT(SIGNAL_PD_PIN), GPIO_PIN(SIGNAL_PD_PIN)); // remove pull-down
puts(" ");
gpio_clear(GPIO_PORT(SIGNAL_PU_PIN), GPIO_PIN(SIGNAL_PU_PIN)); // pull-up signal
voltages = measure_voltages(); // measure pulled up voltages
print_voltage(voltages[2], 2);
gpio_set(GPIO_PORT(SIGNAL_PU_PIN), GPIO_PIN(SIGNAL_PU_PIN)); // remove pull-up
putc('\n');
}
mux_select(-1); // disable multiplexer
}
/** display available commands
* @param[in] argument no argument required
*/
@ -498,6 +535,14 @@ static const struct menu_command_t menu_commands[] = {
.argument_description = NULL,
.command_handler = &command_voltages,
},
{
.shortcut = 't',
.name = "type",
.command_description = "identify signal types",
.argument = MENU_ARGUMENT_NONE,
.argument_description = NULL,
.command_handler = &command_types,
},
};
static void command_help(void* argument)