17#define printScreen(...) {chprintf (chpg, __VA_ARGS__); chprintf (chpg, "\r\n");}
24static void cmd_info(BaseSequentialStream *lchp,
int argc,
25 const char *
const argv[]);
35static BaseSequentialStream *
chpg;
41#if SHELL_DYNAMIC_ENTRIES_NUMBER
57 streamPut(
chpg, str[i++]);
64 const char *name = argv[0];
69 if (strcasecmp(scp->
sc_name, name) == 0) {
78 if (strcasecmp(scp->
sc_name, name) == 0) {
99 const char *bit = argv[argc-1];
102 scp->sc_name != NULL; scp++) {
104 if (strstr(scp->sc_name, bit) == scp->sc_name) {
110 scp->sc_name != NULL; scp++) {
112 if (strstr(scp->sc_name, bit) == scp->sc_name) {
138static void usage(BaseSequentialStream *lchp,
char *
p) {
145static void cmd_info(BaseSequentialStream *lchp,
int argc,
const char *
const argv[]) {
203 const uint16_t mcu_revid = (DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16;
204 const uint16_t mcu_devid = DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID;
205 char *mcu_devid_str =
"not known, please fix microrlShell.c";
206 char mcu_revid_chr =
'?';
209 case 0x415 : mcu_devid_str =
"STM32L475xx/476xx/486xx devices";
211 case 0x1000 : mcu_revid_chr =
'1';
break;
212 case 0x1001 : mcu_revid_chr =
'2';
break;
213 case 0x1003 : mcu_revid_chr =
'3';
break;
214 case 0x1007 : mcu_revid_chr =
'4';
break;
217 case 0x461 : mcu_devid_str =
"STM32L496xx/4A6xx devices";
219 case 0x1000 : mcu_revid_chr =
'A';
break;
220 case 0x2000 : mcu_revid_chr =
'B';
break;
223 case 0x411 : mcu_devid_str =
"STM32F2xx and *EARLY* STM32F40x and 41x";
225 case 0x1000 : mcu_revid_chr =
'A';
break;
226 case 0x1001 : mcu_revid_chr =
'Z';
break;
227 case 0x2000 : mcu_revid_chr =
'B';
break;
228 case 0x2001 : mcu_revid_chr =
'Y';
break;
229 case 0x2003 : mcu_revid_chr =
'X';
break;
232 case 0x413 : mcu_devid_str =
"STM32F40x and 41x";
234 case 0x1000 : mcu_revid_chr =
'A';
break;
235 case 0x1001 : mcu_revid_chr =
'Z';
break;
236 case 0x1003 : mcu_revid_chr =
'1';
break;
237 case 0x1007 : mcu_revid_chr =
'2';
break;
238 case 0x100F : mcu_revid_chr =
'Y';
break;
241 case 0x419 : mcu_devid_str =
"STM32F42x and F43x";
243 case 0x1000 : mcu_revid_chr =
'A';
break;
244 case 0x1003 : mcu_revid_chr =
'Y';
break;
245 case 0x1007 : mcu_revid_chr =
'1';
break;
246 case 0x2001 : mcu_revid_chr =
'3';
break;
249 case 0x449 : mcu_devid_str =
"STM32F74x and STM32F75x";
251 case 0x1000 : mcu_revid_chr =
'A';
break;
252 case 0x1001 : mcu_revid_chr =
'Z';
break;
255 case 0x451 : mcu_devid_str =
"STM32F76x and STM32F77x";
257 case 0x1000 : mcu_revid_chr =
'A';
break;
258 case 0x1001 : mcu_revid_chr =
'Z';
break;
261 case 0x435 : mcu_devid_str =
"STM32L43x";
263 case 0x1000 : mcu_revid_chr =
'A';
break;
264 case 0x1001 : mcu_revid_chr =
'Z';
break;
267 case 0x446 : mcu_devid_str =
"STM32F303xD/E and STM32F398xE";
269 case 0x1001 : mcu_revid_chr =
'Z';
break;
270 case 0x1003 : mcu_revid_chr =
'Y';
break;
275 chprintf(lchp,
"Kernel: %s\r\n", CH_KERNEL_VERSION);
277 chprintf(lchp,
"Hal: %s\r\n", HAL_VERSION);
280#ifdef CH_COMPILER_NAME
281 chprintf(lchp,
"Compiler: %s\r\n", CH_COMPILER_NAME);
283#ifdef PORT_COMPILER_NAME
284 chprintf(lchp,
"Compiler: %s\r\n", PORT_COMPILER_NAME);
287#ifdef CH_ARCHITECTURE_NAME
288 chprintf(lchp,
"Architecture: %s\r\n", CH_ARCHITECTURE_NAME);
290#ifdef PORT_ARCHITECTURE_NAME
291 chprintf(lchp,
"Architecture: %s\r\n", PORT_ARCHITECTURE_NAME);
295#ifdef CH_CORE_VARIANT_NAME
296 chprintf(lchp,
"Core Variant: %s\r\n", CH_CORE_VARIANT_NAME);
298#ifdef PORT_CORE_VARIANT_NAME
299 chprintf(lchp,
"Core Variant: %s\r\n", PORT_CORE_VARIANT_NAME);
302#pragma GCC diagnostic push
303#pragma GCC diagnostic ignored "-Wdouble-promotion"
304 chprintf(lchp,
"Main STM32_SYSCLK frequency %.2f Mhz\r\n", STM32_SYSCLK/1e6f);
305#pragma GCC diagnostic pop
309 chprintf(lchp,
"Port Info: %s\r\n", CH_PORT_INFO);
312 chprintf(lchp,
"Port Info: %s\r\n", PORT_INFO);
316 chprintf(lchp,
"Platform: %s\r\n", PLATFORM_NAME);
323 chprintf(lchp,
"Chip Revision: %s REV '%c' (0x%x:0x%x)\r\n", mcu_devid_str, mcu_revid_chr, mcu_devid, mcu_revid);
325#if (!defined STM32_USE_REVISION_A_FIX) || (STM32_USE_REVISION_A_FIX == 0)
326 if ((mcu_devid == 0x413) && (mcu_revid_chr ==
'A')) {
327 chprintf(lchp,
"Chip Revision: %s REV '%c' PLEASE define STM32_USE_REVISION_A_FIX in mcuconf.h !!\r\n",
328 mcu_devid_str, mcu_revid_chr);
334 chprintf(lchp,
"Build time: %s%s%s\r\n", __DATE__,
" - ", __TIME__);
338 chprintf(lchp,
"systime= %lu\r\n", (
unsigned long)chVTGetSystemTimeX());
356 chRegSetThreadName(
"Enhanced_shell");
358 while (!chThdShouldTerminateX()) {
360 if (streamRead(
chpg, &c, 1) > 0) {
397#if CH_CFG_USE_HEAP && CH_CFG_USE_DYNAMIC
398thread_t *shellCreateFromHeap(
const ShellConfig *scp,
size_t size, tprio_t prio) {
399 return chThdCreateFromHeap(NULL, size,
"shell", prio, shell_thread, (
void *)scp);
414 size_t size, tprio_t prio) {
415 return chThdCreateStatic(wsp, size, prio, shell_thread, (
void *)scp);
418#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,...)
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...
Implementation of system time functions for ChibiOS arch.
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.