diff options
Diffstat (limited to 'lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/shellcfg.c')
-rw-r--r-- | lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/shellcfg.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/shellcfg.c b/lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/shellcfg.c new file mode 100644 index 000000000..afe6d8273 --- /dev/null +++ b/lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/shellcfg.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Jonathan Struebel | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file common/shellcfg.c | ||
19 | * @brief CLI shell config. | ||
20 | * | ||
21 | * @addtogroup SHELL | ||
22 | * @{ | ||
23 | */ | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | #include "hal.h" | ||
27 | #include "shell.h" | ||
28 | #include "chprintf.h" | ||
29 | |||
30 | char ** endptr; | ||
31 | |||
32 | /* | ||
33 | * Shell history buffer | ||
34 | */ | ||
35 | char history_buffer[SHELL_MAX_HIST_BUFF]; | ||
36 | |||
37 | /* | ||
38 | * Shell completion buffer | ||
39 | */ | ||
40 | char *completion_buffer[SHELL_MAX_COMPLETIONS]; | ||
41 | |||
42 | /* | ||
43 | * Shell commands | ||
44 | */ | ||
45 | static void cmd_argt(BaseSequentialStream *chp, int argc, char *argv[]) { | ||
46 | size_t n; | ||
47 | |||
48 | if (argc > 1) { | ||
49 | chprintf(chp, "Usage: arg_test arg\r\n"); | ||
50 | return; | ||
51 | } | ||
52 | n = strtol(argv[0], endptr, 0); | ||
53 | chprintf(chp, "Argument is: %u\r\n", n); | ||
54 | } | ||
55 | |||
56 | static const ShellCommand commands[] = { | ||
57 | {"arg_test", cmd_argt}, | ||
58 | {NULL, NULL} | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * Shell configuration | ||
63 | */ | ||
64 | const ShellConfig shell_cfg = { | ||
65 | (BaseSequentialStream *)&SD1, | ||
66 | commands, | ||
67 | history_buffer, | ||
68 | sizeof(history_buffer), | ||
69 | completion_buffer | ||
70 | }; | ||
71 | |||
72 | /** @} */ | ||