亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fat.c

?? 用ATmega8 做的MP3播放器
?? C
?? 第 1 頁 / 共 2 頁
字號:
// gets part of a file
// this function is dumb and does not check for errors.
// dont use on its own
// used by fget & co.
void fat_get_file_section(FILE *stream, u16 size, u08 *data)
{ // determine the sector that we need to read and which dword defines our  next cluster address
  u16 myh = stream->file_current_clusterh;
  u16 myl = stream->file_current_clusterl;
  u08 i   = 0;

  myl += first_data_sectorl;
  if(myl < first_data_sectorl) myh++;
  // get the data
  MMC_get_part_sec_start(myh, myl,stream->file_offset,size);
  for(;i<size;i++) data[i] = MMC_get_sec_next();
  MMC_get_sec_stop();
  // fine
};


// used to get info from the current directoy
// modes :
//  FAT_FILENAME - 0x02 - find file by name
//  FAT_DIRNAME - 0x03 - find dir by name
//  FAT_FILENUM - 0x04 - find file by number 0 based
//  FAT_DIRNUM - 0x05 - find dir by number 0 based

bool fat_dir_ctl(u08 mode, FILE *stream, DIR *dir, u08* name, u08 count)
{
  // the sector that we are on
  u16 myhfat;
  u16 mylfat;
  u16 myh;
  u16 myl;
  u08 mysec = 0;
  // how many files/dirs were foud
  u08 index = 0;
  // is there data worth looking for in another sector ?
  u08 loop = 1;
  // how many entries were read from this sector
  u08 len = 0;

  myhfat = directory.dir_currenth;
  mylfat = directory.dir_currentl;

  do
  { myl = mylfat;
    myh = myhfat;

    // calc cluster to sectors
    cluster_to_sector(&myh, &myl);

    // add Data section offset
    myl += first_data_sectorl+mysec;
    if(myl < first_data_sectorl) myh++;

    // start getting the data from the mmc
    MMC_get_sec_start(myh, myl);
    // there are 16 directory entries in each directory sector
    // checkout the msdoc of fat for info
    len = 0;
    while (len < 16)
    { u08 tmp[32];
      u08 i;
      // get next entry
      for(i =0; i< 32; i++)
        tmp[i] = MMC_get_sec_next();

      if(tmp[0] == 0x00) loop = 0; // no more directory entries

      // make sure that there is an entry and that we want to process it and that it is valid
      if((tmp[0] > 0x0) && (tmp[0] != 0xE5))
      { // check if this is a long dir entry
        if ((tmp[11]&FAT_LONG_NAME) == FAT_LONG_NAME)
        {
#ifdef LFN_SUPPORT
          // is this the first entry
          if(tmp[0] > 0x40)
          { tmp[0]-= 0x40;
            for(tmp[2] = 0; tmp[2] < 13*LFN_MAX_BLOCK; tmp[2]++)
            { lfn_tmp[tmp[2]] = 0x00;
            };
          };
          if(tmp[0] <= LFN_MAX_BLOCK)
          { // we can use a unicode 0 as a tmp var
            tmp[2] = (tmp[0] - 1) * 13;
            for(i=1; i<10; i+=2)
            { lfn_tmp[tmp[2]++] = tmp[i];
            };
            for(i=14; i<31; i+=2)
            { if(i != 26) lfn_tmp[tmp[2]++] = tmp[i];
            };
          };
#endif
        }
        // check if it is a file
        else if(((tmp[11]&(FAT_DIRECTORY|FAT_VOL_ID)) == 0x00))
        { // do we want to print ?
          if(mode == FAT_PRINT)
          { /*
            printf("Filename: '");
            for(i=0; i<11; i++)
            { if(tmp[i] != ' ')
                printf("%c", tmp[i]);
              if(i==7) printf(".");
            }
            printf("'\n");
            */
          }
          else if((mode == FAT_FILENUM)&&(loop))
          { // is this the file we are looking for ?
            if(index == count)
            { // check if we are supposed to use a mask
              if(name)
              { if(fat_cmp_names(tmp, name, &name[8]))
                { fat_load_file_ptr(tmp, stream);
                  loop = 0;
                };
              }
              else
              { fat_load_file_ptr(tmp, stream);
                loop = 0;
              };
            }
            else
            { if(!name)
              { index++;
              }
              else
              { if(fat_cmp_names(tmp, name, &name[8]))
                { index++;
                };
              }
            };
          }
          else if(mode == FAT_FILENAME)
          { if(fat_cmp_names(tmp, name, &name[8]))
            { fat_load_file_ptr(tmp, stream);
              loop = 0;
            };
          };
#ifdef LFN_SUPPORT
          lfn_tmp[0] = 0x00;
#endif
        // check if this is a volume id
        }
        else if((tmp[11]&FAT_VOL_ID)==FAT_VOL_ID)
        { /*
            printf("Vol-ID: '");
            for(i=0; i<11; i++)
            { if(tmp[i] != ' ')
                printf("%c", tmp[i]);
            }
            printf("'\n");
          */
        }
        // check if this is a pointer to another directory
        else if ((tmp[11]&FAT_DIRECTORY)==FAT_DIRECTORY)
        { // do we want to print ?
          //printf("Entry is a dir\n");
          if(mode == FAT_PRINT)
          { /*
            printf("Dirname: '");
            for(i=0; i<11; i++)
            { if(tmp[i] != ' ')
                printf("%c", tmp[i]);
              if(i==7) printf(".");
            }
            printf("'\n");
            */
          }
          else if((mode == FAT_DIRNUM)&&(loop))
          { // is this the file we are looking for ?
            if(index == count)
            { // check if we are supposed to use a mask
              if(name)
              { if(fat_cmp_names(tmp, name, 0x00))
                { fat_load_dir_ptr(tmp, dir);
                  loop = 0;
                };
              }
              else
              { fat_load_dir_ptr(tmp,dir);
                loop = 0;
              };
            }
            else
            { if(!name)
              { index++;
              }
              else
              { if(fat_cmp_names(tmp, name, 0x00))
                { index++;
                };
              }
            };
          }
          else if((mode == FAT_DIRNAME)&&(loop))
          { if(fat_cmp_names(tmp, name, 0x00))
            { fat_load_dir_ptr(tmp, dir);
              loop = 0;
            };
          };
#ifdef LFN_SUPPORT
          lfn_tmp[0] = 0x00;
#endif
        };

      };
      // inc loop counter
      len++;
      //getch();
    };
    // stop the reading process+
    MMC_get_sec_stop();

    if (mysec < sec_per_clus-1)
      mysec++;
    else
    { FAT_get_next_clus_addr(&myhfat, &mylfat);
      mysec=0;
    }

    //loop = 0;
  } while((myhfat!=0x0fff)&&(mylfat!=0xfffd)&&(loop));

  // if we just did some directory listing, we always return true
  if(mode == FAT_DIRNAME)
    return true;

  // we were looking for some file/directory. if loop is true, no data was found
  if(loop)
    return false;

  return true;
};

/*------------------ FIO API LAYER --------------*/

// only the 'r' mode is supported so far
bool fopen(u08 *filename, u08 mode, FILE *stream)
{ if(mode=='r')
    return fat_dir_ctl(FAT_FILENAME, stream, 0x00, filename, 0);
  return false;
};

// only the 'r' mode is supported so far
bool fopenc(u08 count, u08 mode, u08 *mask, FILE *stream)
{ if(mode=='r')
    return fat_dir_ctl(FAT_FILENUM, stream, 0x00, mask, count);
  return false;
};

// closes a filestream this is not really neccesarry, but alot tidier
void fclose(FILE *stream)
{ stream->file_first_clusterl =
  stream->file_first_clusterh =
  stream->file_current_clusterl =
  stream->file_current_clusterh =
  stream->file_current_sector =
  stream->file_sizel =
  stream->file_sizeh =
  stream->file_offset = 0x00;
};



// has the end of the file been reached ?
bool feof(FILE *stream)
{ return (stream->file_current_clusterh==0x0fff) &&
          (stream->file_current_clusterl>=0xfff8);
};

// checks if a file is open
bool fisopen(FILE *stream)
{ return (stream->file_first_clusterl == 0x00) &&
          (stream->file_first_clusterh == 0x00) &&
          (stream->file_current_clusterl == 0x00) &&
          (stream->file_current_clusterh == 0x00) &&
          (stream->file_current_sector == 0x00) &&
          (stream->file_sizel == 0x00) &&
          (stream->file_sizeh == 0x00) &&
          (stream->file_offset == 0x00);
};

// gets data from a file
u08* fget(FILE *stream, u16 size)
{ // make sure the FILE is open
  if((stream->file_current_clusterh==0x0)&&(stream->file_current_clusterl==0x0)) return 0x00;
  // are we at the end of a sector ?
  if(stream->file_offset == 0x200)
  { // load next sector
    if (stream->file_current_sector >= sec_per_clus-1)
    { FAT_get_next_clus_addr(&stream->file_current_clusterh, &stream->file_current_clusterl);
      if(feof(stream)) return 0x00;
      stream->file_current_sector = 0;
    }
    else
    { stream->file_current_sector++;
    }
    stream->file_offset = 0x00;
  }
  // make sure we are not reading in more than the max data buffer
  if(size > FAT_RD_BUF_SIZE) size = FAT_RD_BUF_SIZE;
  // make sure we are not reading past the end of a file
  if((stream->file_sizeh == 0) && (stream->file_sizel < size)) size = stream->file_sizel;

  // is all the data in this sector? or do we have to split over two sectors
  if((stream->file_offset+size) < 0x200)
  { // all in one
    fat_get_file_section(stream, size, fat_buf);
    stream->file_offset += size;
  }
  else
  { // workout where we need to split
    u08 split_pos = 0x200 - stream->file_offset;
    size -= split_pos;
    // get first half
    fat_get_file_section(stream, split_pos, fat_buf);
    // get second half
    if (stream->file_current_sector >= sec_per_clus-1)
    { FAT_get_next_clus_addr(&stream->file_current_clusterh, &stream->file_current_clusterl);
      stream->file_current_sector = 0;
    }
    else
    { stream->file_current_sector++;
    }
    fat_get_file_section(stream, size, &fat_buf[split_pos]);
    stream->file_offset = size;
    size += split_pos;
  };
  // update the stream struct
  if(stream->file_sizel < size)
  { // save as we checked for zero earlier
    stream->file_sizeh--;
  };
  stream->file_sizel = size - stream->file_sizel;

  fat_buf[size] = '\0';
  return fat_buf;
};

bool fplay_sector(FILE *stream)
{ u16 myh = stream->file_current_clusterh;
  u16 myl = stream->file_current_clusterl;

  // make sure the FILE is open
  if((stream->file_current_clusterh==0x0)&&(stream->file_current_clusterl==0x0)) return false;
  // make sure, that we are not past the last cluster of the file
  if((stream->file_current_clusterh==0x0fff)&&(stream->file_current_clusterl>=0xfff8)) return false;

  cluster_to_sector(&myh, &myl);

  myl += first_data_sectorl;
  if(myl < first_data_sectorl) myh++;

  u16 length;
  u08 tmp;
  u08 sec;

  for(sec=0; sec<sec_per_clus; sec++)
  { // start getting the data
    MMC_get_sec_start(myh, myl);
    length=0;
    tmp = spi_io(0xff);
    // disable the MMC to receive data
    MMC_disable();
    while(length<512)
    { if((512%32) == 0) VS1001_WHILE_NEEDS_NO_DATA;
      VS_BSYNC_HI;
      outp(tmp, SPDR);    // send data
      NOP;
      NOP;
      NOP;
      VS_BSYNC_LO;
      // wait for data to be sent
      while(((inp(SPSR))&(1<<SPIF))== 0x00){};
      tmp = inp(SPDR);
      length++;
    };
    // enables the MMC to receive data again
    MMC_enable();
    // get the 2nd CRC bytes
    spi_io(0xff);
    // give enough time
    MMC_cleanup();
    myl++;
    if (myl==0) myh++;
  }
  FAT_get_next_clus_addr(&stream->file_current_clusterh, &stream->file_current_clusterl);
  return true;
};


// step into a subfolder of the current folder
// if dirname is null function sets the root folder
bool dir_enter(u08 *dirname, DIR *dir)
{ if(!dir) dir = &directory;
  // set a folder
  if(dirname)
  { return fat_dir_ctl(FAT_DIRNAME, 0x00, dir, dirname, 0);
  }
  //set root folder ?
  else
  { dir_root(dir);
    return true;
  };
}

// step into a subfolder of the current folder
bool dir_leave(DIR *dir)
{ u08 tmp[9] = "..      ";
  return dir_enter(tmp, dir);
};

// list the current directory
void dir_list(DIR *dir)
{ if(!dir) dir = &directory;
  fat_dir_ctl(FAT_PRINT, 0x00, 0x00, 0x00, 0);
}

// sets the dir to root
void dir_root(DIR *dir)
{ if(!dir) dir = &directory;
  dir->dir_currentl = 0x00;
  dir->dir_currenth = 0x00;
};

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人网在线免费视频| 亚洲r级在线视频| 亚洲猫色日本管| 婷婷一区二区三区| 精品一区二区在线看| 成人动漫一区二区在线| 在线观看免费亚洲| 精品国精品国产尤物美女| 国产精品乱人伦中文| 亚洲国产精品久久人人爱蜜臀| 免费在线视频一区| 成人免费av资源| 欧美精品v国产精品v日韩精品| 久久人人爽人人爽| 亚洲国产欧美另类丝袜| 国产精品99久久久久久久vr| 在线观看国产日韩| 国产午夜精品福利| 亚洲成人7777| 成人午夜视频在线观看| 在线不卡一区二区| 国产精品久久影院| 免费观看成人av| 日本韩国一区二区| 久久精品网站免费观看| 亚洲a一区二区| 成人激情综合网站| 91精品国产手机| 综合在线观看色| 国产自产视频一区二区三区| 欧美性色黄大片| 中文字幕精品一区二区精品绿巨人| 日韩中文字幕不卡| 91麻豆免费在线观看| 2020国产精品自拍| 五月天中文字幕一区二区| 波多野结衣在线一区| 欧美成人乱码一区二区三区| 亚洲精品久久7777| 懂色av一区二区三区免费观看| 欧美日韩精品是欧美日韩精品| 国产精品成人在线观看| 狠狠色丁香婷综合久久| 911国产精品| 亚洲人成在线播放网站岛国| 成人小视频在线| 久久先锋资源网| 青青草原综合久久大伊人精品优势| 色综合久久中文字幕| 国产精品人妖ts系列视频| 国产一区二区三区日韩| 欧美一区二区三区精品| 亚洲成人激情av| 色先锋资源久久综合| 国产精品私人自拍| 国产91精品在线观看| 精品国产乱码久久久久久图片| 亚洲18女电影在线观看| 色女孩综合影院| 综合在线观看色| 不卡一区二区三区四区| 日本一区二区综合亚洲| 狠狠色综合播放一区二区| 欧美成人a在线| 日韩精品一二三| 欧美日韩另类国产亚洲欧美一级| 一区二区三区中文字幕| 一本到不卡精品视频在线观看| 亚洲欧美自拍偷拍色图| 成人av在线播放网址| 国产欧美一区二区精品久导航| 老司机午夜精品| 日韩欧美一二区| 久久er精品视频| 精品国产91亚洲一区二区三区婷婷| 蜜桃视频第一区免费观看| 欧美一区日韩一区| 美女视频黄a大片欧美| 日韩精品一区二区三区在线 | 成人午夜短视频| 国产亚洲一区二区三区在线观看| 国产伦精品一区二区三区免费迷 | 久久精品国产成人一区二区三区 | 激情国产一区二区| 欧美一区二区三区电影| 九九九精品视频| 国产午夜久久久久| 成人黄色电影在线| 亚洲人成伊人成综合网小说| 在线观看免费亚洲| 日韩av在线免费观看不卡| 日韩精品一区二区三区在线| 国产精品一区二区x88av| 国产嫩草影院久久久久| 91福利社在线观看| 日韩电影免费一区| 久久欧美一区二区| 99精品国产99久久久久久白柏| 一区二区三区日本| 日韩欧美一区二区三区在线| 国产一区二区h| 中文字幕一区二区在线播放| 在线日韩一区二区| 日本成人在线一区| 欧美国产丝袜视频| 在线亚洲+欧美+日本专区| 丝袜亚洲另类欧美| 国产视频一区二区在线| 91美女精品福利| 美女高潮久久久| 久久一日本道色综合| 97精品久久久久中文字幕| 三级欧美韩日大片在线看| 337p日本欧洲亚洲大胆精品| av资源站一区| 日本va欧美va瓶| 国产精品久久久久久久久图文区| 欧美视频日韩视频在线观看| 麻豆国产欧美日韩综合精品二区| 国产欧美视频一区二区三区| 欧美在线一区二区三区| 久久99精品久久久久久| 亚洲精品videosex极品| 日韩精品在线一区二区| 91在线精品一区二区| 日韩国产在线一| 国产精品每日更新| 欧美一级淫片007| www.av精品| 麻豆久久一区二区| 亚洲欧美日韩一区二区三区在线观看| 88在线观看91蜜桃国自产| 成人在线综合网| 日本va欧美va瓶| 一区二区三区四区高清精品免费观看 | 国产成人午夜精品影院观看视频| 美女一区二区视频| 国产精品综合视频| av亚洲精华国产精华精| 欧美网站大全在线观看| 9191成人精品久久| 亚洲色图在线视频| 亚洲免费观看高清完整版在线观看| 欧美精品一二三四| av在线综合网| 狠狠色丁香久久婷婷综合丁香| 亚洲国产精品久久久久婷婷884 | 精品一二三四区| 一区二区国产盗摄色噜噜| 国产欧美日韩综合精品一区二区| 欧美一区二区三区免费观看视频| 在线看不卡av| 成人黄色av电影| 国产一区二区三区免费观看 | 欧美电影免费观看高清完整版在 | 亚洲精品成人悠悠色影视| 国产日本欧洲亚洲| 日韩免费高清电影| 欧美日韩一级大片网址| 91蜜桃免费观看视频| 丰满亚洲少妇av| 美日韩黄色大片| 日韩在线一区二区三区| 亚洲国产三级在线| 亚洲欧美日韩在线播放| 一区二区中文视频| 国产精品嫩草影院av蜜臀| 久久久久久久久久久电影| 欧美一级二级在线观看| 在线播放国产精品二区一二区四区 | 精品日韩一区二区三区| 欧美一级高清大全免费观看| 67194成人在线观看| 欧美伦理影视网| 欧美三日本三级三级在线播放| 在线观看日韩电影| 欧美在线制服丝袜| 欧美色老头old∨ideo| 欧美午夜一区二区三区 | 日韩av中文字幕一区二区三区| 亚洲午夜一二三区视频| 亚洲精品视频自拍| 依依成人精品视频| 一区二区三区在线免费| 夜夜精品浪潮av一区二区三区| 亚洲激情六月丁香| 亚洲综合在线电影| 亚洲亚洲人成综合网络| 午夜久久久影院| 日韩高清电影一区| 蜜臀av在线播放一区二区三区| 美女网站视频久久| 国产一区二区三区电影在线观看| 国产一区美女在线| 丁香婷婷综合五月| av在线播放不卡| 在线视频你懂得一区| 欧美日韩色一区| 日韩一区二区在线观看视频播放| 日韩美女一区二区三区|