annotate Debug/cli/cli.h @ 341:66eccdd9ced5

Code cleanup - Changing header file ifndef define to pragma once's - Removed duplicate output_com.h's
author Jacob Alexander <haata@kiibohd.com>
date Sun, 14 Jun 2015 13:56:56 -0700
parents f4d4cad283c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
307
ecd2ae35d25c Initial commit for UARTConnect module
Jacob Alexander <haata@kiibohd.com>
parents: 239
diff changeset
1 /* Copyright (C) 2014-2015 by Jacob Alexander
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
2 *
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
4 * of this software and associated documentation files (the "Software"), to deal
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
5 * in the Software without restriction, including without limitation the rights
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
7 * copies of the Software, and to permit persons to whom the Software is
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
8 * furnished to do so, subject to the following conditions:
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
9 *
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
10 * The above copyright notice and this permission notice shall be included in
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
11 * all copies or substantial portions of the Software.
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
12 *
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
19 * THE SOFTWARE.
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
20 */
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
21
341
66eccdd9ced5 Code cleanup
Jacob Alexander <haata@kiibohd.com>
parents: 330
diff changeset
22 #pragma once
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
23
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
24 // ----- Includes -----
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
25
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
26 // Compiler Includes
109
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
27 #include <Lib/MainLib.h>
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
28
109
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
29 // Project Includes
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
30 #include <output_com.h>
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
31
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
32
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
33 // ----- Defines -----
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
34
106
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
35 #define CLILineBufferMaxSize 100
307
ecd2ae35d25c Initial commit for UARTConnect module
Jacob Alexander <haata@kiibohd.com>
parents: 239
diff changeset
36 #define CLIMaxDictionaries 10
111
59391aa888aa Initial Force Gauge CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 110
diff changeset
37 #define CLIEntryTabAlign 13
318
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
38 #define CLIMaxHistorySize 10
106
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
39
239
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
40
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
41 // ----- Macros -----
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
42
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
43 // AVR CLI Dictionary definitions (has to deal with the annoying PROGMEM
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
44 // Only using PROGMEM with descriptions (all the string comparison tools need to be re-written otherwise)
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
45 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
46 #define CLIDict_Def(name,description) \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
47 const PROGMEM char name##Name[] = description; \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
48 const CLIDictItem name[]
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
49
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
50 #define CLIDict_Item(name) \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
51 { #name, name##CLIDict_DescEntry, (const void (*)(char*))cliFunc_##name }
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
52
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
53 #define CLIDict_Entry(name,description) \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
54 const PROGMEM char name##CLIDict_DescEntry[] = description;
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
55
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
56 // ARM is easy :P
330
f4d4cad283c6 Some initial bringup of the dfu bootloader on the mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents: 321
diff changeset
57 #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) // ARM
239
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
58 #define CLIDict_Def(name,description) \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
59 const char name##Name[] = description; \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
60 const CLIDictItem name[]
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
61
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
62 #define CLIDict_Item(name) \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
63 { #name, name##CLIDict_DescEntry, (const void (*)(char*))cliFunc_##name }
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
64
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
65 #define CLIDict_Entry(name,description) \
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
66 const char name##CLIDict_DescEntry[] = description;
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
67 #endif
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
68
321
18c3c4924f20 Code cleanup from cli changes.
Jacob Alexander <haata@kiibohd.com>
parents: 319
diff changeset
69 #define RING_PREV(i) CLI_wrap(i - 1, 0, CLIMaxHistorySize - 1)
18c3c4924f20 Code cleanup from cli changes.
Jacob Alexander <haata@kiibohd.com>
parents: 319
diff changeset
70 #define RING_NEXT(i) CLI_wrap(i + 1, 0, CLIMaxHistorySize - 1)
239
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
71
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
72
106
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
73 // ----- Structs -----
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
74
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
75 // Each item has a name, description, and function pointer with an argument for arguments
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
76 typedef struct CLIDictItem {
239
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
77 const char* name;
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
78 const char* description;
2a4c99da1276 HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
79 const void (*function)(char*);
106
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
80 } CLIDictItem;
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
81
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
82
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
83
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
84 // ----- Variables -----
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
85
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
86 char CLILineBuffer[CLILineBufferMaxSize+1]; // +1 for an additional NULL
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
87 uint8_t CLILineBufferCurrent;
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
88
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
89 // Main command dictionary
112
0cb43cb8f683 Adding dictionary titles.
Jacob Alexander <haata@kiibohd.com>
parents: 111
diff changeset
90 CLIDictItem *CLIDict [CLIMaxDictionaries];
0cb43cb8f683 Adding dictionary titles.
Jacob Alexander <haata@kiibohd.com>
parents: 111
diff changeset
91 char* CLIDictNames[CLIMaxDictionaries];
0cb43cb8f683 Adding dictionary titles.
Jacob Alexander <haata@kiibohd.com>
parents: 111
diff changeset
92 uint8_t CLIDictionariesUsed;
106
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
93
318
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
94 // History
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
95 char CLIHistoryBuffer[CLIMaxHistorySize][CLILineBufferMaxSize];
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
96 uint8_t CLIHistoryHead;
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
97 uint8_t CLIHistoryTail;
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
98 int8_t CLIHistoryCurrent;
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
99
217e7bd8a0a4 Add CLI History
Rowan Decker <Smasher816@gmail.com>
parents: 316
diff changeset
100 // Debug
109
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
101 uint8_t CLILEDState;
110
98d940b60d12 Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 109
diff changeset
102 uint8_t CLIHexDebugMode;
106
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
103
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
105
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
106 // ----- Functions and Corresponding Function Aliases -----
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
107
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents: 114
diff changeset
108 void CLI_init();
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents: 114
diff changeset
109 void CLI_process();
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
110 void CLI_registerDictionary( const CLIDictItem *cmdDict, const char* dictName );
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents: 114
diff changeset
111 void CLI_argumentIsolation( char* string, char** first, char** second );
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
112
319
3994a5a68793 Cleanup CLI history
Rowan Decker <Smasher816@gmail.com>
parents: 318
diff changeset
113 int CLI_wrap( int x, int low, int high );
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents: 114
diff changeset
114 void CLI_commandLookup();
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents: 114
diff changeset
115 void CLI_tabCompletion();
319
3994a5a68793 Cleanup CLI history
Rowan Decker <Smasher816@gmail.com>
parents: 318
diff changeset
116 void CLI_saveHistory( char *buff );
3994a5a68793 Cleanup CLI history
Rowan Decker <Smasher816@gmail.com>
parents: 318
diff changeset
117 void CLI_retreiveHistory( int index );
106
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
118
15961894eaeb Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents: 105
diff changeset
119 // CLI Command Functions
109
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
120 void cliFunc_arch ( char* args );
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
121 void cliFunc_chip ( char* args );
316
a0ad3a172269 Add Clear CLI function
Rowan Decker <Smasher816@gmail.com>
parents: 307
diff changeset
122 void cliFunc_clear ( char* args );
109
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
123 void cliFunc_cliDebug( char* args );
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
124 void cliFunc_device ( char* args );
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
125 void cliFunc_help ( char* args );
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
126 void cliFunc_led ( char* args );
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
127 void cliFunc_reload ( char* args );
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
128 void cliFunc_reset ( char* args );
110
98d940b60d12 Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 109
diff changeset
129 void cliFunc_restart ( char* args );
109
2c1a9e6ae70e Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents: 108
diff changeset
130 void cliFunc_version ( char* args );
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
131