⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 monitor.c

📁 最新的LPC214X Monitor驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
////  $Id: monitor.c 352 2009-01-12 03:05:28Z jcw $//  $Revision: 352 $//  $Author: jcw $//  $Date: 2009-01-11 22:05:28 -0500 (Sun, 11 Jan 2009) $//  $HeadURL: http://tinymicros.com/svn_public/arm/lpc2148_demo/trunk/monitor/monitor.c $//#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <ctype.h>#include <fcntl.h>#include <time.h>#include <errno.h>#include <malloc.h>#include <sys/time.h>#include <sys/times.h>#include "FreeRTOS.h"#include "task.h"#include "args.h"#include "../fatfs/disk.h"#include "../fatfs/ff.h"#include "../fiq/fiq.h"#include "../gps/gps.h"#include "../i2c/a24c1024.h"#include "../i2c/i2c.h"#include "../i2c/lm75.h"#include "../iap/iap.h"#include "../kbd/kbd.h"#include "../lcd/lcd.h"#include "../leds/leds.h"#include "../main.h"#include "../pwm/pwm.h"#include "../rtc/rtc.h"#include "../sensors/sensors.h"#include "../spi/m25lc512.h"#include "../swi/swi.h"#include "../timer/beep.h"#include "../timer/timer.h"#include "../uip/uiptask.h"#include "../uip/uip/uip.h"#include "../uip/uip/uip_arp.h"#include "../uip/apps/telnetd/telnetd.h"#include "../uip/apps/sntp/sntp.h"#include "monitor.h"#include "argsdispatch.h"//////typedef struct abortDat_s{  unsigned int dummy;  unsigned int sigil;  unsigned int count;  unsigned int type;  unsigned int pc;  unsigned int opcode;  unsigned int cpsr;  unsigned int lr;  unsigned int sp;  unsigned int r0;  unsigned int r1;  unsigned int r2;  unsigned int r3;  unsigned int r4;  unsigned int r5;  unsigned int r6;  unsigned int r7;  unsigned int r8;  unsigned int r9;  unsigned int r10;  unsigned int r11;  unsigned int r12;  unsigned int stack [8];}__attribute__ ((packed)) abortDat_t;////  Prototypes//static int monitorHelp (int argc, portCHAR **argv);#ifdef CFG_MDstatic int monitorMd (int argc, portCHAR **argv);#endif#ifdef CFG_ABORTstatic int monitorAbortRegs (int argc, portCHAR **argv);static int monitorAbortClear (int argc, portCHAR **argv);static int monitorAbortDirty (int argc, portCHAR **argv);static int monitorAbortUndef (int argc, portCHAR **argv);static int monitorAbortPabort (int argc, portCHAR **argv);static int monitorAbortDabort (int argc, portCHAR **argv);#endif#ifdef CFG_BEEPstatic int monitorBeepOff (int argc, portCHAR **argv);static int monitorBeepOn (int argc, portCHAR **argv);static int monitorBeepMHALL (int argc, portCHAR **argv);static int monitorBeepSMOTW (int argc, portCHAR **argv);#endif#ifdef CFG_AT24C1024static int monitorEEIAddr (int argc, portCHAR **argv);static int monitorEEIRead (int argc, portCHAR **argv);static int monitorEEIReadAddr (int argc, portCHAR **argv);static int monitorEEIWrite (int argc, portCHAR **argv);static int monitorEEIWriteAddr (int argc, portCHAR **argv);static int monitorEEIFillAddr (int argc, portCHAR **argv);#endif#ifdef CFG_M25LC512static int monitorEESAddr (int argc, portCHAR **argv);static int monitorEESRead (int argc, portCHAR **argv);static int monitorEESReadAddr (int argc, portCHAR **argv);static int monitorEESWrite (int argc, portCHAR **argv);static int monitorEESWriteAddr (int argc, portCHAR **argv);static int monitorEESFillAddr (int argc, portCHAR **argv);static int monitorEESEraseChip (int argc, portCHAR **argv);static int monitorEESEraseSector (int argc, portCHAR **argv);static int monitorEESErasePage (int argc, portCHAR **argv);static int monitorEESWriteEnable (int argc, portCHAR **argv);static int monitorEESWriteDisable (int argc, portCHAR **argv);static int monitorEESReadID (int argc, portCHAR **argv);static int monitorEESPowerDown (int argc, portCHAR **argv);static int monitorEESStatusRead (int argc, portCHAR **argv);static int monitorEESStatusWrite (int argc, portCHAR **argv);#endif#ifdef CFG_FATFSstatic int monitorFileChmod (int argc, portCHAR **argv);static int monitorFileConcat (int argc, portCHAR **argv);static int monitorFileCp (int argc, portCHAR **argv);static int monitorFileCpCon (int argc, portCHAR **argv);static int monitorFileDf (int argc, portCHAR **argv);static int monitorFileInit (int argc, portCHAR **argv);static int monitorFileLs (int argc, portCHAR **argv);static int monitorFileMkfs (int argc, portCHAR **argv);static int monitorFileMount (int argc, portCHAR **argv);static int monitorFileMkdir (int argc, portCHAR **argv);static int monitorFileMv (int argc, portCHAR **argv);static int monitorFileRm (int argc, portCHAR **argv);static int monitorFileRmdir (int argc, portCHAR **argv);static int monitorFileSync (int argc, portCHAR **argv);static int monitorFileThruPut (int argc, portCHAR **argv);#endif#ifdef CFG_FIQstatic int monitorFIQClear (int argc, portCHAR **argv);static int monitorFIQCount (int argc, portCHAR **argv);static int monitorFIQOff (int argc, portCHAR **argv);static int monitorFIQOn (int argc, portCHAR **argv);#endif#ifdef CFG_GPSstatic int monitorGPSShow (int argc, portCHAR **argv);static int monitorGPSStart (int argc, portCHAR **argv);static int monitorGPSStop (int argc, portCHAR **argv);#endif#ifdef CFG_I2Cstatic int monitorI2CRead (int argc, portCHAR **argv);static int monitorI2CWrite (int argc, portCHAR **argv);static int monitorI2CWriteRead (int argc, portCHAR **argv);static int monitorI2CDump (int argc, portCHAR **argv);static int monitorI2CErrno (int argc, portCHAR **argv);#endif#ifdef CFG_IAPstatic int monitorIAPFSS (int argc, portCHAR **argv);static int monitorIAPSTOA (int argc, portCHAR **argv);static int monitorIAPFill (int argc, portCHAR **argv);static int monitorIAPErase (int argc, portCHAR **argv);static int monitorIAPBlank (int argc, portCHAR **argv);static int monitorIAPID (int argc, portCHAR **argv);static int monitorIAPVer(int argc, portCHAR **argv);static int monitorIAPISP (int argc, portCHAR **argv);#endif#ifdef CFG_KBDstatic int monitorKbdGet (int argc, portCHAR **argv);static int monitorKbdStart (int argc, portCHAR **argv);static int monitorKbdStop (int argc, portCHAR **argv);#endif#ifdef CFG_LCDstatic int monitorLCDStart (int argc, portCHAR **argv);static int monitorLCDStop (int argc, portCHAR **argv);static int monitorLCDClear (int argc, portCHAR **argv);static int monitorLCDGotoXY (int argc, portCHAR **argv);static int monitorLCDMessage (int argc, portCHAR **argv);#endif#ifdef CFG_LEDstatic int monitorLEDStart (int argc, portCHAR **argv);static int monitorLEDStop (int argc, portCHAR **argv);#endif#ifdef CFG_LM75static int monitorLM75Init (int argc, portCHAR **argv);static int monitorLM75Mode (int argc, portCHAR **argv);static int monitorLM75Addr (int argc, portCHAR **argv);static int monitorLM75ReRead (int argc, portCHAR **argv);static int monitorLM75Temp (int argc, portCHAR **argv);static int monitorLM75Config (int argc, portCHAR **argv);static int monitorLM75Thyst (int argc, portCHAR **argv);static int monitorLM75Tos (int argc, portCHAR **argv);#endif#ifdef CFG_MEMstatic int monitorMemTask (int argc, portCHAR **argv);static int monitorMemMap (int argc, portCHAR **argv);static int monitorMemAlloc (int argc, portCHAR **argv);static int monitorMemRealloc (int argc, portCHAR **argv);static int monitorMemFree (int argc, portCHAR **argv);static int monitorMemList (int argc, portCHAR **argv);#endif#ifdef CFG_MISCstatic int monitorMiscPorts (int argc, portCHAR **argv);static int monitorMiscSizeof (int argc, portCHAR **argv);#endif#ifdef CFG_PWMstatic int monitorPWMDuty (int argc, portCHAR **argv);static int monitorPWMFrequency (int argc, portCHAR **argv);static int monitorPWMWidth (int argc, portCHAR **argv);#endif#ifdef CFG_RTCstatic int monitorRTCGet (int argc, portCHAR **argv);static int monitorRTCSet (int argc, portCHAR **argv);static int monitorRTCAlarm (int argc, portCHAR **argv);static int monitorRTCPeriodic (int argc, portCHAR **argv);#endif#ifdef CFG_SENSORSstatic int monitorSensorsShow (int argc, portCHAR **argv);static int monitorSensorsStart (int argc, portCHAR **argv);static int monitorSensorsStop (int argc, portCHAR **argv);#endif#ifdef CFG_SWIstatic int monitorSWISetAsm (int argc, portCHAR **argv);static int monitorSWIOnAsm (int argc, portCHAR **argv);static int monitorSWIOffAsm (int argc, portCHAR **argv);static int monitorSWIToggleAsm (int argc, portCHAR **argv);static int monitorSWISetC (int argc, portCHAR **argv);static int monitorSWIOnC (int argc, portCHAR **argv);static int monitorSWIOffC (int argc, portCHAR **argv);static int monitorSWIToggleC (int argc, portCHAR **argv);#endif#ifdef CFG_UIPstatic int monitorUIPDHCP (int argc, portCHAR **argv);#ifdef CFG_TELNETDstatic int monitorUIPDrop (int argc, portCHAR **argv);#endifstatic int monitorUIPGW (int argc, portCHAR **argv);static int monitorUIPIP (int argc, portCHAR **argv);static int monitorUIPMAC (int argc, portCHAR **argv);static int monitorUIPNM (int argc, portCHAR **argv);#ifdef CFG_SNTPstatic int monitorUIPSNTP (int argc, portCHAR **argv);#endifstatic int monitorUIPStart (int argc, portCHAR **argv);static int monitorUIPStop (int argc, portCHAR **argv);static int monitorUIPStats (int argc, portCHAR **argv);#ifdef CFG_SNTPstatic int monitorUIPTO (int argc, portCHAR **argv);#endif#endif#ifdef CFG_WDTstatic int monitorWDTTest (int argc, portCHAR **argv);static int monitorWDTStatus (int argc, portCHAR **argv);static int monitorWDTClear (int argc, portCHAR **argv);#endifstatic int monitorVersion (int argc, portCHAR **argv);//////#ifdef CFG_ABORTstatic const commandList_t commandListAbort [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp        }, "This help list",                 "'help' has no parameters" },  { "regs",     0,  0, CMDTYPE_FUNCTION,  { monitorAbortRegs   }, "Print abort registers",          "'regs' has no parameters" },  { "clear",    0,  0, CMDTYPE_FUNCTION,  { monitorAbortClear  }, "Clear abort registers",          "'clear' has no parameters" },  { "dirty",    0,  0, CMDTYPE_FUNCTION,  { monitorAbortDirty  }, "Dirty sigil flag",               "'dirty' has no parameters" },  { "undef",    0,  0, CMDTYPE_FUNCTION,  { monitorAbortUndef  }, "Execute undefined instruction",  "'undef' has no parameters" },  { "pabort",   0,  0, CMDTYPE_FUNCTION,  { monitorAbortPabort }, "Cause prefetch abort",           "'pabort' has no parameters" },  { "dabort",   0,  0, CMDTYPE_FUNCTION,  { monitorAbortDabort }, "Cause data abort",               "'dabort' has no parameters" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL               }, NULL,                             NULL },};#endif#ifdef CFG_BEEPstatic const commandList_t commandListBeep [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp        }, "This help list",               "'help' has no parameters" },  { "off",      0,  0, CMDTYPE_FUNCTION,  { monitorBeepOff     }, "Turn beeper off",              "'off' has no parameters" },  { "on",       1,  1, CMDTYPE_FUNCTION,  { monitorBeepOn      }, "Start <hz> frequency beep",    "'on [60..20000]'" },  { "mhall",    0,  0, CMDTYPE_FUNCTION,  { monitorBeepMHALL   }, "Play Mary Had a Little Lamb",  "'mhall' has no parameters" },  { "smotw",    0,  0, CMDTYPE_FUNCTION,  { monitorBeepSMOTW   }, "Play Smoke On The Water",      "'smotw' has no parameters" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL               }, NULL,                           NULL },};#endif#ifdef CFG_AT24C1024static const commandList_t commandListEEI [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp        }, "This help list",               "'help' has no parameters" },  { "a",        1,  1, CMDTYPE_FUNCTION,  { monitorEEIAddr     }, "Set EEPROM r/w address",       "'ee <address>'" },  { "r",        0,  1, CMDTYPE_FUNCTION,  { monitorEEIRead     }, "Read from current address",    "'r <# bytes>'" },  { "ra",       1,  2, CMDTYPE_FUNCTION,  { monitorEEIReadAddr }, "Read EEPROM",                  "'ra <address> <# bytes>'" },  { "w",        1, 16, CMDTYPE_FUNCTION,  { monitorEEIWrite    }, "Write to current address",     "'w <byte> [<byte> [...<byte>]]'" },  { "wa",       2, 17, CMDTYPE_FUNCTION,  { monitorEEIWriteAddr}, "Write EEPOM",                  "'wa <address> <byte> [<byte> [...<byte>]]'" },  { "fa",       3,  3, CMDTYPE_FUNCTION,  { monitorEEIFillAddr }, "Fill EEPOM",                   "'fa <address> <len> <byte>'" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL               }, NULL,                           NULL },};#endif#ifdef CFG_M25LC512static const commandList_t commandListEES [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp            }, "This help list",               "'help' has no parameters" },  { "a",        1,  1, CMDTYPE_FUNCTION,  { monitorEESAddr         }, "Set EEPROM r/w address",       "'ee <address>'" },  { "r",        0,  1, CMDTYPE_FUNCTION,  { monitorEESRead         }, "Read from current address",    "'r <# bytes>'" },  { "ra",       1,  2, CMDTYPE_FUNCTION,  { monitorEESReadAddr     }, "Read EEPROM",                  "'ra <address> <# bytes>'" },  { "w",        1, 16, CMDTYPE_FUNCTION,  { monitorEESWrite        }, "Write to current address",     "'w <byte> [<byte> [...<byte>]]'" },  { "wa",       2, 17, CMDTYPE_FUNCTION,  { monitorEESWriteAddr    }, "Write EEPOM",                  "'wa <address> <byte> [<byte> [...<byte>]]'" },  { "fa",       3,  3, CMDTYPE_FUNCTION,  { monitorEESFillAddr     }, "Fill EEPOM",                   "'fa <address> <len> <byte>'" },  { "ce",       0,  0, CMDTYPE_FUNCTION,  { monitorEESEraseChip    }, "Erase EEPROM",                 "'ce' has no parameters" },  { "se",       1,  1, CMDTYPE_FUNCTION,  { monitorEESEraseSector  }, "Erase sector",                 "'se <0..3>'" },  { "pe",       1,  1, CMDTYPE_FUNCTION,  { monitorEESErasePage    }, "Erase page",                   "'pe <0..511>'" },  { "wren",     0,  0, CMDTYPE_FUNCTION,  { monitorEESWriteEnable  }, "Enable writes to EEPROM",      "'wren' has no parameters" },  { "wrdi",     0,  0, CMDTYPE_FUNCTION,  { monitorEESWriteDisable }, "Disable writes to EEPROM",     "'wrdi' has no parameters" },  { "id",       0,  0, CMDTYPE_FUNCTION,  { monitorEESReadID       }, "Read device ID",               "'id' has no parameters" },  { "dpd",      0,  0, CMDTYPE_FUNCTION,  { monitorEESPowerDown    }, "Deep power-down device",       "'dpd' has no parameters" },  { "rdsr",     0,  0, CMDTYPE_FUNCTION,  { monitorEESStatusRead   }, "Read status register",         "'rdsr' has no parameters" },  { "wrsr",     1,  1, CMDTYPE_FUNCTION,  { monitorEESStatusWrite  }, "Write status register",        "'wrsr <0..255>'" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL                   }, NULL,                           NULL },};#endif#ifdef CFG_FATFSstatic const commandList_t commandListFile [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp        }, "This help list",               "'help' has no parameters" },  { "chmod",    2,  2, CMDTYPE_FUNCTION,  { monitorFileChmod   }, "Change file mode",             "'chmod <+w|-w> <[path]filename>'" },  { "concat",   2,  2, CMDTYPE_FUNCTION,  { monitorFileConcat  }, "Concatenate 1st to 2nd file",  "'concat <[path]1st_filename> <[path]2nd_filename>'" },  { "cp",       1,  2, CMDTYPE_FUNCTION,  { monitorFileCp      }, "Copy a file",                  "'cp <[path]old_filename> <[path]new_filename>'" },  { "cpcon",    1,  1, CMDTYPE_FUNCTION,  { monitorFileCpCon   }, "Copy console input to file",   "'cpcon <[path]filename>' (ctrl-d exits and saves)" },  { "df",       0,  0, CMDTYPE_FUNCTION,  { monitorFileDf      }, "File system status & info",    "'df' has no parameters" },  { "init",     0,  0, CMDTYPE_FUNCTION,  { monitorFileInit    }, "Initialize disk subsystem",    "'init' has no parameters" },  { "ls",       0,  1, CMDTYPE_FUNCTION,  { monitorFileLs      }, "Display directory",            "'ls [optional path]'" },  { "mkdir",    1,  1, CMDTYPE_FUNCTION,  { monitorFileMkdir   }, "Create directory",             "'mkdir <[path]directory'" },  { "mkfs",     0,  0, CMDTYPE_FUNCTION,  { monitorFileMkfs    }, "Create a FAT filesystem",      "'mkfs' has no parameters" },  { "mount",    0,  0, CMDTYPE_FUNCTION,  { monitorFileMount   }, "Mount disk",                   "'mount' has no parameters" },  { "mv",       2,  2, CMDTYPE_FUNCTION,  { monitorFileMv      }, "Rename a file or directory",   "'mv <[path]old_filename> <[path]new_filename>'" },  { "rm",       1,  1, CMDTYPE_FUNCTION,  { monitorFileRm      }, "Delete file",                  "'rm <[path]filename>'" },  { "rmdir",    1,  1, CMDTYPE_FUNCTION,  { monitorFileRmdir   }, "Delete directory",             "'rmdir <[path]directory>'" },  { "sync",     0,  0, CMDTYPE_FUNCTION,  { monitorFileSync    }, "Sync filesystem",              "'sync' has no parameters" },  { "thruput",  1,  1, CMDTYPE_FUNCTION,  { monitorFileThruPut }, "Measure MMC/SD throughput",    "'thruput <normal|noints|high|suspendall>'" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL               }, NULL,                           NULL },};#endif#ifdef CFG_FIQstatic const commandList_t commandListFIQ [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp        }, "This help list",                 "'help' has no parameters" },  { "clear",    0,  0, CMDTYPE_FUNCTION,  { monitorFIQClear    }, "Clear FIQ interrupt counter",    "'clear' has no parameters" },  { "count",    0,  0, CMDTYPE_FUNCTION,  { monitorFIQCount    }, "Show number of FIQ interrupts",  "'show' has no parameters" },  { "off",      0,  0, CMDTYPE_FUNCTION,  { monitorFIQOff      }, "Disable FIQ interrupt",          "'off' has no parameters" },  { "on",       0,  0, CMDTYPE_FUNCTION,  { monitorFIQOn       }, "Enable FIQ interrupt",           "'on' has no parameters" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL               }, NULL,                             NULL },};#endif#ifdef CFG_GPSstatic const commandList_t commandListGPS [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp        }, "This help list",               "'help' has no parameters" },  { "show",     0,  0, CMDTYPE_FUNCTION,  { monitorGPSShow     }, "Display GPS data",             "'show' has no parameters" },  { "start",    0,  0, CMDTYPE_FUNCTION,  { monitorGPSStart    }, "Start GPS task",               "'start' has no parameters" },  { "stop",     0,  0, CMDTYPE_FUNCTION,  { monitorGPSStop     }, "Stop GPS task",                "'stop' has no parameters" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL               }, NULL,                           NULL },};#endif#ifdef CFG_I2Cstatic const commandList_t commandListI2C [] ={  { "help",     0,  0, CMDTYPE_FUNCTION,  { monitorHelp        }, "This help list",                     "'help' has no parameters" },  { "r",        2,  2, CMDTYPE_FUNCTION,  { monitorI2CRead     }, "Read from I2C device",               "'r <address> <# bytes>'" },  { "w",        2, 17, CMDTYPE_FUNCTION,  { monitorI2CWrite    }, "Write to I2C device",                "'w <address> <byte> [<byte> [...<byte>]]'" },  { "wr",       2, 18, CMDTYPE_FUNCTION,  { monitorI2CWriteRead}, "Write to then read from I2C device", "'wr <address> <byte> [<byte> [...<byte>]] <# bytes to read>'" },  { "dump",     0,  0, CMDTYPE_FUNCTION,  { monitorI2CDump     }, "Dump I2C Debug Buffer",              "'dump' has no parameters" },  { "errno",    0,  0, CMDTYPE_FUNCTION,  { monitorI2CErrno    }, "Display i2cErrno value",             "'errno' has no parameters" },  { NULL,       0,  0, CMDTYPE_FUNCTION,  { NULL               }, NULL,                                 NULL },};#endif#ifdef CFG_IAPstatic const commandList_t commandListIAP [] ={

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -