通过阅读FatFs源码发现,diskio.c文件中提供了4个接口函数(API):- extern int MMC_disk_status(); 7 ]6 Q1 l% p" w2 T( Q4 g
- extern int MMC_disk_initialize();
0 b6 Z0 Z5 t7 F$ _; B) g. M7 R - extern int MMC_disk_read(+ `7 V0 l" G6 k8 i
- BYTE *buff, /* Data buffer to store read data */
9 b- P4 @1 k5 f# W- N - DWORD sector, /* Sector address in LBA */
8 c; g5 L( d H6 I( A% R! E7 H$ `) T - UINT count /* Number of sectors to read */+ h& j4 P5 y# A* \( O
- ); ! Y* r R: V, h6 i
- extern int MMC_disk_write($ `5 [- L4 ]" U' o" {( ~+ ~
- const BYTE *buff, /* Data buffer to store read data */) b" ?2 R3 \: T3 C- [. P
- DWORD sector, /* Sector address in LBA */
5 w9 i4 t' J( y7 { - UINT count /* Number of sectors to read */
/ ?: V) M/ Q' h, x! v$ k - );
复制代码 它只有一个框架,这个函数需要我们自己去实现它,你可以在diskio.c中实现,为了层次清晰,我新建了驱动层spi_sd.c文件,并实现了初始化。. G# V) X9 f6 e9 y) f) s
朋友们以后移植的时候只修改此文件即可,ff.c是不需要修改的哦~~·
3 E1 I& d% ^) P8 ^. c
t' i- B( ^" ]$ U+ A5 o1 f4 Y5 L0 h4 O7 [; ~. A( u/ r& m+ i
' z% k, j1 p8 {% {6 e; o( a7 m, k
" E3 R( o: o1 ^' \) T7 q
. e$ }0 P0 I) l" F2 x |