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

📄 monitor.c

📁 最新的LPC214X Monitor驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
    printf ("m25lc512WriteDisable() returned error %d/%s\n", r, m25lc512Strerror (r));  else    m25lc512WriteGate = FALSE;  return 0;}static int monitorEESReadID (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  U8 id;  m25lc_e r;  if (monitorEESuIPCheck ())    return 0;  if ((r = m25lc512ReadID (&id)) != M25LC_OK)    printf ("m25lc512ReadID() returned error %d/%s\n", r, m25lc512Strerror (r));  else    printf ("ID = 0x%02x (%d)\n", id, id);  return 0;}static int monitorEESPowerDown (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  m25lc_e r;  if (monitorEESuIPCheck ())    return 0;  if ((r = m25lc512DeepPowerDown ()) != M25LC_OK)    printf ("m25lc512DeepPowerDown() returned error %d/%s\n", r, m25lc512Strerror (r));  return 0;}static int monitorEESStatusRead (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  U8 status;  m25lc_e r;  if (monitorEESuIPCheck ())    return 0;  if ((r = m25lc512StatusRead (&status)) != M25LC_OK)    printf ("m25lc512StatusRead() returned error %d/%s\n", r, m25lc512Strerror (r));  else    printf ("Status = 0x%02x (%d)\n", status, status);  return 0;}static int monitorEESStatusWrite (int argc __attribute__ ((unused)), portCHAR **argv){  unsigned int status;  m25lc_e r;  if (monitorEESuIPCheck ())    return 0;  if (!getNumber (argv [0], &status))    return 0;  if (status > 255)    printf ("Error: status must be 0x00..0xff (0..255)\n");  else if (monitorEESWriteGate () == M25LC_OK)    if ((r = m25lc512StatusWrite (status)) != M25LC_OK)      printf ("m25lc512StatusWrite() returned error %d/%s\n", r, m25lc512Strerror (r));  return 0;}#endif#ifdef CFG_FIQ//////static int monitorFIQClear (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  fiqClearCount ();  return 0;}static int monitorFIQCount (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  printf ("FIQ counter = %u\n", fiqGetCount ());  return 0;}static int monitorFIQOff (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  printf ("FIQ interrupts disabled, previous state was %s\n", fiqDisable () ? "enabled" : "disabled");  return 0;}static int monitorFIQOn (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  printf ("FIQ interrupts enabled, previous state was %s\n", fiqEnable () ? "enabled" : "disabled");  return 0;}#endif#ifdef CFG_FATFS//////static int monitorFileChmod (int argc __attribute__ ((unused)), portCHAR **argv){  mode_t mode;  if (!strcmp (argv [0], "-w"))    mode = 0;  else if (!strcmp (argv [0], "+w"))    mode = S_IWUSR;  else  {    printf ("mode must be +w (writable) or -w (not writable)\n");    return 0;  }  if (chmod (argv [1], mode) == -1)    printf ("chmod() failed, errno=%d/%s\n", errno, strerror (errno));  return 0;}static int monitorFileConcat (int argc __attribute__ ((unused)), portCHAR **argv){  int fd1st;  int fd2nd;  int l;  char buffer [128];  if ((fd1st = open (argv [0], O_RDONLY)) == -1)  {    printf ("Cannot open 1st file \"%s\", errno=%d/%s\n", argv [0], errno, strerror (errno));    return 0;  }  if ((fd2nd = open (argv [1], O_WRONLY + O_CREAT + O_APPEND)) == -1)  {    printf ("Cannot open 2nd file \"%s\", errno=%d/%s\n", argv [1], errno, strerror (errno));    return 0;  }  while ((l = read (fd1st, buffer, sizeof (buffer))))  {    if (write (fd2nd, buffer, l) != l)    {      printf ("write() returned error %d/%s (l=%d)\n", errno, strerror (errno), l);      break;    }  }  close (fd1st);  close (fd2nd);  return 0;}static int monitorFileCp (int argc __attribute__ ((unused)), portCHAR **argv){  int fdIn;  int fdOut;  int l;  char buffer [128];  if ((fdIn = open (argv [0], O_RDONLY)) == -1)  {    printf ("Cannot open input file \"%s\", errno=%d/%s\n", argv [0], errno, strerror (errno));    return 0;  }  if (argc == 1)  {    fdOut = fileno (stdout);    fflush (stdout);  }  else if ((fdOut = open (argv [1], O_CREAT | O_TRUNC | O_WRONLY)) == -1)  {    printf ("Cannot open output file \"%s\", errno=%d/%s\n", argv [1], errno, strerror (errno));    close (fdIn);    return 0;  }  while ((l = read (fdIn, buffer, sizeof (buffer))))  {    if (write (fdOut, buffer, l) != l)    {      printf ("write() returned error %d/%s (l=%d)\n", errno, strerror (errno), l);      break;    }  }  close (fdIn);  if (fdOut != fileno (stdout))    close (fdOut);  return 0;}static int monitorFileCpCon (int argc __attribute__ ((unused)), portCHAR **argv){  int fdOut;  char c;  if ((fdOut = open (argv [0], O_CREAT | O_TRUNC | O_WRONLY)) == -1)  {    printf ("Cannot open output file \"%s\", errno=%d/%s\n", argv [0], errno, strerror (errno));    return 0;  }  while (read (fileno (stdin), &c, sizeof (c)))  {    if (c == 0x04)      break;    if (c == '\r')      c = '\n';    if (write (fdOut, &c, sizeof (c)) != sizeof (c))    {      printf ("write() returned error %d/%s\n", errno, strerror (errno));      break;    }    printf ("%c", c);    fflush (stdout);  }  if (close (fdOut) == -1)    printf ("close() returned error %d/%s\n", errno, strerror (errno));  return 0;}static int monitorFileDf (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  U32 p2;  FATFS *fs;  char buffer [100];  FRESULT res;  int acc_size;  int acc_files;  int acc_dirs;  if ((res = f_getfree ("", (U32 *) &p2, &fs)))  {     f_printerror (res);     return 0;  }  printf ("FAT type = %u\nBytes/Cluster = %u\nNumber of FATs = %u\n"      "Root DIR entries = %u\nSectors/FAT = %u\nNumber of clusters = %u\n"      "FAT start (lba) = %u\nDIR start (lba,clustor) = %u\nData start (lba) = %u\n",      fs->fs_type, fs->sects_clust * 512, fs->n_fats,      fs->n_rootdir, fs->sects_fat, fs->max_clust - 2,      fs->fatbase, fs->dirbase, fs->database      );  acc_size = acc_files = acc_dirs = 0;  buffer [0] = '\0';  if ((res = scan_files (buffer, &acc_size, &acc_files, &acc_dirs)))  {     f_printerror (res);     return 0;  }  printf ("\n%u files, %u bytes.\n%u folders.\n"      "%u bytes total disk space.\n%u bytes available\n",      acc_files, acc_size, acc_dirs,      (fs->max_clust - 2) * fs->sects_clust * 512, p2 * fs->sects_clust * 512      );  return 0;}static int monitorFileInit (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  printf ("RRC=%d\n", diskInitialize (0));  return 0;}static int monitorFileLs (int argc, portCHAR **argv){  DIR dir;  FRESULT res;  U32 size;  U16 files;  U16 dirs;  FATFS *fs;  char *path;  path = argc ? argv [0] : "";  if ((res = f_opendir (&dir, path)))  {     f_printerror (res);     return 0;  }  for (size = files = dirs = 0;;)  {    if (((res = f_readdir (&dir, &fileInfo)) != FR_OK) || !fileInfo.fname [0])       break;    if (fileInfo.fattrib & AM_DIR)       dirs++;    else     {      files++;       size += fileInfo.fsize;    }    printf ("\n%c%c%c%c%c %u/%02u/%02u %02u:%02u %9u  %s",        (fileInfo.fattrib & AM_DIR) ? 'D' : '-',        (fileInfo.fattrib & AM_RDO) ? 'R' : '-',        (fileInfo.fattrib & AM_HID) ? 'H' : '-',        (fileInfo.fattrib & AM_SYS) ? 'S' : '-',        (fileInfo.fattrib & AM_ARC) ? 'A' : '-',        (fileInfo.fdate >> 9) + 1980, (fileInfo.fdate >> 5) & 15, fileInfo.fdate & 31,        (fileInfo.ftime >> 11), (fileInfo.ftime >> 5) & 63,        fileInfo.fsize, &(fileInfo.fname [0]));  }  printf ("\n%4u File(s),%10u bytes\n%4u Dir(s)", files, size, dirs);  if (f_getfree (path, (U32 *) &size, &fs) == FR_OK)    printf (", %10uK bytes free", size * fs->sects_clust / 2);  printf ("\n");  return 0;}static int monitorFileMkdir (int argc __attribute__ ((unused)), portCHAR **argv){  f_printerror (f_mkdir (argv [0]));  return 0;}static int monitorFileMkfs (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  f_printerror (f_mkfs (0, 0, 64));  return 0;}static int monitorFileMount (int argc __attribute__ ((unused)), portCHAR **argv __attribute__ ((unused))){  f_printerror (f_mount (0, &fatfs));  return 0;}static int monitorFileMv (int argc __attribute__ ((unused)), portCHAR **argv){  if (rename (argv [0], argv [1]) == -1)    printf ("rename failed, errno=%d/%s\n", errno, strerror (errno));  return 0;}static int monitorFileRmCommon (char *path, int mode){  FRESULT f;  if ((f = f_stat (path, &fileInfo)) != FR_OK)  {    f_printerror (f);    return 0;  }  if (mode == AM_DIR)  {    if (!(fileInfo.fattrib & AM_DIR))      printf ("Not a directory\n");    else      f_printerror (f_unlink (pa

⌨️ 快捷键说明

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