chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

電子發(fā)燒友App

硬聲App

掃碼添加小助手

加入工程師交流群

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>帶有RT-Thread的更好的SD庫

帶有RT-Thread的更好的SD庫

2023-06-14 | zip | 0.00 MB | 次下載 | 免費(fèi)

資料介紹

描述

背景

Arduino IDE 附帶的 SD 庫很方便,但缺少 exFAT、LFN(長文件名)和非英文字符支持等功能。本文介紹了一種替代 SD 卡驅(qū)動程序(基于 RT-Thread)來解決這些問題。

RT-線程

RT-Thread是一個免費(fèi)的開源(Apache 許可證 2.0)RTOS,并以 Arduino 庫的形式提供。還有另一篇文章 ( Multitasking on Arduino ) 可用于了解 RT-Thread 的基本概念。

讓我們從通過 Arduino IDE 的庫管理器安裝庫開始。(本文基于 RT-Thread 庫版本 0.4.4 。)

SD 卡驅(qū)動程序 (TL;DR)

(如果您對實(shí)現(xiàn)不感興趣,只想知道如何使用它,請?zhí)^本節(jié)。)

RT-Thread 庫中的 SD 卡支持采用DFS(設(shè)備文件系統(tǒng))的形式,它是 RT-Thread 架構(gòu)的一部分。FAT 是 RT-Thread 支持的文件系統(tǒng)之一。(在 RT-Thread 庫的 0.4.4 版本中,F(xiàn)AT 是唯一支持的文件系統(tǒng)。)

FAT DFS 本??身就是基于ChaN 的 FatFs 項目的優(yōu)秀作品。

標(biāo)準(zhǔn)的 RT-Thread DFS 提供以下文件系統(tǒng)和文件接口

/* File system operations */
struct dfs_filesystem_ops
{
   const char *name;
   uint32_t flags;      /* flags for file system operations */
   /* operations for file */
   const struct dfs_file_ops *fops;
   /* mount and unmount file system */
   int (*mount)    (struct dfs_filesystem *fs, unsigned long rwflag, const void *data);
   int (*unmount)  (struct dfs_filesystem *fs);
   /* make a file system */
   int (*mkfs)     (rt_device_t devid);
   int (*statfs)   (struct dfs_filesystem *fs, struct statfs *buf);
   int (*unlink)   (struct dfs_filesystem *fs, const char *pathname);
   int (*stat)     (struct dfs_filesystem *fs, const char *filename, struct stat *buf);
   int (*rename)   (struct dfs_filesystem *fs, const char *oldpath, const char *newpath);
};
/* File operations */
struct dfs_file_ops
{
   int (*open)     (struct dfs_fd *fd);
   int (*close)    (struct dfs_fd *fd);
   int (*ioctl)    (struct dfs_fd *fd, int cmd, void *args);
   int (*read)     (struct dfs_fd *fd, void *buf, size_t count);
   int (*write)    (struct dfs_fd *fd, const void *buf, size_t count);
   int (*flush)    (struct dfs_fd *fd);
   int (*lseek)    (struct dfs_fd *fd, off_t offset);
   int (*getdents) (struct dfs_fd *fd, struct dirent *dirp, uint32_t count);
   int (*poll)     (struct dfs_fd *fd, struct rt_pollreq *req);
}

一個特定的 DFS 可能會實(shí)現(xiàn)它們的全部或部分。當(dāng)掛載DFS時,例如dfs_mount("SD", "/", "elm", 0, 0),特定的DFS會綁定到一個設(shè)備上。在這種情況下,DFS "elm" (FatFs) 綁定到設(shè)備 "SD"。

標(biāo)準(zhǔn)的 RT-Thread 設(shè)備提供以下接口:

/* operations set for device object */
struct rt_device_ops
{
   /* common device interface */
   rt_err_t  (*init)   (rt_device_t dev);
   rt_err_t  (*open)   (rt_device_t dev, rt_uint16_t oflag);
   rt_err_t  (*close)  (rt_device_t dev);
   rt_size_t (*read)   (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
   rt_size_t (*write)  (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
   rt_err_t  (*control)(rt_device_t dev, int cmd, void *args);
};

一個特定的設(shè)備可以實(shí)現(xiàn)它們的全部或全部(將函數(shù)指針設(shè)置為 NULL)。

在庫中,名為“SD”的設(shè)備實(shí)現(xiàn)了與SD卡訪問相關(guān)的功能,在MKRZERO板的情況下,它涉及到一個名為“SPI1”的低級設(shè)備。而 SPI 設(shè)備最終涉及到了 Arduino SPI 庫。

數(shù)據(jù)記錄器示例

Arduino SD 庫提供了一個名為“Datalogger”的示例。RT-Thread 庫中也提供了相同的示例,如下面的代碼部分所列。

不同之處在于,在下面的示例代碼中,采樣間隔為 1 秒,并且只執(zhí)行 10 次。

您可能已經(jīng)注意到上面的注釋open()功能。要打開現(xiàn)有文件并刪除其所有內(nèi)容,只需O_APPENDO_TRUNC標(biāo)志替換即可。

當(dāng)使用 MKRZERO 板運(yùn)行以下示例時,您可能會觀察到串行監(jiān)視器的以下輸出

\ | /
- RT -     Thread Operating System
/ | \     4.0.1 build Apr 17 2019
2006 - 2019 Copyright by rt-thread team
+ Mount SD to "/"
416,347,312
finsh />436,369,335
442,375,340
449,376,338
449,375,346
429,374,341
447,369,342
449,363,338
426,363,334
419,353,327

使用 Shell 進(jìn)行操作

使用 RT-Thread 庫的真正優(yōu)勢在于它使您能夠使用 (FinSH) shell 命令來操作文件。

串行監(jiān)視器或其他串行終端工具中,輸入ls()命令將顯示當(dāng)前目錄(在本例中為“/”)中的文件列表,如下所示。

ls()
Directory /:
DATALOG.TXT         240
HI_UTF8.TXT         35
A_REAL~1.TXT        22
       0, 0x00000000 

文件名后面的數(shù)字是以字節(jié)為單位的文件大小。在上面的屏幕截圖中,“datalog.txt”的大小為 240 字節(jié),因?yàn)槲疫\(yùn)行了該示例兩次。

輸入cat("datalog.txt")命令會顯示“datalog.txt”的內(nèi)容,確認(rèn)有20條記錄。

finsh />cat("datalog.txt")
464,358,333
464,368,336
480,381,354
447,364,346
443,363,340
441,365,343
463,371,345
467,374,313
447,364,345
465,369,346
416,347,312
436,369,335
442,375,340
449,376,338
449,375,346
429,374,341
447,369,342
449,363,338
426,363,334
419,353,327
       0, 0x00000000

還有copy()rm()命令。

finsh />copy("datalog.txt", "copy.txt")
       0, 0x00000000
finsh />ls()
Directory /:
COPY.TXT            240
DATALOG.TXT         240
HI_UTF8.TXT         35
A_REAL~1.TXT        22
       0, 0x00000000
finsh />rm("copy.txt")
       0, 0x00000000
finsh />ls()
Directory /:
DATALOG.TXT         240
HI_UTF8.TXT         35
A_REAL~1.TXT        22
       0, 0x00000000

要列出所有可用命令,請輸入list()。

finsh />list()
--Function List:
hello            -- say hello world
version          -- show RT-Thread version information
list             -- list available commands
list_mem         -- list memory usage information
list_thread      -- list thread
list_sem         -- list semaphore in system
list_mutex       -- list mutex in system
list_event       -- list event in system
list_mb          -- list mail box in system
list_mq          -- list message queue in system
list_memp        -- list memory pool in system
list_timer       -- list timer in system
list_dev         -- list device in system
mkfs             -- make a file system
df               -- get disk free
mkdir            -- create a directory
cd               -- change current working directory
ls               -- list directory contents
rm               -- remove files or directories
cat              -- print file content
copy             -- copy file or dir
list_sd          -- show SD information
--Variable List:
dummy            -- dummy variable for finsh
       0, 0x00000000

ExFAT、LFN 和非英文字符支持

默認(rèn)情況下不啟用 ExFAT、LFN(長文件名)和非英文字符支持(以使示例更?。?。在“ rtconfig.h ”(位于 RT-Thread 庫目錄中)中打開以下配置以啟用這些功能。

#define RT_DFS_ELM_USE_EXFAT
#define RT_DFS_ELM_USE_LFN              (2)
#define RT_DFS_ELM_MAX_LFN              (255)
#define RT_DFS_ELM_CODE_PAGE            936

RT_DFS_ELM_MAX_LFN表示文件名的最大長度,可以在 12 到 255 的范圍內(nèi)。

RT_DFS_ELM_CODE_PAGE默認(rèn)設(shè)置為 437 用于美國,更改為 936 將啟用簡體中文支持,如下所示。

finsh />ls()
Directory /:
DATALOG.TXT         240
hi_utf8.txt         35
a_really_long_file_name.txt22
      0, 0x00000000
finsh />cat("hi_utf8.txt")
Hello, world!
世界,你好!	0, 0x00000000

下一步

  • RT-Thread Primer(即將推出)

SD Arduino RT-Thread
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1耗盡型MOS FET產(chǎn)品目錄選型表
  2. 0.14 MB   |  2次下載  |  免費(fèi)
  3. 2TI系列-米爾TI AM62L核心板開發(fā)板-高能效低功耗嵌入式平臺
  4. 1.51 MB  |  次下載  |  免費(fèi)
  5. 3WILLSEMI韋爾20年半年度報告由代理分銷經(jīng)銷一級代理分銷經(jīng)銷
  6. 3.30 MB  |  次下載  |  免費(fèi)
  7. 4LRC 樂山無線電InTWSApplications家電由原廠代理分銷經(jīng)銷一級代理分銷經(jīng)銷供應(yīng)
  8. 85.84 KB  |  次下載  |  免費(fèi)
  9. 5LAT1596 一文說明白 STM32G4 雙 Bank 啟動與升級
  10. 0.64 MB   |  次下載  |  5 積分
  11. 6LAT1594_基于事件喚醒低功耗之介紹
  12. 0.37 MB   |  次下載  |  5 積分
  13. 7PT8P2309 觸控 A/D 型 8-Bit MCU規(guī)格書
  14. 4.05 MB   |  次下載  |  免費(fèi)
  15. 8PT8P2308 觸控 A/D 型 8-Bit MCU規(guī)格書
  16. 4.13 MB   |  次下載  |  免費(fèi)

本月

  1. 1美的電磁爐電路原理圖資料
  2. 4.39 MB   |  19次下載  |  10 積分
  3. 2反激式開關(guān)電源設(shè)計解析
  4. 0.89 MB   |  11次下載  |  5 積分
  5. 3耗盡型MOS FET產(chǎn)品目錄選型表
  6. 0.14 MB   |  2次下載  |  免費(fèi)
  7. 4簡易光伏控制器原理圖資料
  8. 0.07 MB   |  1次下載  |  5 積分
  9. 52EDL05x06xx系列 600V半橋門驅(qū)動器帶集成自舉二極管(BSD)手冊
  10. 0.69 MB   |  1次下載  |  免費(fèi)
  11. 6國產(chǎn)千兆網(wǎng)口芯片PT153S中文資料
  12. 1.35 MB   |  次下載  |  免費(fèi)
  13. 7斯丹電子 | 用于芯片測試系統(tǒng)的射頻干簧繼電器
  14. 5.11 MB  |  次下載  |  免費(fèi)
  15. 8SFI立昌ESD/TVS管原廠代理分銷經(jīng)銷一級代理分銷經(jīng)銷
  16. 294.76 KB  |  次下載  |  免費(fèi)

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935137次下載  |  10 積分
  3. 2開源硬件-PMP21529.1-4 開關(guān)降壓/升壓雙向直流/直流轉(zhuǎn)換器 PCB layout 設(shè)計
  4. 1.48MB  |  420064次下載  |  10 積分
  5. 3Altium DXP2002下載入口
  6. 未知  |  233095次下載  |  10 積分
  7. 4電路仿真軟件multisim 10.0免費(fèi)下載
  8. 340992  |  191448次下載  |  10 積分
  9. 5十天學(xué)會AVR單片機(jī)與C語言視頻教程 下載
  10. 158M  |  183360次下載  |  10 積分
  11. 6labview8.5下載
  12. 未知  |  81605次下載  |  10 積分
  13. 7Keil工具M(jìn)DK-Arm免費(fèi)下載
  14. 0.02 MB  |  73829次下載  |  10 積分
  15. 8LabVIEW 8.6下載
  16. 未知  |  65991次下載  |  10 積分