/*
- * Copyright (C) 2012-2013 Czech Technical University in Prague
+ * Copyright (C) 2012-2013, 2015, 2016 Czech Technical University in Prague
*
* Created on: 28.2.2013
*
* Authors:
* - Michal Horn
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
*
* File : cmd_hout.c
*
#ifndef DOCGEN
#include "rpp/rpp.h"
-#include "hal/hal.h"
-#include "drv/drv.h"
+/* FIXME: remove hout.h */
+#include "drv/hout.h"
+#include "drv/port.h" /* TODO: Use rpp/port.h */
#include "cmdproc_utils.h"
*/
int cmd_do_read_hout_ifbk_values(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
{
- uint32_t i; // Cycle control variable
- port_desc_t *desc;
- uint32_t values[PORT_HOUTIFBK_CHANNEL_NUM*2];
+ uint32_t i;
+ const struct port_desc *port = &port_desc[PORT_ID_HOUTIFBK];
+ uint16_t values[6];
int ret;
- desc = hal_port_get_dsc(PORT_NAME_HOUTIFBK, -1);
+ assert(ARRAY_SIZE(values) == port->numchn);
- ret = desc->port_getfnc_ptr(desc->config, PORT_HOUTIFBK_CHANNEL_NUM, values);
+ ret = port->get(port, values, sizeof(values));
if (ret < 0)
return ret;
- for (i = 0; i < PORT_HOUTIFBK_CHANNEL_NUM; i++) {
+ for (i = 0; i < port->numchn; i++) {
rpp_sci_printf("HOUT%d: %d\n", i+1, values[i]);
}
return 0;
{
int pin;
char *p = param[1];
- char spareParams;
+ char spareParams[2];
- if (sscanf(p, "%d %1s", &pin, &spareParams) != 1)
+ if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
return -CMDERR_BADPAR;
pin--;
if (pin < 0 || pin > 5) return -CMDERR_BADPAR;
{
char *p;
uint32_t values[MAX_PARAM_VALUES_NUM];
- char spareParams;
+ char spareParams[2];
int pin;
p = param[1];
if (param[2] != NULL) { // More parameters = set values
p = param[2];
- if (sscanf(p, "%d %d %1s", &values[0], &values[1], &spareParams) != 2)
+ if (sscanf(p, "%d %d %1s", &values[0], &values[1], spareParams) != 2)
return -CMDERR_BADPAR;
if (values[1] > 100) return -CMDERR_BADPAR;
hout_pwm_set_signal(pin, (double)values[0], values[1]);
double period = hout_pwm_get_period(pin);
uint32_t duty = hout_pwm_get_duty(pin);
- rpp_sci_printf("houtpwm%d_period=%g\r\nhoutpwm%d_duty=%u%%", pin+1, period, pin+1, duty);
+ rpp_sci_printf("houtpwm%d_period=%g\r\nhoutpwm%d_duty=%u%%\n", pin+1, period, pin+1, duty);
return 0;
}
}
{
int pin;
char *p = param[1];
- char spareParams;
+ char spareParams[2];
- if (sscanf(p, "%d %1s", &pin, &spareParams) != 1)
+ if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
return -CMDERR_BADPAR;
pin--;
if (pin < 0 || pin > 5) return -CMDERR_BADPAR;
{
int pin;
char *p = param[1];
- char spareParams;
+ char spareParams[2];
- if (sscanf(p, "%d %1s", &pin, &spareParams) != 1)
+ if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
return -CMDERR_BADPAR;
pin--;
if (pin < 0 || pin > 5) return -CMDERR_BADPAR;
"\n"
" --> houtpwm1\n"
" houtpwm1_period=1000\n"
- " houtpwm1_duty=25\n"
+ " houtpwm1_duty=25%\n"
"\n"
"Prints the actual period of HOUT1 PWM in microseconds and the duty\n"
"cycle in percents.\n",