📄 monitor.c
字号:
{ "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "fss", 0, 0, CMDTYPE_FUNCTION, { monitorIAPFSS }, "Find safe sector", "'fss' has no parameters" }, { "stoa", 1, 1, CMDTYPE_FUNCTION, { monitorIAPSTOA }, "Convert sector to address for 'md'", "'fss' has no parameters" }, { "fill", 2, 2, CMDTYPE_FUNCTION, { monitorIAPFill }, "Fill sector with byte", "'fill <sector> <byte>'" }, { "erase", 1, 1, CMDTYPE_FUNCTION, { monitorIAPErase }, "Erase sector", "'erase <sector>'" }, { "blank", 1, 1, CMDTYPE_FUNCTION, { monitorIAPBlank }, "Blank check sector", "'blank <sector>'" }, { "id", 0, 0, CMDTYPE_FUNCTION, { monitorIAPID }, "Read part ID", "'id' has no parameters" }, { "ver", 0, 0, CMDTYPE_FUNCTION, { monitorIAPVer }, "Read boot loader version", "'ver' has no parameters" }, { "isp", 0, 0, CMDTYPE_FUNCTION, { monitorIAPISP }, "Restart into ISP bootloader", "'isp' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_KBDstatic const commandList_t commandListKBD [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "get", 0, 0, CMDTYPE_FUNCTION, { monitorKbdGet }, "Get character from keyboard", "'start' has no parameters" }, { "start", 0, 0, CMDTYPE_FUNCTION, { monitorKbdStart }, "Start keyboard task", "'start' has no parameters" }, { "stop", 0, 0, CMDTYPE_FUNCTION, { monitorKbdStop }, "End keyboard task", "'stop' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_LCDstatic const commandList_t commandListLCD [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "start", 0, 0, CMDTYPE_FUNCTION, { monitorLCDStart }, "Start LCD task", "'start' has no parameters" }, { "stop", 0, 0, CMDTYPE_FUNCTION, { monitorLCDStop }, "End LCD task", "'stop' has no parameters" }, { "clear", 0, 0, CMDTYPE_FUNCTION, { monitorLCDClear }, "Clear display", "'clear' has no parameters" }, { "gotoxy", 2, 2, CMDTYPE_FUNCTION, { monitorLCDGotoXY }, "Set cursor position", "'gotoxy <column> <line>'" }, { "msg", 1, 1, CMDTYPE_FUNCTION, { monitorLCDMessage }, "Send message to LCD", "'msg <text>'" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_LEDstatic const commandList_t commandListLED [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "start", 0, 0, CMDTYPE_FUNCTION, { monitorLEDStart }, "Start LED task", "'start' has no parameters" }, { "stop", 0, 0, CMDTYPE_FUNCTION, { monitorLEDStop }, "End LED task", "'stop' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_LM75static const commandList_t commandListLM75 [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "init", 0, 0, CMDTYPE_FUNCTION, { monitorLM75Init }, "Initialize LM75", "'init' has no parameters" }, { "mode", 1, 1, CMDTYPE_FUNCTION, { monitorLM75Mode }, "Set LM75 mode", "'mode <value>'" }, { "addr", 1, 1, CMDTYPE_FUNCTION, { monitorLM75Addr }, "Set LM75 address", "'addr <value>'" }, { "reread", 0, 0, CMDTYPE_FUNCTION, { monitorLM75ReRead }, "Re-read last register", "'reread' has no parameters" }, { "temp", 0, 0, CMDTYPE_FUNCTION, { monitorLM75Temp }, "Read LM75 temperature", "'temp' has no parameters" }, { "config", 0, 1, CMDTYPE_FUNCTION, { monitorLM75Config }, "Read part ID", "'id' has no parameters" }, { "thyst", 0, 1, CMDTYPE_FUNCTION, { monitorLM75Thyst }, "Read or set THYST register", "'thyst [value]'" }, { "tos", 0, 1, CMDTYPE_FUNCTION, { monitorLM75Tos }, "Read or set TOS register", "'tos [value]'" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_MEMstatic const commandList_t commandListMem [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "task", 0, 0, CMDTYPE_FUNCTION, { monitorMemTask }, "Show FreeRTOS task memory", "'task' has no parameters" }, { "map", 0, 0, CMDTYPE_FUNCTION, { monitorMemMap }, "Show various addresses", "'map' has no parameters" }, { "alloc", 2, 2, CMDTYPE_FUNCTION, { monitorMemAlloc }, "Allocate memory", "'alloc <slot> <size>'" }, { "realloc", 2, 2, CMDTYPE_FUNCTION, { monitorMemRealloc }, "Reallocate memory", "'realloc <slot> <size>'" }, { "free", 1, 1, CMDTYPE_FUNCTION, { monitorMemFree }, "Free memory", "'free <slot>'" }, { "list", 0, 0, CMDTYPE_FUNCTION, { monitorMemList }, "List memory", "'list' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_MISCstatic const commandList_t commandListMisc [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "ports", 0, 0, CMDTYPE_FUNCTION, { monitorMiscPorts }, "Display port registers", "'ports' has no parameters" }, { "sizeof", 0, 0, CMDTYPE_FUNCTION, { monitorMiscSizeof }, "Sizeof() variable data types", "'sizeof' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_PWMstatic const commandList_t commandListPWM [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "duty", 1, 1, CMDTYPE_FUNCTION, { monitorPWMDuty }, "Set PWM duty cycle", "'duty <0..100>'" }, { "freq", 1, 1, CMDTYPE_FUNCTION, { monitorPWMFrequency}, "Set PWM frequency", "'freq <1..48000000>'" }, { "width", 1, 1, CMDTYPE_FUNCTION, { monitorPWMWidth }, "Set PWM width (in microseconds)", "'width <1..48000000>'" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_RTCstatic const commandList_t commandListRTC [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "get", 0, 0, CMDTYPE_FUNCTION, { monitorRTCGet }, "Display system date/time", "'get' has no parameters" }, { "set", 1, 2, CMDTYPE_FUNCTION, { monitorRTCSet }, "Set system date/time", "'set <gps|YYYY/MM/DD HH:MM:SS>'" }, { "alarm", 0, 2, CMDTYPE_FUNCTION, { monitorRTCAlarm }, "Set date/time for alarm", "'alarm <off|YYYY/MM/DD HH:MM:SS>'" }, { "periodic", 0, 1, CMDTYPE_FUNCTION, { monitorRTCPeriodic }, "Alarm every minute change", "'periodic <on|off>'" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_SENSORSstatic const commandList_t commandListSensors [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "show", 0, 0, CMDTYPE_FUNCTION, { monitorSensorsShow }, "Display sensor data", "'show' has no parameters" }, { "start", 0, 0, CMDTYPE_FUNCTION, { monitorSensorsStart}, "Start sensors task", "'start' has no parameters" }, { "stop", 0, 0, CMDTYPE_FUNCTION, { monitorSensorsStop }, "Stop sensors task", "'stop' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_SWIstatic const commandList_t commandListSWI [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "aset", 1, 1, CMDTYPE_FUNCTION, { monitorSWISetAsm }, "Set LED2 state (asm)", "'aset <on|of>'" }, { "aon", 0, 0, CMDTYPE_FUNCTION, { monitorSWIOnAsm }, "Turn LED2 on (asm)", "'aon' has no parameters" }, { "aoff", 0, 0, CMDTYPE_FUNCTION, { monitorSWIOffAsm }, "Turn LED2 off (asm)", "'aoff' has no parameters" }, { "atoggle", 0, 0, CMDTYPE_FUNCTION, { monitorSWIToggleAsm}, "Toggle LED2 state (asm)", "'atoggle' has no parameters" }, { "cset", 1, 1, CMDTYPE_FUNCTION, { monitorSWISetC }, "Set LED2 state (C)", "'cset <on|off>'" }, { "con", 0, 0, CMDTYPE_FUNCTION, { monitorSWIOnC }, "Turn LED2 on (C)", "'con' has no parameters" }, { "coff", 0, 0, CMDTYPE_FUNCTION, { monitorSWIOffC }, "Turn LED2 off (C)", "'coff' has no parameters" }, { "ctoggle", 0, 0, CMDTYPE_FUNCTION, { monitorSWIToggleC }, "Toggle LED2 state (C)", "'ctoggle' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_UIPstatic const commandList_t commandListUIP [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "dhcp", 0, 1, CMDTYPE_FUNCTION, { monitorUIPDHCP }, "Display/set DHCP state", "'dhcp [<on|off>]'" },#ifdef CFG_TELNETD { "drop", 0, 1, CMDTYPE_FUNCTION, { monitorUIPDrop }, "Drop telnet client connection","'drop' has no parameters" },#endif { "gw", 0, 1, CMDTYPE_FUNCTION, { monitorUIPGW }, "Display/set gateway address", "'gw [<a.b.c.d>]'" }, { "ip", 0, 1, CMDTYPE_FUNCTION, { monitorUIPIP }, "Display/set IP address", "'ip [<a.b.c.d>]'" }, { "mac", 0, 1, CMDTYPE_FUNCTION, { monitorUIPMAC }, "Display/set MAC address", "'mac [<xx:yy:zz:aa:bb:cc>]'" }, { "nm", 0, 1, CMDTYPE_FUNCTION, { monitorUIPNM }, "Display/set netmask address", "'nm [<a.b.c.d>]'" },#ifdef CFG_SNTP { "sntp", 0, 1, CMDTYPE_FUNCTION, { monitorUIPSNTP }, "Request SNTP time", "'sntp [<set>|<a.b.c.d>]'" },#endif { "start", 0, 0, CMDTYPE_FUNCTION, { monitorUIPStart }, "Start UIP stack", "'start' has no parameters" }, { "stop", 0, 0, CMDTYPE_FUNCTION, { monitorUIPStop }, "Stop UIP stack", "'stop' has no parameters" }, { "stats", 0, 0, CMDTYPE_FUNCTION, { monitorUIPStats }, "Display uIP status", "'stats' has no parameters" },#ifdef CFG_SNTP { "to", 0, 1, CMDTYPE_FUNCTION, { monitorUIPTO }, "Display/set time offset", "'to [offset_in_seconds]'" },#endif { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endif#ifdef CFG_WDTstatic const commandList_t commandListWDT [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" }, { "test", 0, 0, CMDTYPE_FUNCTION, { monitorWDTTest }, "Test watchdog", "'test' has no parameters" }, { "status", 0, 0, CMDTYPE_FUNCTION, { monitorWDTStatus }, "Display RSIR register", "'status' has no parameters" }, { "clear", 0, 0, CMDTYPE_FUNCTION, { monitorWDTClear }, "Clear RSIR status", "'rsir' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#endifstatic const commandList_t commandList [] ={ { "help", 0, 0, CMDTYPE_FUNCTION, { monitorHelp }, "This help list", "'help' has no parameters" },#ifdef CFG_ABORT { "abort", 1, 0, CMDTYPE_CMDLIST, { commandListAbort }, "Read/clear abort registers", "'abort help' for help list" },#endif#ifdef CFG_BEEP { "beep", 1, 0, CMDTYPE_CMDLIST, { commandListBeep }, "Beep related functions", "'beep help' for help list" },#endif#ifdef CFG_AT24C1024 { "eei", 1, 0, CMDTYPE_CMDLIST, { commandListEEI }, "Read/write I2C EEPROM", "'eei help' for help list" },#endif#ifdef CFG_M25LC512 { "ees", 1, 0, CMDTYPE_CMDLIST, { commandListEES }, "Read/write SPI EEPROM", "'ees help' for help list" },#endif#ifdef CFG_FATFS { "file", 1, 0, CMDTYPE_CMDLIST, { commandListFile }, "Various file related commands", "'file help' for help list" },#endif#ifdef CFG_FIQ { "fiq", 1, 0, CMDTYPE_CMDLIST, { commandListFIQ }, "Demonstrate FIQ functions", "'fiq help' for help list" },#endif#ifdef CFG_GPS { "gps", 1, 0, CMDTYPE_CMDLIST, { commandListGPS }, "GPS related functions", "'gps help' for help list" },#endif#ifdef CFG_I2C { "i2c", 1, 0, CMDTYPE_CMDLIST, { commandListI2C }, "Perform I2C commands", "'i2c help' for help list" },#endif#ifdef CFG_IAP { "iap", 1, 0, CMDTYPE_CMDLIST, { commandListIAP }, "Perform IAP commands", "'iap help' for help list" },#endif#ifdef CFG_KBD { "kbd", 1, 0, CMDTYPE_CMDLIST, { commandListKBD }, "Various keyboard commands", "'kbd help' for help list" },#endif#ifdef CFG_LCD { "lcd", 1, 0, CMDTYPE_CMDLIST, { commandListLCD }, "Various LCD commands", "'lcd help' for help list" },#endif#ifdef CFG_LED { "led", 1, 0, CMDTYPE_CMDLIST, { commandListLED }, "Various LED commands", "'led help' for help list" },#endif#ifdef CFG_LM75 { "lm75", 1, 0, CMDTYPE_CMDLIST, { commandListLM75 }, "Read/set LM75 temp sensor", "'lm75 help' for help list" },#endif#ifdef CFG_MD { "md", 0, 2, CMDTYPE_FUNCTION, { monitorMd }, "Display memory", "'md [address [length]]'" },#endif#ifdef CFG_MEM { "mem", 1, 0, CMDTYPE_CMDLIST, { commandListMem }, "Various memory functions", "'mem help' for help list" },#endif#ifdef CFG_MISC { "misc", 1, 0, CMDTYPE_CMDLIST, { commandListMisc }, "Miscellaneous stuff", "'misc help' for help list" },#endif#ifdef CFG_PWM { "pwm", 1, 0, CMDTYPE_CMDLIST, { commandListPWM }, "Demonstrate PWM functions", "'pwm help' for help list" },#endif#ifdef CFG_RTC { "rtc", 1, 0, CMDTYPE_CMDLIST, { commandListRTC }, "Demonstrate RTC functions", "'rtc help' for help list" },#endif#ifdef CFG_SENSORS { "sensors", 1, 0, CMDTYPE_CMDLIST, { commandListSensors }, "Sensors related functions", "'sensors help' for help list" },#endif#ifdef CFG_SWI { "swi", 1, 0, CMDTYPE_CMDLIST, { commandListSWI }, "Demonstrate SWI functions", "'swi help' for help list" },#endif#ifdef CFG_UIP { "uip", 1, 0, CMDTYPE_CMDLIST, { commandListUIP }, "Various uIP commands", "'uip help' for help list" },#endif#ifdef CFG_WDT { "wdt", 1, 0, CMDTYPE_CMDLIST, { commandListWDT }, "Manipulate watchdog timer", "'wdt help' for help list" },#endif { "version", 0, 0, CMDTYPE_FUNCTION, { monitorVersion }, "Display version information", "'version' has no parameters" }, { NULL, 0, 0, CMDTYPE_FUNCTION, { NULL }, NULL, NULL },};#ifdef CFG_FATFSstatic FATFS fatfs;static FILINFO fileInfo;#endif#ifdef CFG_UIP#ifdef CFG_DHCPstatic int uipDHCPC = TRUE;#elsestatic int uipDHCPC = FALSE;#endif#endifcommandList_t *activeCommandList = NULL;//// External variables//extern unsigned int __abort_dat;extern unsigned long __start_of_text__;extern unsigned long __end_of_text__;extern unsigned long __start_of_startup__;extern unsigned long __end_of_startup__;extern unsigned long __start_of_prog__;extern unsigned long __end_of_prog__;extern unsigned long __start_of_rodata__;extern unsigned long __end_of_rodata__;extern unsigned long __start_of_glue7__;extern unsigned long __end_of_glue7__;extern unsigned long __data_beg__;extern unsigned long __data_end__;extern unsigned long __bss_beg__;extern unsigned long __bss_end__;extern unsigned long __heap_max;extern unsigned long __heap_beg;extern unsigned long __heap_end;extern unsigned long __stack_end__;extern unsigned long __stack_beg_und;extern unsigned long __stack_end_und;extern unsigned long __stack_beg_abt;extern unsigned long __stack_end_abt;extern unsigned long __stack_beg_fiq;extern unsigned long __stack_end_fiq;extern unsigned long __stack_beg_irq;extern unsigned long __stack_end_irq;extern unsigned long __stack_beg_svc;extern unsigned long __stack_end_svc;extern unsigned long __stack_beg_sys;extern unsigned long __stack_end_sys;extern xTaskHandle taskHandles [TASKHANDLE_LAST];//////#if defined CFG_LCD || defined CFG_UIPstatic int isDecimalString (char *s){ while (*s) if (!isdigit (*s++)) return 0; return 1;}#endif#ifdef CFG_FATFS//// Recursion is our friend... fileInfo is global to avoid eating stack space//static FRESULT scan_files_ex (char *path, int *total_size, int *total_files, int *total_dirs){ DIR dirs; FRESULT res; if ((res = f_opendir (&dirs, path)) == FR_OK) { int i = strlen (path); while (((res = f_readdir (&dirs, &fileInfo)) == FR_OK) && fileInfo.fname [0]) { if (fileInfo.fattrib & AM_DIR) { *total_dirs += 1; *(path + i) = '/'; strcpy (path + i + 1, &fileInfo.fname [0]); res = scan_files_ex (path, total_size, total_files, total_dirs); *(path + i) = '\0'; if (res != FR_OK) return res; } else { *total_files += 1; *total_size += fileInfo.fsize; } } } return res;}static FRESULT scan_files (char *path, int *total_size, int *total_files, int *total_dirs){ *total_size = 0; *total_files = 0; *total_dirs = 0; return scan_files_ex (path, total_size, total_files, total_dirs);}//// These two really ought to be in the FatFS code//U32 get_fattime (){ U32 tmr; time_t now; struct tm tm; now = time (NULL); localtime_r (&now, &tm); tmr = 0 | ((tm.tm_year - 80) << 25) | ((tm.tm_mon + 1) << 21) | (tm.tm_mday << 16) | (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec >> 1); return tmr;}//// Functions newlib doesn't know about (but should)//void _sync (void);int _mkdir (const char *path, mode_t mode);int _chmod (const char *path, mode_t mode);void sync (void);int chmod (const char *path, mode_t mode);void sync (void){ _sync ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -