3 * @author Shinichiro Nakamura
4 * @brief ナチュラルタイニーシェルタスクコマンドの実装
10 #include <target_syssvc.h>
11 #include <syssvc/serial.h>
12 #include <logtrace/trace_config.h>
14 #include "kernel_cfg.h"
19 #include "task_audio.h"
21 #include "task_display.h"
24 FATFS fatfs[_VOLUMES];
29 void cmd_taskinfo(int argc, char **argv) {
32 syslog(LOG_NOTICE, "TSKID\tSTACK ADDR (HEAD:TAIL)\tSTACK USED (USED/TOTAL)");
33 syslog(LOG_NOTICE, "=========================================================");
34 for (i = 0; i < TNUM_TSKID; i++) {
35 const int tskid = 1 + i;
36 inf_tsk(tskid, &itsk);
37 syslog(LOG_NOTICE, " %2d\t0x%x:0x%x\t%5d/%5d",
39 itsk.stk_head, itsk.stk_tail,
40 itsk.stk_used, itsk.stk_total);
42 syslog(LOG_NOTICE, " (%02d:%02d)",
43 itsk.tsk_pri_curr, itsk.tsk_pri_base);
46 syslog(LOG_NOTICE, "=========================================================");
49 void cmd_audio(int argc, char **argv) {
51 if (ntlibc_strcmp(argv[1], "through") == 0) {
52 TSKAPI_AUDIO_PARAM(AUDIO_PARAM_MODE, AUDIO_VALUE_MODE_THROUGH);
55 if (ntlibc_strcmp(argv[1], "vocal_cancel") == 0) {
56 TSKAPI_AUDIO_PARAM(AUDIO_PARAM_MODE, AUDIO_VALUE_MODE_VOCAL_CANCEL);
59 if (ntlibc_strcmp(argv[1], "fir") == 0) {
60 TSKAPI_AUDIO_PARAM(AUDIO_PARAM_MODE, AUDIO_VALUE_MODE_FIR);
63 if (ntlibc_strcmp(argv[1], "iir") == 0) {
64 TSKAPI_AUDIO_PARAM(AUDIO_PARAM_MODE, AUDIO_VALUE_MODE_IIR);
68 syslog(LOG_NOTICE, "audio [through | vocal_cancel | fir | iir]");
71 void cmd_lcd(int argc, char **argv) {
73 if (ntlibc_strcmp(argv[1], "cls") == 0) {
74 TSKAPI_DISPLAY_CLEAR(0x00, 0x00, 0x00);
78 syslog(LOG_NOTICE, "lcd cls : Clear the LCD.");
81 void cmd_led(int argc, char **argv) {
83 syslog(LOG_NOTICE, "led [DBLEDn|SWLEDn] [ON|OFF]");
86 if (ntlibc_strcmp(argv[1], "DBLED0") == 0) {
87 if (ntlibc_strcmp(argv[2], "ON") == 0) {
88 TSKAPI_LED_LEDMSG(DBLED0, LEDON);
91 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
92 TSKAPI_LED_LEDMSG(DBLED0, LEDOFF);
96 if (ntlibc_strcmp(argv[1], "DBLED1") == 0) {
97 if (ntlibc_strcmp(argv[2], "ON") == 0) {
98 TSKAPI_LED_LEDMSG(DBLED1, LEDON);
101 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
102 TSKAPI_LED_LEDMSG(DBLED1, LEDOFF);
106 if (ntlibc_strcmp(argv[1], "DBLED2") == 0) {
107 if (ntlibc_strcmp(argv[2], "ON") == 0) {
108 TSKAPI_LED_LEDMSG(DBLED2, LEDON);
111 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
112 TSKAPI_LED_LEDMSG(DBLED2, LEDOFF);
116 if (ntlibc_strcmp(argv[1], "DBLED3") == 0) {
117 if (ntlibc_strcmp(argv[2], "ON") == 0) {
118 TSKAPI_LED_LEDMSG(DBLED3, LEDON);
121 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
122 TSKAPI_LED_LEDMSG(DBLED3, LEDOFF);
126 if (ntlibc_strcmp(argv[1], "SWLED0") == 0) {
127 if (ntlibc_strcmp(argv[2], "ON") == 0) {
128 TSKAPI_LED_LEDMSG(SWLED0, LEDON);
131 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
132 TSKAPI_LED_LEDMSG(SWLED0, LEDOFF);
136 if (ntlibc_strcmp(argv[1], "SWLED1") == 0) {
137 if (ntlibc_strcmp(argv[2], "ON") == 0) {
138 TSKAPI_LED_LEDMSG(SWLED1, LEDON);
141 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
142 TSKAPI_LED_LEDMSG(SWLED1, LEDOFF);
146 if (ntlibc_strcmp(argv[1], "SWLED2") == 0) {
147 if (ntlibc_strcmp(argv[2], "ON") == 0) {
148 TSKAPI_LED_LEDMSG(SWLED2, LEDON);
151 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
152 TSKAPI_LED_LEDMSG(SWLED2, LEDOFF);
156 if (ntlibc_strcmp(argv[1], "SWLED3") == 0) {
157 if (ntlibc_strcmp(argv[2], "ON") == 0) {
158 TSKAPI_LED_LEDMSG(SWLED3, LEDON);
161 if (ntlibc_strcmp(argv[2], "OFF") == 0) {
162 TSKAPI_LED_LEDMSG(SWLED3, LEDOFF);
166 syslog(LOG_NOTICE, "Invalid command.");
169 void cmd_mount(int argc, char **argv) {
170 int a = f_mount(0, &fatfs[0]);
171 int b = f_opendir(&dir, "");
172 ntlibc_strcpy(curdir, "");
173 if ((a == 0) && (b == 0)) {
174 syslog(LOG_NOTICE, "Mounted the SD card.");
176 syslog(LOG_NOTICE, "Failure to mount the SD card.");
180 void cmd_ls(int argc, char **argv) {
182 r = f_opendir(&dir, curdir);
184 syslog(LOG_NOTICE, "Failure to open the directory. (code=%d)", r);
188 r = f_readdir(&dir, &filinfo);
190 syslog(LOG_NOTICE, "Failure to read the directory. (code=%d)", r);
193 if (!filinfo.fname[0]) {
196 if (filinfo.fattrib & AM_DIR) {
197 syslog(LOG_NOTICE, "<DIR>\t%s", filinfo.fname);
199 syslog(LOG_NOTICE, "%d\t%s", filinfo.fsize, filinfo.fname);
205 void cmd_cd(int argc, char **argv) {
209 r = f_opendir(&dir, "");
211 ntlibc_strcpy(curdir, "");
215 r = f_opendir(&dir, argv[1]);
217 ntlibc_strcpy(curdir, argv[1]);
221 syslog(LOG_NOTICE, "cd [dir]");
225 syslog(LOG_NOTICE, "Failure to open the director. (code=%d)", r);
230 void cmd_trace(int argc, char **argv) {
231 #ifdef TOPPERS_ENABLE_TRACE
232 syslog(LOG_NOTICE, "trace started.");
234 trace_sta_log(TRACE_STOP);
235 trace_sta_log(TRACE_CLEAR);
236 trace_sta_log(TRACE_AUTOSTOP);
238 syslog(LOG_NOTICE, "trace disabled in this build.");
242 void cmd_exit(int argc, char **argv) {