]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blobdiff - rpp-test-sw/commands/cmd_fray.c
Update to the reworked gio and port in the rpp-lib
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / cmd_fray.c
index be24a4c9f9413cafb4285259ebbeb30724c42c51..27a455e7f2cf5027633e70530ff0967eab79c7fd 100644 (file)
@@ -1,23 +1,15 @@
 /*
- * Copyright (C) 2012-2013 Czech Technical University in Prague
+ * Copyright (C) 2012-2013, 2015 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_fray.c
  *
 
 #ifndef DOCGEN
 
+#include "drv/port_def.h"
 #include "rpp/rpp.h"
-#include "drv/fray.h"
 #include "cmdproc_utils.h"
-#include "hal/hal.h"
 #include "cmdproc.h"
-#include "sys/ti_drv_fray.h"
+#include "spi_resp_transl.h"
 
 /**
  * This structure contains global FlexRay configuration.
@@ -315,9 +306,6 @@ int cmd_do_fray_status(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
 {
        char *p;
        int pin;
-       uint32_t numCmdDesc;
-       int i;
-       uint32_t numFieldDesc;
 
        p = param[1];
        if (sscanf(p, "%d", &pin) != 1)
@@ -327,19 +315,14 @@ int cmd_do_fray_status(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
 
        if (Fr_spi_transfer(pin) != 0) return -CMDERR_BADDIO;
 
-       spitr_reg_translate_table_t translatedData;
-       const spitr_cmd_map_t *cmdDesc = get_spi_cmd_map(PORT_NAME_FRAY1, -1, &numCmdDesc);
-       if (cmdDesc == NULL) return -CMDERR_BADREG;
-
-       const spitr_field_desc_t *fieldDescs = get_spi_field_desc(cmdDesc, numCmdDesc, Fr_spi_get_cmd(pin), &numFieldDesc);
-       if (fieldDescs == NULL)
+       const spitr_cmd_desc_t *cmd_desc = get_spi_cmd_desc(&spitr_port_cmds[PORT_ID_FRAY1],
+                                                                                                               Fr_spi_get_cmd(pin));
+       if (cmd_desc == NULL)
                return -CMDERR_BADPAR;
        uint32_t fr_spi_response = Fr_spi_response(pin);
        uint32_t lsbResponse = 0 | ((fr_spi_response & 0xFF) << 8) | ((fr_spi_response & 0xFF00) >> 8);
-       spitr_fill_tr_table(fieldDescs, numFieldDesc, lsbResponse, &translatedData);
-       for (i = 0; i < translatedData.num_rows; i++) {
-               rpp_sci_printf("%s: %x\r\n", translatedData.row[i].field_name, translatedData.row[i].value);
-       }
+
+       spitr_print_resp(cmd_desc, lsbResponse);
        return 0;
 }