16 #define printScreen(...) {chprintf (chpg, __VA_ARGS__); chprintf (chpg, "\r\n");}
23 static void cmd_info(BaseSequentialStream *lchp,
int argc,
24 const char *
const argv[]);
34 static BaseSequentialStream *
chpg;
40 #if SHELL_DYNAMIC_ENTRIES_NUMBER
56 streamPut(
chpg, str[i++]);
63 const char *name = argv[0];
68 if (strcasecmp(scp->
sc_name, name) == 0) {
77 if (strcasecmp(scp->
sc_name, name) == 0) {
98 const char *bit = argv[argc-1];
103 if (strstr(scp->sc_name, bit) == scp->sc_name) {
111 if (strstr(scp->sc_name, bit) == scp->sc_name) {
137 static void usage(BaseSequentialStream *lchp,
char *
p) {
144 static void cmd_info(BaseSequentialStream *lchp,
int argc,
const char *
const argv[]) {
202 const uint16_t mcu_revid = (DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16;
203 const uint16_t mcu_devid = DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID;
204 char *mcu_devid_str =
"not known, please fix microrlShell.c";
205 char mcu_revid_chr =
'?';
208 case 0x415 : mcu_devid_str =
"STM32L475xx/476xx/486xx devices";
210 case 0x1000 : mcu_revid_chr =
'1';
break;
211 case 0x1001 : mcu_revid_chr =
'2';
break;
212 case 0x1003 : mcu_revid_chr =
'3';
break;
213 case 0x1007 : mcu_revid_chr =
'4';
break;
216 case 0x461 : mcu_devid_str =
"STM32L496xx/4A6xx devices";
218 case 0x1000 : mcu_revid_chr =
'A';
break;
219 case 0x2000 : mcu_revid_chr =
'B';
break;
222 case 0x411 : mcu_devid_str =
"STM32F2xx and *EARLY* STM32F40x and 41x";
224 case 0x1000 : mcu_revid_chr =
'A';
break;
225 case 0x1001 : mcu_revid_chr =
'Z';
break;
226 case 0x2000 : mcu_revid_chr =
'B';
break;
227 case 0x2001 : mcu_revid_chr =
'Y';
break;
228 case 0x2003 : mcu_revid_chr =
'X';
break;
231 case 0x413 : mcu_devid_str =
"STM32F40x and 41x";
233 case 0x1000 : mcu_revid_chr =
'A';
break;
234 case 0x1001 : mcu_revid_chr =
'Z';
break;
235 case 0x1003 : mcu_revid_chr =
'1';
break;
236 case 0x1007 : mcu_revid_chr =
'2';
break;
237 case 0x100F : mcu_revid_chr =
'Y';
break;
240 case 0x419 : mcu_devid_str =
"STM32F42x and F43x";
242 case 0x1000 : mcu_revid_chr =
'A';
break;
243 case 0x1003 : mcu_revid_chr =
'Y';
break;
244 case 0x1007 : mcu_revid_chr =
'1';
break;
245 case 0x2001 : mcu_revid_chr =
'3';
break;
248 case 0x449 : mcu_devid_str =
"STM32F74x and STM32F75x";
250 case 0x1000 : mcu_revid_chr =
'A';
break;
251 case 0x1001 : mcu_revid_chr =
'Z';
break;
254 case 0x451 : mcu_devid_str =
"STM32F76x and STM32F77x";
256 case 0x1000 : mcu_revid_chr =
'A';
break;
257 case 0x1001 : mcu_revid_chr =
'Z';
break;
260 case 0x435 : mcu_devid_str =
"STM32L43x";
262 case 0x1000 : mcu_revid_chr =
'A';
break;
263 case 0x1001 : mcu_revid_chr =
'Z';
break;
266 case 0x446 : mcu_devid_str =
"STM32F303xD/E and STM32F398xE";
268 case 0x1001 : mcu_revid_chr =
'Z';
break;
269 case 0x1003 : mcu_revid_chr =
'Y';
break;
274 chprintf(lchp,
"Kernel: %s\r\n", CH_KERNEL_VERSION);
276 chprintf(lchp,
"Hal: %s\r\n", HAL_VERSION);
279 #ifdef CH_COMPILER_NAME
280 chprintf(lchp,
"Compiler: %s\r\n", CH_COMPILER_NAME);
282 #ifdef PORT_COMPILER_NAME
283 chprintf(lchp,
"Compiler: %s\r\n", PORT_COMPILER_NAME);
286 #ifdef CH_ARCHITECTURE_NAME
287 chprintf(lchp,
"Architecture: %s\r\n", CH_ARCHITECTURE_NAME);
289 #ifdef PORT_ARCHITECTURE_NAME
290 chprintf(lchp,
"Architecture: %s\r\n", PORT_ARCHITECTURE_NAME);
294 #ifdef CH_CORE_VARIANT_NAME
295 chprintf(lchp,
"Core Variant: %s\r\n", CH_CORE_VARIANT_NAME);
297 #ifdef PORT_CORE_VARIANT_NAME
298 chprintf(lchp,
"Core Variant: %s\r\n", PORT_CORE_VARIANT_NAME);
301 #pragma GCC diagnostic push
302 #pragma GCC diagnostic ignored "-Wdouble-promotion"
304 #pragma GCC diagnostic pop
308 chprintf(lchp,
"Port Info: %s\r\n", CH_PORT_INFO);
311 chprintf(lchp,
"Port Info: %s\r\n", PORT_INFO);
315 chprintf(lchp,
"Platform: %s\r\n", PLATFORM_NAME);
322 chprintf(lchp,
"Chip Revision: %s REV '%c' (0x%x:0x%x)\r\n", mcu_devid_str, mcu_revid_chr, mcu_devid, mcu_revid);
324 #if (!defined STM32_USE_REVISION_A_FIX) || (STM32_USE_REVISION_A_FIX == 0)
325 if ((mcu_devid == 0x413) && (mcu_revid_chr ==
'A')) {
326 chprintf(lchp,
"Chip Revision: %s REV '%c' PLEASE define STM32_USE_REVISION_A_FIX in mcuconf.h !!\r\n",
327 mcu_devid_str, mcu_revid_chr);
333 chprintf(lchp,
"Build time: %s%s%s\r\n", __DATE__,
" - ", __TIME__);
337 chprintf(lchp,
"systime= %lu\r\n", (
unsigned long)chVTGetSystemTimeX());
355 chRegSetThreadName(
"Enhanced_shell");
357 while (!chThdShouldTerminateX()) {
359 if (streamRead(
chpg, &c, 1) > 0) {
396 #if CH_CFG_USE_HEAP && CH_CFG_USE_DYNAMIC
397 thread_t *shellCreateFromHeap(
const ShellConfig *scp,
size_t size, tprio_t prio) {
398 return chThdCreateFromHeap(NULL, size,
"shell", prio, shell_thread, (
void *)scp);
413 size_t size, tprio_t prio) {
414 return chThdCreateStatic(wsp, size, prio, shell_thread, (
void *)scp);
417 #if SHELL_DYNAMIC_ENTRIES_NUMBER
static pthread_mutex_t mut
shellcmd_f * sc_function
Command function.
const char * sc_name
Command name.
static AltCbParam altCbParam
void shellInit(void)
Shell manager initialization.
event_source_t shell_terminated
Shell termination event source.
static const ShellCommand localCommands[]
Array of the default and dynamic commands.
void microrlExecute(int argc, const char *const *argv)
const char ** microrlComplet(int argc, const char *const *argv)
static THD_FUNCTION(shell_thread, p)
Shell thread function.
static void cmd_info(BaseSequentialStream *lchp, int argc, const char *const argv[])
#define SHELL_DYNAMIC_ENTRIES_NUMBER
static BaseSequentialStream * chpg
void microrlPrint(const char *str)
static void usage(BaseSequentialStream *lchp, char *p)
void modeAlternate(void(*funcp)(uint8_t c, uint32_t mode), uint32_t mode)
void(* altFunc)(uint8_t c, uint32_t mode)
thread_t * shellCreateStatic(const ShellConfig *scp, void *wsp, size_t size, tprio_t prio)
Spawns a new shell.
static const char * complWorlds[64]
static const ShellCommand * staticCommands
Custom command entry type.
void chprintf(BaseSequentialStream *lchp, const char *fmt,...)
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
void microrl_set_complete_callback(microrl_t *pThis, const char **(*get_completion)(int, const char *const *))
void microrl_init(microrl_t *pThis, void(*print)(const char *))
void microrl_insert_char(microrl_t *pThis, int ch)
void microrl_set_sigint_callback(microrl_t *pThis, void(*sigintf)(void))
void microrl_set_execute_callback(microrl_t *pThis, void(*execute)(int, const char *const *))
Mini printf-like functionality.
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.