Exemplo n.º 1
0
void handle_sdcard()
{

  DEBUG_PUTS("[Card inserted]\n");

  if (sd_init())
    if (fatfs_mount())
      if (find_imgfile())
	if (imgfile_init()) {
	  set_disk_type(imgheader.disk_type);
	  PORTA = fatfs_filenumber;
	  fatfs_next_filename();
	} else {
	  fatfs_reset_filename();
	  PORTA = ~0;
	}

  while (SDCARD_INSERTED) {
    service_ide();
    service_cdda();
  }

  DEBUG_PUTS("[Card extracted]\n");
  cdda_stop();
  set_disk_type(0xff);
}
Exemplo n.º 2
0
int test_fatfs(void)
{
    int ret;
    uint8_t buf[1024];

    memset(buf, 0, 1024);

    ret = fatfs_mount(&fs);
    if (ret != 0) {
        bl_dbg("Failed mounting flash device.");
    }

    ret = fatfs_open(&fs, "CONFIG.INI");
    if (ret) {
        bl_dbg("Failed opening config file.");
    }
    ret = fatfs_read(&fs, buf, 1024);
    if (ret < 0) {
        bl_dbg("Failed reading data.");
    }
    buf[ret] = '\0';
    d_print("%s\r\n", buf);

    fatfs_close(&fs);

    fatfs_umount(&fs);

    bl_dbg("Done");
#if 0
    int k;
    for (i = 44; i < 8192; i++) {
        at45db_bread(i, 1, buf);
        for (k = 0; k < 1024; k++) {
            d_print("%c", buf[k]);
            wait(25);
        }
        d_print("Page: %d\r\n", i);
        wait(5000);
    }
#endif
    return 0;
}
Exemplo n.º 3
0
u08 picture_load(const char *filename, u08 x, u08 y)
{
  FIL fsrc;
  FRESULT res;
  u08 result = CMD_OK;
  
  // try to mount sd card
  if(fatfs_mount() !=0) {
    result = PIC_MOUNT_ERROR;
  }
  else {
    // open file
    res = f_open(&fsrc, filename, FA_OPEN_EXISTING | FA_READ);
    if(res == FR_OK)
    {
      // read header
      UINT read;
      res = f_read(&fsrc, &buf, BUF_SIZE, &read);
      if(res == FR_OK) {
        // parse header
        result = parse_header(buf, read);
        if(result == CMD_OK) {
          // prepare display
          u16 xp = x * 8;
          u16 yp = y * 8;          
          // load bitmap data
          result = load_data(&fsrc,xp,yp);
        }
      } else {
        result = PIC_READ_ERROR;
      }
      // close file
      f_close(&fsrc);
    }
  
    // unmount
    fatfs_umount();
  }
  return result;
}