<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 將FATFS移植STM32RBT6遇到的掛載不成功和返回值問題

          將FATFS移植STM32RBT6遇到的掛載不成功和返回值問題

          作者: 時間:2016-11-27 來源:網(wǎng)絡 收藏
          移植fatfs遇到了諸多問題,很是苦惱啊,移植成功思來之不易,特分享一下經(jīng)驗。硬件是STM32F103RBT6內(nèi)存只有20kB,Flash只有128KB,考慮到內(nèi)存有限,就不能支持長文件名了,在原子論壇上下載的所以要改動,在此感謝原子論壇給我?guī)淼膸椭€有安富萊論壇http://bbs.armfly.com/read.php?tid=3601給我?guī)淼膯⑹?。另外硬件還有一個大的相機的SD卡,網(wǎng)上買的模塊當然也可以自己焊接一個,采用SPI接口,SPI1和SPI2都行,看圖

          本文引用地址:http://www.ex-cimer.com/article/201611/322305.htm

          移植前做了大量準備,在網(wǎng)上尤其是原子論壇翻看各種其他人移植的心得,去fatfs的官方網(wǎng)站下載0.10版本的程序,看各種相關(guān)的移植心得,文檔版本眾多,眼花繚亂,花了點時間看了看一些函數(shù)。看得差不多了,就直接把0.10的版本考到自己的工程目錄下開始make,經(jīng)過大量的翻閱和實踐,要動的地方只有diskio.c和ffconfig.h,第一個需要把底層驅(qū)動函數(shù)sd_inti();添加進去。sd卡的讀單塊和讀多塊,寫單塊寫多塊填進去,ffconfig.h里邊需要改幾個宏定義的值參照別人的例程就可以實現(xiàn)很簡單。

          DSTATUS disk_initialize (
          BYTE drv/* Physical drive nmuber (0..) */
          )
          {


          u8 state;
          state=SD_Init();
          if(!state){
          return STA_NODISK;
          }
          return 0;
          }

          /*-----------------------------------------------------------------------*/
          /* Return Disk Status */

          DSTATUS disk_status (
          BYTE drv/* Physical drive nmuber (0..) */
          )
          {return 0;
          }

          /*-----------------------------------------------------------------------*/
          /* Read Sector(s) */

          DRESULT disk_read (
          BYTE drv,/* Physical drive nmuber (0..) */
          BYTE *buff,/* Data buffer to store read data */
          DWORD sector,/* Sector address (LBA) */
          BYTE count/* Number of sectors to read (1..255) */
          )
          {
          u8 res=0;


          if(count==1) //1個sector的讀操作
          {
          res = SD_ReadSingleBlock(sector, buff);
          //res= SD_ReadDisk(buff,sector,count);
          }
          else //多個sector的讀操作
          {
          res = SD_ReadMultiBlock(sector, buff, count);
          }

          //處理返回值,將SPI_SD_driver.c的返回值轉(zhuǎn)成ff.c的返回值
          if(res == 0x00)
          {
          return RES_OK;
          }
          else
          {
          return RES_ERROR;
          }
          }

          /*-----------------------------------------------------------------------*/
          /* Write Sector(s) */

          #if _READONLY == 0
          DRESULT disk_write (
          BYTE drv,/* Physical drive nmuber (0..) */
          const BYTE *buff,/* Data to be written */
          DWORD sector,/* Sector address (LBA) */
          BYTE count/* Number of sectors to write (1..255) */
          )
          {
          u8 res;

          // 讀寫操作
          if(count == 1)
          {
          res = SD_WriteSingleBlock(sector, buff);;
          }
          else
          {
          res = SD_WriteMultiBlock(sector, buff, count);
          }
          // 返回值轉(zhuǎn)換
          if(res == 0)
          {
          return RES_OK;
          }
          else
          {
          return RES_ERROR;
          }
          }
          #endif /* _READONLY */


          上一頁 1 2 下一頁

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();