📄 test_fat32_u_sd.c
字号:
#include <std.h>
#include <stdio.h>
#include <log.h>
#include <swi.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_timer.h>
#define FAT_INI_VAR
#include "TYPE.H"
#include "Driver_WR.h"
#include "sd_cmd.h"
#include "ch375_cmd.h"
#include "filesys.h"
#include "SD_32M_Manager.h"
TIMER_Handle htimer1;
unsigned int start, end, overhead;
unsigned int writetime, readtime;
unsigned char buff_w[10512];
unsigned char buff_r[10512];
extern UINT8 RBC_Write(UINT32 iLbaStart, UINT8 iSectorCount,UINT8 xdata *mBufferPoint);
extern UINT8 RBC_Read(UINT32 iLbaStart, UINT8 iSectorCount,UINT8 xdata *mBufferPoint);
extern int MyFileOpen(char *file_name, UINT8 mode);
extern UINT8 MyDiskSelect(UINT8 dev_id);
void SwiMainFunc() {
unsigned char temp;
int i;
Uint8 temp8;
Uint32 temp32;
Uint32 write_len;
Uint32 file_size;
TIMER_Config MyTimerConfig = { 0x000002C0, /* ctl */
0xFFFFFFFF, /* prd */
0x00000000 /* cnt */
};
for(i=0;i<10000;i++)
{
buff_w[i]=i*1;
buff_r[i]=0;
}
htimer1 = TIMER_open(TIMER_DEVANY,0);
TIMER_config(htimer1,&MyTimerConfig);
start = TIMER_getCount(htimer1);
end = TIMER_getCount(htimer1);
overhead = end - start ;
if(MMC_Init()!=CH_OK)
{
printf("Error: MMC is not inited \n");
return;
}
temp8 = MyDiskSelect(0);
/*
if(fat_init()!=F_OK)
{
printf("Error: fat_init() \n");
return;
}*/
Get_SD_Info();
// SD_Hiden32M(1);
RBC_Read(0,1,buff_r);
temp32 = buff_r[0x1C6]+(buff_r[0x1C7]<<8)+(buff_r[0x1C8]<<16)+(buff_r[0x1C9]<<24);
RBC_Read(temp32,1,buff_r+512);
temp32 = 6+temp32;
RBC_Read(temp32,1,buff_r+1024);
// temp32 = SD_EraseBlock(32,4);
// RBC_Read(32,8,buff_r);
// MyFileOpen("\\TEST2.TXT",1);
// test_disk_query();
/* printf("Create file ...\n");
test_create_file("\\TEST2.TXT");
file_size= ch375FileOpen(1, "\\TEST2.TXT", 1);
temp32 = ch375FileWrite( buff_w, 32);
ch375FileClose(1,temp32,file_size);
// test_create_dir("\\新建目录4\\二级子目录1");
// test_enum_file();
*/
/* All done now, close the port. */
MyMcbsp_Close();
printf("Done \n");
}
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
void main() {
/* Initialize the chip support library, required */
CSL_init();
// SwiMainFunc();
SwiMainFunc();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -