2 * Copyright (C) 2012-2013 Czech Technical University in Prague
4 * Created on: 28.2.2013
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.
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.
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/>.
25 * This file contains commands for testing LOUT (8x100mA Digital output).
36 #include "cmdproc_utils.h"
40 * @brief Set digital value to LOUT pin
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
47 int cmd_do_lout_set(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
54 if (sscanf(p, "%d %d %1s", &pin, &val, &spareParams) != 2) {
55 return -CMDERR_BADPAR;
57 ret = rpp_lout_set(pin, val);
59 rpp_sci_printf("Pin out of range.");
60 return -CMDERR_BADPAR;
63 if (rpp_lout_update() == FAILURE) {
64 rpp_sci_printf("LOUT update failed.");
68 return cmd_opchar_replong(cmd_io, param, val, 0, 10);
72 * @brief Read digital diagnostic value from LOUT DIAG pin
74 * @param[in] cmd_io Pointer to IO stack
75 * @param[in] des Pointer to command descriptor
76 * @param[in] param Parameters of command
77 * @return 0 when OK or error code lower than 0
79 int cmd_do_lout_diag(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
85 if (sscanf(p, "%d %1s", &pin, &spareParams) != 1) {
86 return -CMDERR_BADPAR;
89 if (rpp_lout_update() == FAILURE) {
90 rpp_sci_printf("LOUT update failed.");
94 ret = rpp_lout_diag(pin);
96 rpp_sci_printf("Pin out of range.");
97 return -CMDERR_BADPAR;
100 rpp_sci_printf("loutdiag%d=%d\n", pin, ret, ret);
106 /** Command descriptor for lout set port value */
107 cmd_des_t const cmd_des_lout_set={
109 "loutset*","Set a value of the LOUT pin",
110 "=== Command syntax ===\n"
112 " loutset<PIN> <VALUE>\n"
114 "* <PIN> is a number in range 1-8\n"
115 "* <VALUE> is a binary value to be set (0 or 1)\n"
117 "=== Description ===\n"
119 "The command sets the digital value on the LOUT pin.\n"
129 "Sets LOUT2 to 0.\n",
130 CMD_HANDLER(cmd_do_lout_set), (void *)&cmd_list_lout
133 /** Command descriptor for lout get pin diag value */
134 cmd_des_t const cmd_des_lout_diag={
136 "loutdiag*","Read a diagnostic value from an LOUT pin",
137 "=== Command syntax ===\n"
141 "where <PIN> is a number in range 1-8\n"
143 "=== Description ===\n"
145 "The command reads a logical value of the LOUT diagnostic signal.\n"
151 "Reads value of the LOUT1 diagnostic signal.\n",
152 CMD_HANDLER(cmd_do_lout_diag), (void *)&cmd_list_lout
156 /** List of commands for hout, defined as external */
157 cmd_des_t const *cmd_list_lout[]={