FatFs

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

Previous topic - Next topic

tha

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



The disk_write function ถูกเรียกเพื่อเขียน data ไปยัง the sector(s) of storage device.

Parameters
   pdrv
       Physical drive number ที่ระบุ the target device.
   buff
       ตัวชี้ไปยัง the first item of the byte array ที่จะถูกเขียน. Size of 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
The specified memory address ไม่ได้เป็นแถวเดียวกันกับ the word boundary เสมอไป เนื่องจาก the argument ถูกกำหนดเป็น BYTE*. สำหรับข้อมูลเพิ่มเติม, โปรดดูที่ the description of disk_read function.
โดยทั่วไป, a multiple sector write request (count > 1) ต้องไม่ถูกแบ่งออกลงใน single sector transactions ไปยัง the storage device, มิฉะนั้น the file write throughput จะลดลงอย่างมาก.
FatFs คาดว่าจะมีฟังก์ชันการเขียนแบบหน่วงเวลาของ the disk control layer. The write operation ไปยัง the media ไม่จำเป็นต้องเสร็จสมบูรณ์เมื่อรีเทิร์นจากฟังชั่นนี้ด้วย write operation กำลังดำเนินการหรือ data ถูกเก็บเฉพาะลงใน the write-back cache. แต่ write data บน the buff จะใช้ไม่ได้หลังจากรีเทิร์นจากฟังชั่นนี้. The write completion request ถูกกระทำโดย CTRL_SYNC command ของ disk_ioctl function. ดังนั้น, ถ้า a delayed write function ถูกนำมาใช้งาน, the write throughput of the filesystem จะถูกปรับปรุงให้ดีขึ้น.
หมายเหตุ: Application program ต้องไม่เรียกฟังชั่นนี้, มิฉะนั้น FAT structure บน the volume อาจถูกทำให้พังลงได้.

QuickInfo
ฟังชั่นนี้จะไม่ถูกต้องการเมื่อ FF_FS_READONLY == 1.

tha

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



The disk_ioctl function ถูกเรียกเพื่อควบคุม device specific features และฟังก์ชันเบ็ดเตล็ดอื่นๆ นอกเหนือจาก generic read/write.

Parameters
   pdrv
       Physical drive number ที่ระบุ the target device.
   cmd
       Command code.
   buff
       ตัวชี้ไปยัง the parameter ขึ้นอยู่กับ the command code. ไม่ต้องสนใจถ้า the command ไม่มี parameter ที่จะถูกส่งผ่าน.

Return Value
   RES_OK (0)
       The function สำเร็จลง.
   RES_ERROR
       An error เกิดขึ้น.
   RES_PARERR
       The command code หรือ parameter ไม่ถูกต้อง.
   RES_NOTRDY
       The device ยังไม่ถูกกำหนดค่าเริ่มต้น..

Description
The FatFs module ต้องการเฉพาะ five device independent commands ที่อธิบายข้างล่าง.

FatFs จะไม่ใช้ทั้ง any device dependent command หรือ user defined command. ตารางต่อไปนี้แสดงตัวอย่างของ non-standard commands ซึ่งอาจเป็นประโยชน์สำหรับบาง applications.


QuickInfo
The disk_ioctl function ไม่ถูกต้องการเมื่อ FF_FS_READONLY == 1 and FF_MAX_SS == FF_MIN_SS.


tha

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



The get_fattime function ถูกเรียกเพื่อรับ the current time.

Return Value
Current local time จะถูกส่งคืนกลับเป็น bit-fields ที่แพ็คลงใน a DWORD value. The bit fields เป็นดังต่อไปนี้:

   bit31:25
       Year ตั้งต้นจาก the 1980 (0..127, ตัวอย่างเช่น 37 สำหรับ 2017)
   bit24:21
       Month (1..12)
   bit20:16
       Day of the month (1..31)
   bit15:11
       Hour (0..23)
   bit10:5
       Minute (0..59)
   bit4:0
       Second / 2 (0..29, ตัวอย่างเช่น 25 สำหรับ 50)

Description
The get_fattime function จะส่งคืนกลับ any valid time ถึงแม้ว่า the system does ไม่รองรับ a real time clock. ถ้าศูนย์ถูกส่งคืนกลับ, the file จะไม่มี a valid timestamp.

QuickInfo
ฟังชั่นนี้จะไม่ถูกต้องการเมื่อ FF_FS_READONLY == 1 or FF_FS_NORTC == 1.

Example