FatFs

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

Previous topic - Next topic

tha

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



Parameters
   label
       ตัวชี้ไปยัง the null-terminated string ที่ระบุ the volume label ที่จะถูกเซ็ต.

Return Values
FR_OK, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_INVALID_NAME, FR_WRITE_PROTECTED, FR_INVALID_DRIVE, FR_NOT_ENABLED, FR_NO_FILESYSTEM, FR_TIMEOUT

Description
เมื่อ the string มี a drive prefix, the volume label จะถูกเซ็ตถึง the volume ที่ระบุโดย the drive prefix. Unix style volume ID ไม่สามารถถูกใช้เพื่อระบุ the volume. ถ้า drive number ไม่ถูกระบุ, the volume label จะถูกเซ็ตเป็นo the default drive. ถ้าความยาวของ the given volume label เป็นศูนย์, the volume label บน the volume จะถูกเอาออก. The format of the volume label เป็นดังแสดงข้างล่าง:

  •  สูงถึง 11 bytes long เมื่อ conversion of OEM code page ที่ FAT volume.
  •  สูงถึง 11 characters long ที่ exFAT volume.
  •  characters ที่ยอมได้สำหรับ FAT volume คือ: characters ยอมได้สำหรับ SFN ไม่รวมจุด. อักขระตัวพิมพ์เล็กจะถูกแปลงขึ้น.
  •  characters ที่ยอมได้สำหรับ exFAT volume คือ: characters ยอมได้สำหรับ LFN รวมถึงจุด. อักขระตัวพิมพ์เล็กจะถูกสงวนไว้.
  •  Spaces สามารถถูกฝังที่ไหนก็ได้ใน the volume label. Trailing spaces ถูกตัดออกที่ at FAT volume.

หมายเหตุ: The standard system (Windows) มี a problem ที่ the volume label ที่มี a heading \xE5 บน the FAT volume. เพื่อหลีกเลี่ยงปัญหานี้, ฟังชั่นนี้จะปฏิเสธ volume label ดังกล่าวว่าเป็น invalid name.

QuickInfo
Available when FF_FS_READONLY == 0 and FF_USE_LABEL == 1.

Example


See Also
f_getlabel

tha

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



Parameters
   cp
       OEM code page ที่จะถูกใช้สำหรับ the path name. Valid values เป็นดังต่อไปนี้.

Return Values
FR_OK, FR_INVALID_PARAMETER

Description
The f_setcp function เซ็ต the active code page สำหรับ the path name. นอกจากนี้ code conversion of string functions จะได้รับผลกระทบโดย the setting of code page เมื่อ FF_LFN_UNICODE >= 1 and FF_STRF_ENCODE == 0. เนื่องจาก the initial setting of the code page เป็น 0 และ API function ที่มี extended character จะทำงานไม่ถูกต้อง, a valid code page จำเป็นต้องถูกเซ็ตบน the system start-up และมันไม่ควรถูกเปลี่ยนกลางทาง.

QuickInfo
Available when FF_CODE_PAGE == 0.

tha

Media Access Interface

เนื่องจาก FatFs module เป็น the Filesystem Layer ไม่ขึ้นอยู่กับ platforms and storage media, มันแยกจาก the physical devices, อย่างเช่น memory card, harddisk และ any type of storage device โดยสิ้นเชิง. The storage device control module ไม่เป็นส่วนหนึ่งใดๆของ FatFs module และมันจำเป็นต้องถูกจัดให้มีโดยผู้นำไปใช้งาน. FatFs ควบคุม the storage devices โดยทาง a simple media access interface ที่แสดงข้างล่าง. นอกจากนี้การนำไปใช้งานอย่างง่ายๆสำหรับบาง platforms มีให้ใช้งานใน the downloads. A function checker สำหรับ storage device control module  มีให้ใช้งาน ที่นี่.





tha

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



The disk_status function ถูกเรียกเพื่อสอบถาม the current drive status.

Parameter
   pdrv
       Physical drive number ที่ระบุ the target device. ศูนย์เสมอใน single drive system.

Return Values
The current drive status ถูกส่งคืนกลับในการรวมกันของ status flags ที่อธิบายข้างล่าง. FatFs อ้างถึงเฉพาะ STA_NOINIT and STA_PROTECT.
   STA_NOINIT
       แสดงให้เห็นว่า the device ยังไม่ได้ถูกกำหนดค่าเริ่มต้นและไม่พร้อมจะทำงาน. flag นี้ถูกเซ็ตบน system reset, media removal
       หรือ failure of disk_initialize function. มันถูกเคลียร์บน disk_initialize function ทำสำเร็จลง. Any media change ที่เกิด
       ขึ้นแบบไม่ประสานเวลาต้องถูกจับและสะท้อนมันไปยัง the status flags, มิฉะนั้น auto-mount function จะทำงานไม่ถูกต้อง. ถ้า
       the system ไม่รองรับ media change detection, application program จำเป็นต้อง re-mount the volume อย่างชัดเจน
       ด้วย f_mount function หลังจากแต่ละ media change.
   STA_NODISK
       แสดงให้เห็นว่าไม่มี medium ใน the drive. นี้ถูกเคลียร์เสมอเมื่อ the drive เป็น non-removable class. โปรดทราบว่า FatFs ไม่
       ได้อ้างถึง flag นี้.
   STA_PROTECT
       แสดงให้เห็นว่า the medium มีการป้องกันการเขียน . นี้ถูกเคลียร์เสมอเมื่อ the drive ไม่มี write protect function. จะใช้ไม่ได้ถ้า
       STA_NODISK ถูกเซ็ต.

tha

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



The disk_initialize function ถูกเรียกเพื่อกำหนดค่าเริ่มต้น the storage device.

Parameter
   pdrv
       Physical drive number ที่ระบุ the target device. ศูนย์เสมอที่ single drive system.

Return Values
ฟังชั่นนี้ส่งคืนกลับ the current drive status flags เป็น the result. สำหรับรายละเอียดของ the drive status, โปรดดูที่ the disk_status function.

Description
ฟังชั่นนี้กำหนดค่าเริ่มต้น the storage device และเตรียมมันให้พร้อมเพื่อ generic read/write. เมื่อ the function สำเร็จลง, STA_NOINIT flag ใน the return value จะถูกเคลียร์.
หมายเหตุ: ฟังก์ชันนี้จำเป็นต้องอยู่ภายใต้การควบคุมของ FatFs module. Application program ต้องไม่เรียกฟังชั่นนี้, มิฉะนั้น FAT structure บน the volume อาจแตกได้. เพื่อกำหนดค่าเริ่มต้น the filesystem ใหม่, ใช้ f_mount function แทน.

tha

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



The disk_read function ถูกเรียกเพื่ออ่าน data จาก the sector(s) of storage device.

Parameters
   pdrv
       Physical drive number ที่ระบุ the target device.
   buff
       ตัวชี้ไปยัง the first item of the byte array เพื่อเก็บ read data. Size of read data จะเป็น the sector size * count bytes.
   sector
       เริ่มต้น sector number ใน LBA. The data type LBA_t เป็นนามแฝงของ DWORD or QWORD ขึ้นอยู่กับ the configuration option.
   count
       Number of sectors ที่จะอ่าน.

Return Value
   RES_OK (0)
       The function สำเร็จลง.
   RES_ERROR
       An unrecoverable hard error ที่เกิดขึ้นในระหว่าง the read operation.
   RES_PARERR
       parameter ไม่ถูกต้อง.
   RES_NOTRDY
       The device ยังไม่ถูกกำหนดค่าเริ่มต้น.

tha

Description
Read/write operation ไปยัง the generic storage devices, อย่างเช่น memory card, hadddisk and optical disk, ถูกทำในหน่วยของ block of data bytes ที่เรียกว่า sector. FatFs รองรับ the sector size ในช่วง 512 ถึง 4096 bytes. เมื่อ FatFs ถูกกำหนดค่าสำหรับ fixed sector size (FF_MIN_SS == FF_MAX_SS, นี่เป็นกรณีส่วนใหญ่), the generic read/write function ต้องทำงานที่ the sector size เท่านั้น.  เมื่อ FatFs ถูกกำหนดค่าสำหรับ variable sector size (FF_MIN_SS < FF_MAX_SS), the sector size of medium ถูกสอบถามด้วย disk_ioctl function หลังจาก disk_initialize function สำเร็จลง.

tha

มีข้อควรพิจารณาบางประการเกี่ยวกับ the memory addres ที่ส่งผ่านโดยทาง buff. มันไม่ได้เป็นแถวเดียวกันกับ the word boundary เสมอไป, เน่องจาก the argument ถูกกำหนดเป็น BYTE*. The unaligned transfer request สามารถเกิดขึ้นที่ direct transfer. ถ้า the bus architecture, โดยเฉพาะy DMA controller, ไม่ยอมให้ unaligned memory access, มันควรถูกแก้ไขในฟังชั่นนี้. หากเป็นกรณี มีวิธีแก้ไขปัญหาชั่วคราวที่อธิบายไว้ด้านล่างเพื่อหลีกเลี่ยงปัญหานี้.

  •  แปลง word transfer เป็น byte transfer ด้วยเคล็ดลับบางประการในฟังชั่นนี้. - ขอแนะนำ.
  •  ในการเรียก the f_read(), หลีกเลี่ยง long read request ที่รวมทั้งหมดของ sector. - Any direct transfer ไม่เคยเกิดขึ้น.
  •  ในการเรียก the f_read(fp, data, btw, bw), ทำให้แน่ใจว่า (((UINT)data & 3) == (f_tell(fp) & 3)) เป็นจริง. - Word
      alignment of buff จะถูกรับประกัน.

นอกจากนี้ the memory area อาจไม่สามารถเข้าถึงได้ใน DMA กรณีนี้ถ้ามันตั้งอยู่บน the tightly coupled memory ซึ่งมักจะถูกใช้สำหรับ stack. ใช้ double buffered transfer, หรือหลีกเลี่ยงการกำหนด file I/O buffer, FATFS and FIL structure เป็น local variables ที่อยู่บน the stack.

โดยทั่วไป, a multiple sector read request ต้องไม่ถูกแบ่งออกลงใน single sector transactions ไปยัง the storage device, มิฉะนั้น read throughput จะแย่ลง.