]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - sw/app/rocon/appl_cmdproc.c
826e8e010d1b210cf18a7f97c97187d7e02523b6
[fpga/lx-cpu1/lx-rocon.git] / sw / app / rocon / appl_cmdproc.c
1 #include <system_def.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <cmd_proc.h>
5
6 #include "appl_defs.h"
7
8 extern cmd_des_t const *cmd_pxmc_base[];
9 extern cmd_des_t const *cmd_appl_tests[];
10 extern cmd_des_t const *cmd_pxmc_ptable[];
11 extern cmd_des_t const *cmd_pxmc_coordmv[];
12
13 extern cmd_des_t const cmd_des_dprint;
14
15 cmd_des_t const **cmd_list;
16
17 cmd_des_t const cmd_des_help =
18 {
19   0, 0,
20   "help", "prints help for commands",
21   cmd_do_help,
22   {
23     (char *) &cmd_list
24   }
25 };
26
27
28 cmd_des_t const *cmd_list_main[] =
29 {
30   &cmd_des_help,
31   CMD_DES_INCLUDE_SUBLIST(cmd_appl_tests),
32 #ifdef CONFIG_PXMC
33   CMD_DES_INCLUDE_SUBLIST(cmd_pxmc_base),
34   CMD_DES_INCLUDE_SUBLIST(cmd_pxmc_ptable),
35 #endif
36   CMD_DES_INCLUDE_SUBLIST(cmd_pxmc_coordmv),
37   &cmd_des_dprint,
38   NULL
39 };
40
41 cmd_des_t const **cmd_list = cmd_list_main;
42
43 extern cmd_io_t cmd_io_usbcon;
44 extern cmd_io_t cmd_io_uartcon;
45
46 int dbg_prt_last_msec;
47
48 int cmdproc_poll(void)
49 {
50   int ret = 0;
51
52   ret |= cmd_processor_run(&cmd_io_uartcon, cmd_list_main);
53   ret |= cmd_processor_run(&cmd_io_usbcon, cmd_list_main);
54
55   lt_mstime_update();
56
57   if(!ret && (labs((int)(actual_msec - dbg_prt_last_msec)) > 2000) &&
58     !cmd_io_uartcon.priv.ed_line.in->lastch) {
59      cmd_io_t *cmd_io = &cmd_io_uartcon;
60      dbg_prt_last_msec = actual_msec;
61
62      if (cmd_io->priv.ed_line.io_stack)
63        cmd_io = cmd_io->priv.ed_line.io_stack;
64      run_dbg_prt(cmd_io);
65   }
66
67   return ret;
68 }