application: improve target show display, and show signal voltages

This commit is contained in:
King Kévin 2021-03-11 11:20:09 +01:00
parent 1bcbf3fd5f
commit 66f26f3093
1 changed files with 27 additions and 9 deletions

View File

@ -131,6 +131,24 @@ static float* measure_voltages(void)
return voltages;
}
/** measure and print target voltage */
static void print_voltage_target(void)
{
gpio_set(GPIO_PORT(SIGNAL_PU_PIN), GPIO_PIN(SIGNAL_PU_PIN)); // ensure we are not pulling up the signal
gpio_set(GPIO_PORT(SIGNAL_PD_PIN), GPIO_PIN(SIGNAL_PD_PIN)); // ensure we are not pulling down the signal
gpio_set(GPIO_PORT(TARGET_EN), GPIO_PIN(TARGET_EN)); // ensure the level shifters pulling up the signals are not enabled
float* voltages = measure_voltages(); // measure voltages
puts("target voltage: ");
print_voltage(voltages[1], 2);
puts(" V");
if (voltages[1] > 3.25) {
puts(" (warning: signal voltage may exceed 3.30 V limit)");
} else if (voltages[1] < 1.0) {
puts(" (warning: target voltage seems not connected)");
}
putc('\n');
}
/** select channel of multiplexer
* @param[in] channel channel to select, or -1 to disable multiplexer
*/
@ -199,15 +217,15 @@ static void command_swd_scan(void* argument)
static void command_voltages(void* argument)
{
(void)argument; // we won't use the argument
float* voltages = measure_voltages(); // measure voltages
puts("voltages:\n");
puts("- target: ");
print_voltage(voltages[1], 2);
puts(" V\n");
if (voltages[2] >= 3.25) {
puts("- signal: >= 3.30 V\n");
} else {
puts("- signal: ");
float* voltages;
print_voltage_target(); // print target voltage (also sets measurement conditions)
puts("signal voltages:\n");
for (uint8_t i = 0; i < SIGNAL_NUMBERS; i++) {
puts("- ");
puts(signal_names[i]);
mux_select(i); // select the channel
voltages = measure_voltages(); // measure raw voltages
puts(" ");
print_voltage(voltages[2], 2);
puts(" V\n");
}