RT,板子F5528的芯片,模拟IO口SPI模式通信SD,小弟目前编了个SD卡的驱动,想在SD卡上完成FATFS 的系统植入,并能够在PC上显示出SD卡中的数据。FATFS用的是0.9版本的,看了网友其他人做的SD卡数据读写,里面都有diskio.c,而这版没有。。。。不知需不需要编????
看了ff.c中的一堆函数,不知如何用啊??是在main中调用吗??可是函数本身的定义有问题啊,FRESULT f_mount(),这个FRESULT什么意思啊??
跪求大神给知道一下!!谢谢!!
此帖出自
小平头技术问答
这个FAT困扰我很久了。。。。一直没调通。。。。
main代码如下:
void main()
{
WDTCTL = WDTPW + WDTHOLD; //关闭看门狗
P2OUT |= BIT2 + BIT3 + BIT4 + BIT5;
P2DIR |= BIT2 + BIT3 + BIT4 + BIT5; //LED
P1DIR &= ~( BIT4 + BIT5 + BIT6 + BIT7 ); //按键
P1IES |= BIT4 + BIT5 + BIT6 + BIT7;
P1IE |= BIT4 + BIT5 + BIT6 + BIT7;
P2IFG =0;
SpiSetup();
_EINT(); LPM4;
FRESULT rc; /* Result code */
DIRE dir; /* Directory object */
FILINFO fno; /* File information object */
UINT bw, br, i;
f_mount(0, &Fatfs); /* Register volume work area (never fails) */
printf(" Open an existing file (message.txt). ");
rc = f_open(&Fil, "MESSAGE.TXT", FA_READ);
if (rc) die(rc);
printf(" Type the file content. ");
for (;;) {
rc = f_read(&Fil, Buff, sizeof Buff, &br); /* Read a chunk of file */
if (rc || !br) break; /* Error or end of file */
for (i = 0; i < br; i++) /* Type the data */
putchar(Buff);
}
if (rc) die(rc);
printf(" Close the file. ");
rc = f_close(&Fil);
if (rc) die(rc);
printf(" Create a new file (hello.txt). ");
rc = f_open(&Fil, "HELLO.TXT", FA_WRITE | FA_CREATE_ALWAYS);
if (rc) die(rc);
printf(" Write a text data. (Hello world!) ");
rc = f_write(&Fil, "Hello world! ", 14, &bw);
if (rc) die(rc);
printf("%u bytes written. ", bw);
printf(" Close the file. ");
rc = f_close(&Fil);
if (rc) die(rc);
printf(" Open root directory. ");
rc = f_opendir(&dir, "");
if (rc) die(rc);
printf(" Directory listing... ");
for (;;) {
rc = f_readdir(&dir, &fno); /* Read a directory item */
if (rc || !fno.fname[0]) break; /* Error or end of dir */
if (fno.fattrib & AM_DIR)
printf(" <dir> %s ", fno.fname);
else
printf("%8lu %s ", fno.fsize, fno.fname);
}
if (rc) die(rc);
printf(" Test completed. ");
for (;;) ;
}
求指教
一周热门 更多>