]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/cmdproc/src/commands/cmd_adc.c
Exclude docgen.c from CCS build
[pes-rpp/rpp-test-sw.git] / rpp / lib / cmdproc / src / commands / cmd_adc.c
1 /*
2  * Copyright (C) 2012-2013 Czech Technical University in Prague
3  *
4  * Created on: 28.2.2013
5  *
6  * Authors:
7  *     - Michal Horn
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * File : cmd_adc.c
23  *
24  * Abstract:
25  *      This file contains command for reading adc port.
26  *
27  */
28
29 #include "commands/cmd_adc.h"
30
31 #ifndef DOCGEN
32
33 #include "hal/hal.h"
34 #include "rpp/rpp.h"
35
36
37 /**
38  * @brief Read ADC port
39  *
40  * Command syntax: readadc
41  *
42  * @param[in]   cmd_io  Pointer to IO stack
43  * @param[in]   des             Pointer to command descriptor
44  * @param[in]   param   Parameters of command
45  * @return 0 when OK or error code lower than 0
46  */
47 int cmd_do_read_adc1_values(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
48 {
49     uint32_t i;                                         // Cycle control variable
50
51     rpp_ain_update();
52     rpp_sci_printf("ADC1: values: ");
53     /* conversion results :                                       */
54     for (i = 0; i < PORT_ADC_CHANNEL_NUM; i++) {
55         rpp_sci_printf((uint8_t *)"\r\nChannel: %d\tvalue: %d\t%h", i+1, rpp_ain_get(i+1), rpp_ain_get(i+1));
56     }
57     return 0;
58 }
59
60 #endif  /* DOCGEN */
61
62 /** Descriptor of command for adc port reading */
63 cmd_des_t const cmd_des_read_adc1={
64     0, 0,
65     "readadc","Reads values from ADC1",
66     "=== Description ===\n"
67     "\n"
68     "This command reads values on all ADIN 1-12 channels and prints it as\n"
69     "channel-value (hexadecimal) table.\n"
70     "\n"
71     "=== Command syntax ===\n"
72     "\n"
73     "   --> readadc\n",
74     CMD_HANDLER(cmd_do_read_adc1_values), (void *)&cmd_list_adc
75 };
76
77 /** List of commands for adc, defined as external */
78 cmd_des_t const *cmd_list_adc[]={
79   &cmd_des_read_adc1,
80   NULL
81 };