FatFs

Started by tha, May 05, 2022, 10:00:40 AM

Previous topic - Next topic

tha

http://elm-chan.org/fsw/ff/doc/getcwd.html



Parameters
   buff
       ตัวชี้ไปยัง the buffer ที่รับ the current directory string.
   len
       ขนาดของ the buffer ในหน่วยของ TCHAR.

Return Values
FR_OK, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_NOT_ENABLED, FR_NO_FILESYSTEM, FR_TIMEOUT, FR_NOT_ENOUGH_CORE

Description
The f_getcwd function ดึง full path name ของ the current directory ของ the current drive. เมื่อ FF_VOLUMES >= 2, a heading drive prefix ถูกเพิ่มไปยัง the path name. The style of drive prefix ขึ้นอยู่กับ FF_STR_VOLUME_ID.
Note: ใน revision นี้, function นี้ไม่สามารถดึง the current directory path บน the exFAT volume. มันส่งคืนกลับ the root directory path เสมอ.

QuickInfo
Available when FF_FS_RPATH == 2.

Example


See Also
f_chdrive, f_chdir

tha

http://elm-chan.org/fsw/ff/doc/mount.html



Parameters
   fs
       ตัวชี้ไปยัง the filesystem object ที่จะถูก registered และถูก cleared. Null pointer ยกเลิกการรีจีสเตอร์ the registered
       filesystem object.
   path
       ตัวชี้ไปยัง the null-terminated string ที่ระบุ the logical drive. The string ที่ไม่มี drive number หมายถึง the default
       drive.
   opt
      Mounting option. 0: ไม่ mount ตอนนี้ (จะถูก mounted บน the first access ไปยัง the volume), 1: บังคับ mounted the
      volume เพื่อเช็คว่ามันพร้อมจะทำงานหรือไม่.

Return Values
FR_OK, FR_INVALID_DRIVE, FR_DISK_ERR, FR_NOT_READY, FR_NOT_ENABLED, FR_NO_FILESYSTEM

tha

Description
FatFs ต้องการ work area (filesystem object) สำหรับแต่ละ logical drives (FAT volumes). ก่อนดำเนินการ any file/directory operations, a filesystem object จำเป็นต้องถูก registered ด้วย f_mount function สำหรับ the logical drive. The file/directory API functions พร้อมที่จะทำงานหลังจากขบวนการนี้. Some volume management functions, f_mkfs, f_fdisk and f_setcp, ไม่ต้องการ a filesystem object.

The f_mount function รีจีสเตอร์/ยกเลิกการรีจีสเตอร์ a filesystem object ให้กับ the FatFs module ดังต่อไปนี้:

1. กำหนด the logical drive ซึ่งถูกระบุโดย path.
2. เคลียร์และยกเลิกการรีจีสเตอร์ the regsitered work area of the volume ถ้ามีอยู่.
3. เคลียร์และรีจีสเตอร์ the new work area ให้กับ the volume ถ้า fs ไม่เป็น NULL.
4. ดำเนินการ volume mount process ให้กับ the volume ถ้า forced mounting ถูกระบุ.


tha

ถ้ามี any open object of file or directory บน the logical drive, the object จะไม่ถูกใช้ได้โดยฟังชั่นนี้.

ถ้า forced mounting ไม่ถูกระบุ (opt = 0), ฟังชั่นนี้สำเร็จลงได้เสมอโดยไม่คำนึงถึง the physical drive status. มันเพียงเคลียร์ (ยกเลิกการกำหนดค่าเริ่มต้น) the given work area และรีจีสเตอร์ address ของมันไปยัง the internal table และไม่มีกิจกรรมของ the physical drive ในฟังชั่นนี้. The volume mount process จะถูกพยายามบน  file/directroy function ที่ตามมาถ้า the filesystem object ไม่ถูกเริ่มต้น. (การหน่วงเวลา mounting) The volume mount processes, เริ่มต้น the corresponding physical drive, ค้นหา the FAT volume ในนั้นและจากนั้นเริ่มต้น the work area, ถูกกระทำใน the subsequent file/directory functions เมื่ออย่างใดอย่างหนึ่งของเงื่อนไขต่อไปนี้เป็นจริง.

  •  Filesystem object ยังไม่ถูกเริ่มต้น. มันจะถูกถอดการเริ่มต้นโดย f_mount function.
  •  Physical drive ไม่ถูกเริ่มต้น. มันจะถูกถอดการเริ่มต้นโดย system reset or media removal.

tha

ถ้า the function ที่มี forced mounting (opt = 1) ล้มเหลวด้วย FR_NOT_READY, มันหมายความว่า the filesystem object ถูกรีจีสเตอร์สำเร็จแล้วแต่ the volume ไม่พร้อมที่จะทำงานโดยทันที. The volume mount process จะถูกพยายามบน subsequent file/directroy function. ถ้าการจัดให้มีใช้ของ the disk I/O layer ไม่มี asynchronous media change detection, application program จำเป็นต้องดำเนินการ f_mount function หลังจากแต่ละ media change เพื่อบังคับเคลียร์ the filesystem object.

เพื่อยกเลิกการรีจีสเตอร์ the work area, ระบุ a NULL ให้กับ the fs, และดังนั้น the work area สามารถถูกทิ้ง. f_unmount function ถูกจัดให้มีใช้เป็น a macro.


QuickInfo
มีให้ใช้งานเสมอ.

Example


See Also
f_open, FATFS

tha

http://elm-chan.org/fsw/ff/doc/mkfs.html



Parameters
   path
       ตัวชี้ไปยัง the null-terminated string ระบุ the logical drive ที่จะถูกฟอร์แม็ต. ถ้ามันไม่มี a drive number ในนั้น, มันหมายถึง
       การระบุ the default drive. The logical drive อาจหรืออาจไม่ถูก mounted แล้วสำหรับ the format process.
   opt
       ระบุ the format option structure MKFS_PARM holding format options. ถ้า a null pointer ถูกให้, มันให้ the function
       every option ใน default value. The structure มี five members ดังอธิบายข้างล่าง:
          BYTE fmt
               ระบุ combination of FAT type flags, FM_FAT, FM_FAT32, FM_EXFAT และ bitwise-or ของทั้งสามเหล่านี้,
               FM_ANY. FM_EXFAT ถูกละเว้นเมื่อ exFAT ไม่ถูกเปิดใช้งาน. flags เหล่านี้ระบุว่า FAT type ไหนที่จะถูกสร้างบน the
               volume. ถ้าสองประเภทขึ้นไปถูกระบุ, หนึ่งในนั้นของพวกมันจะถูกเลือกขึ้นอยู่กับ the volume size and au_size. The flag
               FM_SFD ระบุเพื่อสร้าง the volume บน the drive ใน SFD format. The default value คือ FM_ANY.
          DWORD au_size
               ระบุขนาดของ the allocation unit (cluter) เป็นหน่วย byte. ค่าที่ใช้ได้คือกำลัง 2 ระหว่าง sector size และ 128 *
               sector size ที่รวมสำหรับ FAT/FAT32 volume, หรือสูงถึง 16 MB สำหรับ exFAT volume. ถ้า a zero (default value)
               หรือค่าที่ใช้ไม่ได้ใดๆถูกให้, the function จะใช้ default allocation unit size ขึ้นอยู่กับ the volume size.

tha

          UINT n_align
               ระบุ alignment of the volume data area (file allocation pool, มักจะลบ block boundary of flash memory
               media) ในหน่วยของ sector. ค่าที่ใช้ได้สำหรับ member นี้คือระหว่าง 1 and 32768 ที่รวมในกำลัง 2. ถ้า a zero (the
               default value) หรือค่าที่ใช้ไม่ได้ใดๆถูกให้, the function ได้รับ the block size จาก lower layer ด้วย disk_ioctl
               function.
          BYTE n_fat
               ระบุจำนวนของ FAT ก๊อปปี้บน the FAT/FAT32 volume. Valid value สำหรับ member นี้คือ 1 หรือ 2. The default
               value (0) และค่าที่ใช้ไม่ได้ใดๆให้ 1. ถ้า the FAT type เป็น exFAT, member นี้ไม่มีผลอะไร.
          UINT n_root
               ระบุจำนวนของ root directory entries บน the FAT volume. Valid value สำหรับ member นี้คือสูงถึง 32768 และถูก
               ปรับให้สอดคล้องกับ sector size / 32. The default value (0) และค่าที่ใช้ไม่ได้ใดๆให้ 512. ถ้า the FAT type เป็น
               FAT32 หรือ exFAT, member นี้ไม่มีผลอะไร.
   work
       ตัวชี้ไปยัง the working buffer ที่ใช้สำหรับ the format process. ถ้า a null pointer ถูกให้ด้วย FF_USE_LFN == 3, the
       function ได้รับ a memory block สำหรับ the working buffer ในฟังชั่นนี้.
   len
       ขนาดของ the working buffer เป็นหน่วย byte. มันจำเป็นต้องเป็น FF_MAX_SS เป็นอย่างน้อย. Plenty of working buffer จะ
       ลดจำนวนของ write transactions ไปยัง the drive, ดังนั้น the format process จะสำเร็จลงอย่างรวดเร็ว.

Return Values
FR_OK, FR_DISK_ERR, FR_NOT_READY, FR_WRITE_PROTECTED, FR_INVALID_DRIVE, FR_MKFS_ABORTED, FR_INVALID_PARAMETER, FR_NOT_ENOUGH_CORE

tha

Description
The FAT sub-type, FAT12/FAT16/FAT32, ของ FAT volume ยกเว้น exFAT ถูกกำหนดโดยเฉพาะจำนวนของ clusters บน the volume และไม่มีสิ่งอื่น, ตามข้กำหนดของ the FAT specification ที่ปล่อยออกโดย Microsoft. ดังนั้น the FAT sub-type ของ created volume จะขึ้นอยู่กับ the volume size and the cluster size. ในกรณีของ combination of FAT type and cluter size ที่ระบุโดย argument ที่ไม่ถูกต้องสำหรับ the volume size, the function จะล้มเหลวด้วย FR_MKFS_ABORTED.