📄 cftest.c
字号:
#include <sys\hyrtk.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include "ioctrl.h"
#include "devctrl.h"
#include "CF.h"
#include <sys/hyrtk.h>
#define TPR_V 0x0c000000
#define HFLAG_V (0x1<<5)
BOOL Init(void)
{
long BCR_D;
// set WAIT polarity high and disable INT3
// polarity non-inverted: high
UpdateFCR((1<<26)|(1<<30), (0<<26));
// enable MEM2 WAIT function
UpdateMCR(0, (1<<26));
// Set DRAM access
// UpdateBCR((1<<19)|(1<<15)|(1<<17), (1<<18)|(1<<14)|(1<<16));
/*
printf("BCR_D= %x\n", BCR_D);
BCR_D = GetBCR();
printf("BCR_D= %x\n", BCR_D);
asm volatile ("FETCH 4\n ORI SR, $20\nMOVI BCR, $bb1aa3cb\n"
:
: "l" (TPR_V)
);
*/
// initialize 8 bit latch outputs
SetGPOutput(0, 0xffffffff);
// switch on LCD voltages
DelayBy(10000);
SetGPOutput(GP_OUT0, 0);
return TRUE;
}
static int CFinstalled = 0;
static int CFnumFiles = 0;
#define MAX_CF_FILES 100
static char CFnames[MAX_CF_FILES][15];
static int CFcurrent = 0;
#define KEYS_CF (KEY0|KEY1|KEY2|KEY3|KEY4|KEY5|KEY6|KEY7|INPUT_PCD1|INPUT_PCD2)
void CheckCF()
{
struct ffblk ff;
int done;
DelayBy(200000);
if (CFinstalled)
{
CFinstalled = 0;
DeInstallLocalFileSystem();
CFnumFiles = 0;
CFcurrent = 0;
}
if (!CFinstalled)
{
if (InstallLocalFileSystem() == 1)
{
CFinstalled = 1;
CFnumFiles = 0;
CFcurrent = 0;
}
else
DeInstallLocalFileSystem();
}
}
int n1, n2;
void main(void)
{
unsigned char val[1000];
int fh1, fh2;
int count,i;
if (Init() == FALSE)
exit(1);
CheckCF();
if (!CFinstalled)
{
// show error message on screen
printf("No CF card detected");
exit(1);
}
fh1 = open("Z:CFDATA.DAT", O_RDONLY | O_BINARY);
fh2 = open("Z:CF.DAT", O_CREAT | O_BINARY | O_WRONLY, S_IWRITE);
count = 0;
do {
n1 = read(fh1, &val[count], sizeof(unsigned char)*1000);
count+=1000;
}while (count < 1000);
for(i=0;i<1000;i++)
printf("%c",val[i]);
count = 0;
do {
n2 = write(fh2, &val[count], sizeof(unsigned char)*1000);
count+=1000;
}while (count < 1000);
close(fh1);
close(fh2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -