2 * Copyright (C) 2012-2013, 2016 Czech Technical University in Prague
4 * Created on: 28.2.2013
9 * This document contains proprietary information belonging to Czech
10 * Technical University in Prague. Passing on and copying of this
11 * document, and communication of its contents is not permitted
12 * without prior written authorization.
17 * This file contains commands for testing LOUT (8x100mA Digital output).
28 #include "cmdproc_utils.h"
31 * @brief Set digital value to LOUT pin
33 * @param[in] cmd_io Pointer to IO stack
34 * @param[in] des Pointer to command descriptor
35 * @param[in] param Parameters of command
36 * @return 0 when OK or error code lower than 0
38 int cmd_do_lout_set(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
46 if (sscanf(p, "%d %d %1s", &pin, &val, spareParams) != 2)
47 return -CMDERR_BADPAR;
48 ret = rpp_lout_set(pin, val);
50 rpp_sci_printf("Pin out of range.");
51 return -CMDERR_BADPAR;
54 if (rpp_lout_update() == FAILURE) {
55 rpp_sci_printf("LOUT update failed.");
59 return cmd_opchar_replong(cmd_io, param, val, 0, 10);
63 * @brief Read digital diagnostic value from LOUT DIAG pin
65 * @param[in] cmd_io Pointer to IO stack
66 * @param[in] des Pointer to command descriptor
67 * @param[in] param Parameters of command
68 * @return 0 when OK or error code lower than 0
70 int cmd_do_lout_diag(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
77 if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
78 return -CMDERR_BADPAR;
80 if (rpp_lout_update() == FAILURE) {
81 rpp_sci_printf("LOUT update failed.");
85 ret = rpp_lout_diag(pin);
87 rpp_sci_printf("Pin out of range.");
88 return -CMDERR_BADPAR;
91 rpp_sci_printf("loutdiag%d=%d\n", pin, ret, ret);
97 /** Command descriptor for lout set port value */
98 cmd_des_t const cmd_des_lout_set = {
100 "loutset*","Set a value of the LOUT pin",
101 "### Command syntax ###\n"
103 " loutset<PIN> <VALUE>\n"
106 "- `<PIN>` is a number in range 1-8\n"
107 "- `<VALUE>` is a binary value to be set (0 or 1)\n"
109 "### Description ###\n"
111 "The command sets the digital value on the LOUT pin.\n"
121 "Sets LOUT2 to 0.\n",
122 CMD_HANDLER(cmd_do_lout_set), (void *)&cmd_list_lout
125 /** Command descriptor for lout get pin diag value */
126 cmd_des_t const cmd_des_lout_diag = {
128 "loutdiag*","Read a diagnostic value from an LOUT pin",
129 "### Command syntax ###\n"
133 "where `<PIN>` is a number in range 1-8\n"
135 "### Description ###\n"
137 "The command reads a logical value of the LOUT diagnostic signal.\n"
143 "Reads value of the LOUT1 diagnostic signal.\n",
144 CMD_HANDLER(cmd_do_lout_diag), (void *)&cmd_list_lout
148 /** List of commands for hout, defined as external */
149 cmd_des_t const *cmd_list_lout[] = {