通过阅读FatFs源码发现,diskio.c文件中提供了4个接口函数(API):- extern int MMC_disk_status();
1 y" T) W8 ?8 U. S% [7 B+ S6 O - extern int MMC_disk_initialize();
% e0 C9 t7 |: ]: k4 M1 ^ - extern int MMC_disk_read(% ^, Z5 t0 ]! `$ g& v
- BYTE *buff, /* Data buffer to store read data */# p( T- d2 ]; S
- DWORD sector, /* Sector address in LBA */
1 M9 D. n% A1 ~ - UINT count /* Number of sectors to read */
& _& e2 C# W9 z+ k, A' d2 ?/ \ - );
7 D$ A2 S# ~" G# s9 t! z - extern int MMC_disk_write(4 H8 v2 }8 }1 E7 |" R6 d
- const BYTE *buff, /* Data buffer to store read data */# u6 D) F% [* t3 L
- DWORD sector, /* Sector address in LBA */
4 K# a! [( k; X2 Q! ]% J2 | - UINT count /* Number of sectors to read */
3 K# n0 J: x3 o/ z2 w - );
复制代码 它只有一个框架,这个函数需要我们自己去实现它,你可以在diskio.c中实现,为了层次清晰,我新建了驱动层spi_sd.c文件,并实现了初始化。
1 K' @* \- N9 d5 Q5 K, t朋友们以后移植的时候只修改此文件即可,ff.c是不需要修改的哦~~·
5 P; |) u8 O5 k2 N1 K: h; _- N R% I2 F1 H% R* x/ Z
) a3 e3 n7 c B) a, w; V
+ D0 H C. h; n, p0 e( v) u9 o, h# s. Y l; E9 ^' h* n, s5 x
& r! m5 }0 I2 r3 {1 q, }5 l
|