?? main.c
字號:
//#include <msp430x16x.h>
#include <msp430xG46x.h>
#include "hal_hardware_board.h"
#include "mmc.h"
#include "diskio.h"
#include "tff.h"
#include <stdio.h>
#define OPERATIONOK 0
#define OPENFAIL 1
#define READFAIL 2
#define WRITEFAIL 3
unsigned long cardSize = 0;
unsigned char status = 1;
unsigned int timeout = 0;
int i = 0;
int main( void )
{
FATFS fs; // Work area (file system object) for logical drive
FIL fsrc, fdst; // file objects
BYTE buffer[500]; // file copy buffer
BYTE buffer1[500]={0}; // file copy buffer
FRESULT res; // FatFs function common result code
UINT bw; // File R/W count
UINT br; // File R/W count
INT8U fs_status=0;
INT16U i;
CPU_init();
for(i=0;i<400;i++)
{
buffer[i]= i%256;
}
//Initialisation of the MMC/SD-card
while (status != 0) // if return in not NULL an error did occur and the
// MMC/SD-card will be initialized again
{
status = mmcInit();
timeout++;
if (timeout == 150) // Try 50 times till error
{
//printf ("No MMC/SD-card found!! %x\n", status);
break;
}
}
// Read the Card Size from the CSD Register
cardSize = mmcReadCardSize();
// Register a work area for logical drive 0
f_mount(0, &fs);
// Open source file
res = f_open(&fsrc, "srcfile.txt", FA_OPEN_EXISTING | FA_READ|FA_WRITE);
if (res) fs_status = OPENFAIL ;
else fs_status =OPERATIONOK;
// Create destination file
res = f_open(&fdst, "dstfile.txt", FA_OPEN_EXISTING | FA_WRITE|FA_READ);
if (res) fs_status = OPENFAIL ;
else fs_status =OPERATIONOK;
// Copy source to destination
// for (;;) {
res = f_write(&fsrc, buffer, 400, &bw);
if (res || bw < 400) fs_status = READFAIL ;//break; // error or disk full
else fs_status =OPERATIONOK;
res = f_read(&fsrc, buffer1, 400, &br);
if (res || br == 0) fs_status = READFAIL ;//break; // error or eof
else fs_status =OPERATIONOK;
res = f_write(&fdst, buffer1, 400, &bw);
if (res || bw < 400) fs_status = WRITEFAIL ;//break; // error or disk full
f_close(&fsrc);
f_close(&fdst);
// Unregister a work area before discard it
f_mount(0, NULL);
mmcGoIdle(); // set MMC in Idle mode
while (1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -