📄 test-1.c~
字号:
test_char = _FF_getchar();
_FF_putchar(test_char);
test_char = ascii_to_char(test_char);
addr_sd = test_char;
for(n = 0; n < addr_size; n++)
{
test_char = _FF_getchar();
if(test_char == 0x8)
{
n -= 2;
addr_sd >>= 8;
}
else if((test_char == '\r') || (test_char == '\n'))
return(addr_sd);
if(test_char == 0x1B)
return(0xFFFFFFFF);
_FF_putchar(test_char);
test_char = ascii_to_char(test_char);
addr_sd = addr_sd << 4;
addr_sd |= test_char;
}
return(addr_sd);
}
#ifndef _READ_ONLY_
/****************************************************************************
**
** Function that runs the demo program to show a normal file creation and
** writing to the file.
**
** Parameters: None
**
** Returns: None
**
****************************************************************************/
void run_demo(void)
{
FILE *pntr1;
int8 c, n;
int16 temp16;
/* Create File */
pntr1 = fcreatec(_FF_FNAME, ATTR_ARCHIVE);
n = 0;
while(pntr1 == NULL)
{
if(pntr1 == NULL)
{
_FF_printf(Fail02Str, _FF_error);
n++;
if(n & 0xF0)
return;
}
pntr1 = fcreatec(_FF_FNAME, ATTR_ARCHIVE);
}
if(fputc('\"', pntr1) == (int16) EOF)
goto RUN_DEMO_ERROR;
fprintf(pntr1, _FF_FNAME);
if(fputc('\"', pntr1) == (int16) EOF)
goto RUN_DEMO_ERROR;
if(fputc('\r', pntr1) == (int16) EOF)
goto RUN_DEMO_ERROR;
if(fputc('\n', pntr1) == (int16) EOF)
goto RUN_DEMO_ERROR;
/* Write to file */
#ifdef _RTC_ON_
/* if real time clock enabled, get and print time and date to file */
rtc_get_timeNdate(&RTCHour, &RTCMin, &RTCSec, &RTCDay, &RTCMonth, &RTCYear);
fprintf(pntr1, C2DStr, '\"', RTCMonth);
fprintf(pntr1, p2DSlashStr, RTCDay);
fprintf(pntr1, p4DStr, RTCYear);
fprintf(pntr1, p2DColinStr, RTCHour);
fprintf(pntr1, p2DColinStr, RTCMin);
fprintf(pntr1, p2DCRLFStr, RTCSec, '\"');
#endif
for(c = 0; c < 10; c++)
fprintf(pntr1, column_d, c);
fprintf(pntr1, _FF_CRLFStr);
for(c = 0; c < 100; c++)
{
/* print numbers separated by commas */
for(n = 0; n < 10; n++)
{
temp16 = c;
temp16 *= 10;
temp16 += n;
fprintf(pntr1, ldStr, temp16);
}
if(fputc('\r', pntr1) == (int16) EOF)
goto RUN_DEMO_ERROR; /* line feed/carriage return */
if(fputc('\n', pntr1) == (int16) EOF)
goto RUN_DEMO_ERROR; /* line feed/carriage return */
PORTB ^= 0x40;
PORTB ^= 0x80;
}
RUN_DEMO_ERROR:
fclose(pntr1);
_FF_printf(doneStr);
}
/****************************************************************************
**
** Function that runs a demo program to show multiple file creations and
** writing to the files in a specified directory.
**
** Parameters: None
**
** Returns: None
**
****************************************************************************/
void run_multi(void)
{
FILE *pntr1;
uint8 c, d;
uint16 n;
uint32 fsize;
int8 create_info[22], modify_info[22], tempc[14];
HiLo16Union c2;
#if defined(_DIRECTORIES_SUPPORTED_)
_FF_strcpyf((int8 *) modify_info, WORKING_FOLDER);
if(chdir(modify_info))
{
/* an error occured, try creating the folder */
if(mkdir(modify_info)) /* Just try to make the directory once, */
return;
if(chdir(modify_info)) /* Then try to change the directory again */
return;
}
#endif
/* Create File */
for(d = 0; d < 20; d++)
{
_FF_strcpyf((int8 *) modify_info, DEMO_FILENAME8);
_FF_strcpyf((int8 *) create_info, DEMO_FILENAME3);
#if defined(_ICCAVR_)
_FF_sprintf((int8 *)tempc, (int8 *) SDSStr, (int8 *)modify_info, d, (int8 *)create_info);
#else
_FF_sprintf((int8 *)tempc, SDSStr, (int8 *)modify_info, d, (int8 *)create_info);
#endif
pntr1 = fcreate(tempc, ATTR_ARCHIVE);
for(n = 0; n < 5; n++)
{
if(pntr1 == 0)
{
_FF_printf(CreateFailedStr, 0x22, tempc, 0x22);
pntr1 = fcreate(tempc, ATTR_ARCHIVE);
}
else
n = 5;
}
if(pntr1 == 0)
{
_FF_printf(CreateFailedStr, 0x22, tempc, 0x22);
return;
}
_FF_printf(CreatedStr, 0x22, tempc, 0x22);
#ifdef _RTC_ON_
/* if real time clock enabled, get and print time and date to file */
rtc_get_timeNdate(&RTCHour, &RTCMin, &RTCSec, &RTCDay, &RTCMonth, &RTCYear);
_FF_printf(C2DStr, 0x22, RTCMonth);
_FF_printf(p2DSlashStr, RTCDay);
_FF_printf(p4DStr, RTCYear);
_FF_printf(p2DColinStr, RTCHour);
_FF_printf(p2DColinStr, RTCMin);
_FF_printf(P2DCStr, RTCSec, 0x22);
#endif
/* Write to file */
#ifdef _RTC_ON_
/* if real time clock enabled, get and print time and date to file */
rtc_get_timeNdate(&RTCHour, &RTCMin, &RTCSec, &RTCDay, &RTCMonth, &RTCYear);
fprintf(pntr1, C2DStr, 0x22, RTCMonth);
fprintf(pntr1, p2DSlashStr, RTCDay);
fprintf(pntr1, p4DStr, RTCYear);
fprintf(pntr1, p2DColinStr, RTCHour);
fprintf(pntr1, p2DColinStr, RTCMin);
fprintf(pntr1, p2DCRLFStr, RTCSec, 0x22);
#endif
for(n = 0; n < 0x100; n++)
{
fprintf(pntr1, CSCStr, 0x22, tempc, 0x22);
c2.uval8.lo = n & 0x0F;
if(c2.uval8.lo > 9)
c2.uval8.lo += 0x37;
else
c2.uval8.lo += 0x30;
c2.uval8.hi = (n >> 4) & 0x0F;
if(c2.uval8.hi > 9)
c2.uval8.hi += 0x37;
else
c2.uval8.hi += 0x30;
c = 0;
while((pntr1->position % 512) < 507)
{
if((pntr1->position % 64) == 62)
{
if(fputc('\r', pntr1) == EOF)
{
n = 0x100;
break;
}
}
else if((pntr1->position % 64) == 63)
{
fputc('\n', pntr1);
c = 0;
}
else
{
if((c % 3) == 0)
fputc(c2.uval8.hi, pntr1);
else if((c % 3) == 1)
fputc(c2.uval8.lo, pntr1);
else if((c % 3) == 2)
fputc(' ', pntr1);
c++;
}
}
fprintf(pntr1, EOFStr);
}
fclose(pntr1);
if(fget_file_info(tempc, &fsize, create_info, modify_info, &c, &n) != EOF)
{
_FF_printf(CRLF_FileSize, fsize);
_FF_printf(_S_STR, create_info);
_FF_printf(CR_ModTime);
_FF_printf(_S_STR, modify_info);
_FF_printf(CR_ATTR, c);
_FF_printf(CR_STARTCLUS, n, (clust_to_addr(n)<<9));
}
else
_FF_printf(CRLF_ERROR_X, _FF_error);
if(rx_counter0)
{
c = _FF_getchar();
if(c == 0x1B)
break;
}
} /*for(d = 0; d < 20; d++)*/
_FF_printf(doneStr);
}
#if defined(_DIRECTORIES_SUPPORTED_)
/****************************************************************************
**
** Function that runs a demo program to show a file creation and writing to a
** file in a bunch of different directories.
**
** Parameters: None
**
** Returns: None
**
****************************************************************************/
void run_multifold(void)
{
FILE *pntr1;
uint8 c, d;
uint16 n;
int8 tempback[3], tempc[14];
uint32 fsize;
int8 create_info[22], modify_info[22];
HiLo16Union c2;
_FF_strcpyf((int8 *)tempc, WORKING_FOLDER);
if(chdir(tempc))
{
/* an error occured, try creating the folder */
if(mkdir(tempc)) /* Just try to make the directory once, */
return;
if(chdir(tempc)) /* Then try to change the directory again */
return;
}
tempback[0] = '.';
tempback[1] = '.';
tempback[2] = 0;
/* Create Folders */
for(d = 0; d < 100; d++)
{
#if defined(_ICCAVR_)
_FF_sprintf((int8 *)tempc, (int8 *) DEMO_FOLDNAME, d);
#else
_FF_sprintf((int8 *)tempc, DEMO_FOLDNAME, d);
#endif
if(chdir(tempc))
{
mkdir(tempc); /* Just try to make the directory once, */
if(chdir(tempc)) /* Then try to change the directory again */
return;
}
pntr1 = fcreatec(_FF_FNAME, ATTR_ARCHIVE);
if(pntr1 == 0)
{
_FF_printf(CreateFailedStr, 0x22, tempc, 0x22);
return;
}
_FF_printf(CreatedStr, 0x22, tempc, 0x22);
/* Write to file */
#ifdef _RTC_ON_
/* if real time clock enabled, get and print time and date to file */
rtc_get_timeNdate(&RTCHour, &RTCMin, &RTCSec, &RTCDay, &RTCMonth, &RTCYear);
fprintf(pntr1, C2DStr, 0x22, RTCMonth);
fprintf(pntr1, p2DSlashStr, RTCDay);
fprintf(pntr1, p4DStr, RTCYear);
fprintf(pntr1, p2DColinStr, RTCHour);
fprintf(pntr1, p2DColinStr, RTCMin);
fprintf(pntr1, p2DCRLFStr, RTCSec, 0x22);
#endif
for(n = 0; n < 0x40; n++)
{
fprintf(pntr1, CSCStr, 0x22, tempc, 0x22);
c2.uval8.lo = n & 0x0F;
if(c2.uval8.lo > 9)
c2.uval8.lo += 0x37;
else
c2.uval8.lo += 0x30;
c2.uval8.hi = (n >> 4) & 0x0F;
if(c2.uval8.hi > 9)
c2.uval8.hi += 0x37;
else
c2.uval8.hi += 0x30;
c = 0;
while((pntr1->position % 512) < 507)
{
if((pntr1->position % 64) == 62)
fputc('\r', pntr1);
else if((pntr1->position % 64) == 63)
{
fputc('\n', pntr1);
c = 0;
}
else
{
if((c % 3) == 0)
fputc(c2.uval8.hi, pntr1);
else if((c % 3) == 1)
fputc(c2.uval8.lo, pntr1);
else if((c % 3) == 2)
fputc(' ', pntr1);
c++;
}
}
fprintf(pntr1, EOFStr);
} /*for(n = 0; n < 0x40; n++)*/
fclose(pntr1);
if(fget_file_infoc(_FF_FNAME, &fsize, create_info, modify_info, &c, &n) != EOF)
{
_FF_printf(CRLF_FileSize, fsize);
_FF_printf(_S_STR, create_info);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -