Subversion Repositories ChibiGauge

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/*
2
 * shellCmds.c
3
 *
4
 *  Created on: 1 Oct 2019
5
 *      Author: Mike
6
 */
7
 
8
 
9
#include <stdio.h>
10
#include <string.h>
11
 
12
#include "ch.h"
13
#include "hal.h"
14
//#include "test.h"
15
#include "shell.h"
16
#include "evtimer.h"
17
#include "chprintf.h"
18
 
3 mjames 19
#include "useLidar.h"
20
 
2 mjames 21
#include "shellCmds.h"
22
 
23
 
24
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
25
        size_t n, size , largest;
26
 
27
        (void) argv;
28
        if (argc > 0) {
29
                chprintf(chp, "Usage: mem\r\n");
30
                return;
31
        }
32
        n = chHeapStatus(NULL, &size, &largest);
33
        chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
34
        chprintf(chp, "heap fragments   : %u \r\n",n);
35
        chprintf(chp, "largest fragment : %u \r\n",largest);
36
        chprintf(chp, "heap free total  : %u bytes\r\n", size);
37
}
38
 
39
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
40
          static const char *states[] = {CH_STATE_NAMES};
41
          thread_t *tp;
42
 
43
          (void)argv;
44
          if (argc > 0) {
45
            shellUsage(chp, "threads");
46
            return;
47
          }
48
          chprintf(chp, "stklimit    stack     addr refs prio     state         name\r\n" SHELL_NEWLINE_STR);
49
          tp = chRegFirstThread();
50
          do {
51
        #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
52
            uint32_t stklimit = (uint32_t)tp->wabase;
53
        #else
54
            uint32_t stklimit = 0U;
55
        #endif
56
            chprintf(chp, "%08lx %08lx %08lx %4lu %4lu %9s %12s" SHELL_NEWLINE_STR,
57
                     stklimit, (uint32_t)tp->ctx.sp, (uint32_t)tp,
58
                     (uint32_t)tp->refs - 1, (uint32_t)tp->prio, states[tp->state],
59
                     tp->name == NULL ? "" : tp->name);
60
            tp = chRegNextThread(tp);
61
          } while (tp != NULL);
62
        }
63
 
64
 
65
static void cmd_pll (BaseChannel *chp, int argc, char *argv[])
66
{
67
 
68
        chprintf(chp,"pll ");
69
 
70
        if(argc >= 2)
71
        {
72
                if(strncmp(argv[0],"gain",4)==0)
73
                {
74
            int v = atoi(argv[0]);
75
            v=v==0?1:v;
76
        //    setGain(v);
77
            chprintf(chp,"setGain(%d)\r\n",v);
78
                }
79
 
80
 
81
        }
82
        else
83
        {
84
                chprintf(chp,"no args\r\n");
85
        }
86
 
87
 
88
}
89
 
90
 
91
 
92
 
93
 
94
 
95
const ShellCommand shellCommands[] = { { "mem", cmd_mem }, { "threads",
3 mjames 96
                cmd_threads }, { "pll", cmd_pll }, { "lidar", shellLidar },  { NULL, NULL } };
2 mjames 97
 
98