2 * Copyright (C) 2012-2013 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"
32 * @brief Set digital value to LOUT pin
34 * @param[in] cmd_io Pointer to IO stack
35 * @param[in] des Pointer to command descriptor
36 * @param[in] param Parameters of command
37 * @return 0 when OK or error code lower than 0
39 int cmd_do_lout_set(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
47 if (sscanf(p, "%d %d %1s", &pin, &val, &spareParams) != 2)
48 return -CMDERR_BADPAR;
49 ret = rpp_lout_set(pin, val);
51 rpp_sci_printf("Pin out of range.");
52 return -CMDERR_BADPAR;
55 if (rpp_lout_update() == FAILURE) {
56 rpp_sci_printf("LOUT update failed.");
60 return cmd_opchar_replong(cmd_io, param, val, 0, 10);
64 * @brief Read digital diagnostic value from LOUT DIAG pin
66 * @param[in] cmd_io Pointer to IO stack
67 * @param[in] des Pointer to command descriptor
68 * @param[in] param Parameters of command
69 * @return 0 when OK or error code lower than 0
71 int cmd_do_lout_diag(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
78 if (sscanf(p, "%d %1s", &pin, &spareParams) != 1)
79 return -CMDERR_BADPAR;
81 if (rpp_lout_update() == FAILURE) {
82 rpp_sci_printf("LOUT update failed.");
86 ret = rpp_lout_diag(pin);
88 rpp_sci_printf("Pin out of range.");
89 return -CMDERR_BADPAR;
92 rpp_sci_printf("loutdiag%d=%d\n", pin, ret, ret);
98 /** Command descriptor for lout set port value */
99 cmd_des_t const cmd_des_lout_set = {
101 "loutset*","Set a value of the LOUT pin",
102 "### Command syntax ###\n"
104 " loutset<PIN> <VALUE>\n"
107 "- `<PIN>` is a number in range 1-8\n"
108 "- `<VALUE>` is a binary value to be set (0 or 1)\n"
110 "### Description ###\n"
112 "The command sets the digital value on the LOUT pin.\n"
122 "Sets LOUT2 to 0.\n",
123 CMD_HANDLER(cmd_do_lout_set), (void *)&cmd_list_lout
126 /** Command descriptor for lout get pin diag value */
127 cmd_des_t const cmd_des_lout_diag = {
129 "loutdiag*","Read a diagnostic value from an LOUT pin",
130 "### Command syntax ###\n"
134 "where `<PIN>` is a number in range 1-8\n"
136 "### Description ###\n"
138 "The command reads a logical value of the LOUT diagnostic signal.\n"
144 "Reads value of the LOUT1 diagnostic signal.\n",
145 CMD_HANDLER(cmd_do_lout_diag), (void *)&cmd_list_lout
149 /** List of commands for hout, defined as external */
150 cmd_des_t const *cmd_list_lout[] = {