]> rtime.felk.cvut.cz Git - rpp-test-sw.git/commitdiff
adc: Support different number of channels depending on the target
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 2 Sep 2015 16:38:29 +0000 (18:38 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 3 Sep 2015 08:30:59 +0000 (10:30 +0200)
rpp-test-sw/commands/cmd_adc.c

index 5c88ff6c029f104b4df39ae73a87e5df55076d83..9cdd168203efc1aed7c227e59be1afc69156a5f8 100644 (file)
@@ -48,13 +48,13 @@ int cmd_do_read_adc1_values(cmd_io_t *cmd_io, const struct cmd_des *des, char *p
        if (param[1] == param[0] + 7) { /* Single pin variant */
                if (sscanf(param[1], "%d", &min) != 1)
                        return -CMDERR_BADPAR;
-               if (min > 15)
+               if (min >= PORT_ADC_CHANNELS)
                        return -CMDERR_NODEV;
                max = min;
        }
        else {              /* All pins */
                min = 0;
-               max = port_desc[PORT_ID_ADC].numchn - 1;
+               max = PORT_ADC_CHANNELS - 1;
        }
        for (i = min; i <= max; i++) {
                unsigned d = rpp_adc_get(i+1);
@@ -68,10 +68,13 @@ int cmd_do_adc_watch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 {
        int i;
 
-       rpp_sci_printf("ADC Inputs Test [0-15]:\r\n");
-       rpp_sci_printf("===============================================================================================\r\n");
+       rpp_sci_printf("ADC Inputs Test [0-%d]:\r\n", PORT_ADC_CHANNELS - 1);
 
-       for (i = 0; i < 16; i++)
+       for (i = 0; i < PORT_ADC_CHANNELS; i++)
+               rpp_sci_printf("======");
+       rpp_sci_printf("\n");
+
+       for (i = 0; i < PORT_ADC_CHANNELS; i++)
                rpp_sci_printf("%5d ", i);
        rpp_sci_printf("\n");
 
@@ -83,10 +86,10 @@ int cmd_do_adc_watch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
         // Update inputs
         rpp_adc_update();
 
-               for (i = 0; i < 16; i++)
+               for (i = 0; i < PORT_ADC_CHANNELS; i++)
                        rpp_sci_printf("%5d ", rpp_adc_get(i+1));
                rpp_sci_printf("lsb\n");
-               for (i = 0; i < 16; i++)
+               for (i = 0; i < PORT_ADC_CHANNELS; i++)
                        rpp_sci_printf("%5.2f ", lsb2volts(rpp_adc_get(i+1)));
                rpp_sci_printf("V\r\033[A"); /* Cursor up */