2 * Copyright (C) 2012-2013, 2016 Czech Technical University in Prague
4 * Created on: 28.2.2013
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
33 * This file contains commands for testing LOUT (8x100mA Digital output).
44 #include "cmdproc_utils.h"
47 * @brief Set digital value to LOUT pin
49 * @param[in] cmd_io Pointer to IO stack
50 * @param[in] des Pointer to command descriptor
51 * @param[in] param Parameters of command
52 * @return 0 when OK or error code lower than 0
54 int cmd_do_lout_set(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
62 if (sscanf(p, "%d %d %1s", &pin, &val, spareParams) != 2)
63 return -CMDERR_BADPAR;
64 ret = rpp_lout_set(pin, val);
66 rpp_sci_printf("Pin out of range.\n");
67 return -CMDERR_BADPAR;
70 if (rpp_lout_update() == FAILURE) {
71 rpp_sci_printf("LOUT update failed.\n");
75 return cmd_opchar_replong(cmd_io, param, val, 0, 10);
79 * @brief Read digital diagnostic value from LOUT DIAG pin
81 * @param[in] cmd_io Pointer to IO stack
82 * @param[in] des Pointer to command descriptor
83 * @param[in] param Parameters of command
84 * @return 0 when OK or error code lower than 0
86 int cmd_do_lout_diag(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
93 if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
94 return -CMDERR_BADPAR;
96 if (rpp_lout_update() == FAILURE) {
97 rpp_sci_printf("LOUT update failed.\n");
101 ret = rpp_lout_diag(pin);
103 rpp_sci_printf("Pin out of range.\n");
104 return -CMDERR_BADPAR;
107 rpp_sci_printf("loutdiag%d=%d\n", pin, ret, ret);
113 /** Command descriptor for lout set port value */
114 cmd_des_t const cmd_des_lout_set = {
116 "loutset*","Set a value of the LOUT pin",
117 "### Command syntax ###\n"
119 " loutset<PIN> <VALUE>\n"
122 "- `<PIN>` is a number in range 1-8\n"
123 "- `<VALUE>` is a binary value to be set (0 or 1)\n"
125 "### Description ###\n"
127 "The command sets the digital value on the LOUT pin.\n"
139 "Sets LOUT2 to 0.\n",
140 CMD_HANDLER(cmd_do_lout_set), (void *)&cmd_list_lout
143 /** Command descriptor for lout get pin diag value */
144 cmd_des_t const cmd_des_lout_diag = {
146 "loutdiag*","Read a diagnostic value from an LOUT pin",
147 "### Command syntax ###\n"
151 "where `<PIN>` is a number in range 1-8\n"
153 "### Description ###\n"
155 "The command reads a logical value of the LOUT diagnostic signal.\n"
161 "Reads value of the LOUT1 diagnostic signal.\n",
162 CMD_HANDLER(cmd_do_lout_diag), (void *)&cmd_list_lout
166 /** List of commands for hout, defined as external */
167 cmd_des_t const *cmd_list_lout[] = {