application: allow setting probe range
This commit is contained in:
parent
89f8c80093
commit
1facc923c3
|
@ -69,6 +69,8 @@ const uint8_t channels[] = {ADC_CHANNEL17, ADC_CHANNEL(TARGET_CHANNEL), ADC_CHAN
|
|||
static const char* channel_names[] = {"B12", "B13", "B14", "B15", "A8 ", "A9 ", "A10", "A15", "B3 ", "B4 ", "B5 ", "B6 "}; /**< names of pin connected to target signals */
|
||||
static const uint32_t channel_ports[] = {GPIO_PORT(PB12), GPIO_PORT(PB13), GPIO_PORT(PB14), GPIO_PORT(PB15), GPIO_PORT(PA8), GPIO_PORT(PA9), GPIO_PORT(PA10), GPIO_PORT(PA15), GPIO_PORT(PB3), GPIO_PORT(PB4), GPIO_PORT(PB5), GPIO_PORT(PB6)}; /**< GPIO ports for signal pin */
|
||||
static const uint32_t channel_pins[] = {GPIO_PIN(PB12), GPIO_PIN(PB13), GPIO_PIN(PB14), GPIO_PIN(PB15), GPIO_PIN(PA8), GPIO_PIN(PA9), GPIO_PIN(PA10), GPIO_PIN(PA15), GPIO_PIN(PB3), GPIO_PIN(PB4), GPIO_PIN(PB5), GPIO_PIN(PB6)}; /**< GPIO pins for signal pin */
|
||||
static uint8_t channel_start = 0; /**< first signal of range to probe */
|
||||
static uint8_t channel_stop = CHANNEL_NUMBERS - 1; /**< last signal of range to probe */
|
||||
|
||||
size_t putc(char c)
|
||||
{
|
||||
|
@ -255,7 +257,7 @@ static void command_voltages(void* argument)
|
|||
float* voltages;
|
||||
print_target(); // print target voltage (also sets measurement conditions)
|
||||
puts("signal voltages:\n");
|
||||
for (uint8_t i = 0; i < CHANNEL_NUMBERS; i++) {
|
||||
for (uint8_t i = channel_start; i < channel_stop; i++) {
|
||||
puts("- ");
|
||||
puts(channel_names[i]);
|
||||
mux_select(i); // select the channel
|
||||
|
@ -282,7 +284,7 @@ static void command_types(void* argument)
|
|||
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 < CHANNEL_NUMBERS; i++) {
|
||||
for (uint8_t i = channel_start; i < channel_stop; i++) {
|
||||
puts(channel_names[i]);
|
||||
puts(" ");
|
||||
mux_select(i); // select the channel
|
||||
|
@ -345,6 +347,34 @@ static void command_types(void* argument)
|
|||
mux_select(-1); // disable multiplexer
|
||||
}
|
||||
|
||||
/** set first channel of range to scan
|
||||
* @param[in] argument optional pointer to first channel number
|
||||
*/
|
||||
static void command_channel_start(void* argument)
|
||||
{
|
||||
if (argument) {
|
||||
const uint32_t channel = *(uint32_t*)argument;
|
||||
if (channel < CHANNEL_NUMBERS && channel < channel_start) {
|
||||
channel_start = channel;
|
||||
}
|
||||
}
|
||||
printf("channels to probe: %u-%u\n", channel_start, channel_stop);
|
||||
}
|
||||
|
||||
/** set last channel of range to scan
|
||||
* @param[in] argument optional pointer to last channel number
|
||||
*/
|
||||
static void command_channel_stop(void* argument)
|
||||
{
|
||||
if (argument) {
|
||||
const uint32_t channel = *(uint32_t*)argument;
|
||||
if (channel < CHANNEL_NUMBERS && channel > channel_start) {
|
||||
channel_stop = channel;
|
||||
}
|
||||
}
|
||||
printf("channels to probe: %u-%u\n", channel_start, channel_stop);
|
||||
}
|
||||
|
||||
/** display available commands
|
||||
* @param[in] argument no argument required
|
||||
*/
|
||||
|
@ -620,6 +650,22 @@ static const struct menu_command_t menu_commands[] = {
|
|||
.argument_description = NULL,
|
||||
.command_handler = &command_types,
|
||||
},
|
||||
{
|
||||
.shortcut = 'c',
|
||||
.name = "start",
|
||||
.command_description = "first channel of range to probe",
|
||||
.argument = MENU_ARGUMENT_UNSIGNED,
|
||||
.argument_description = "[ch]",
|
||||
.command_handler = &command_channel_start,
|
||||
},
|
||||
{
|
||||
.shortcut = 'C',
|
||||
.name = "stop",
|
||||
.command_description = "last channel of range to probe",
|
||||
.argument = MENU_ARGUMENT_UNSIGNED,
|
||||
.argument_description = "[ch]",
|
||||
.command_handler = &command_channel_stop,
|
||||
},
|
||||
};
|
||||
|
||||
static void command_help(void* argument)
|
||||
|
|
Loading…
Reference in New Issue