📄 filedemo.c
字号:
Files_Deleted[task_id] += 5; /* Increment Task4 Files Deleted */
}
else
{
Errors[task_id]++; /* Log error */
}
/* Set directory back to Task4 directory */
status = NU_Set_Current_Dir ("..");
status = NU_Set_Current_Dir ("TASK4DIR");
/* Create 2 files in working directory */
for ( ii = 0; ii < 2; ii++)
{
/* Make unique file name for each */
fname[6] = 0x30 + ii; /* ascii numbers 0-1 */
/* Create File */
fd = NU_Open(fname,(PO_TEXT|PO_RDWR|PO_CREAT|PO_TRUNC),
(PS_IWRITE | PS_IREAD));
/* Write 512 bytes to the new file */
status = NU_Write(fd, outbuf, 512);
/* Check status for number of bytes written */
if (status == 512)
{
Files_Created[task_id]++; /* Increment Task4 Files Created */
}
else
{
Errors[task_id]++; /* Log error */
}
/* Close file */
status = NU_Close(fd);
} /* End For (ii ) */
/* Rename all files using wildcard */
status = NU_Rename("*.TXT", "*.TK4");
/* Check status for success */
if( status == NU_SUCCESS)
{
Files_Renamed[task_id] += 2; /* Increment Task4 Files Renamed */
}
else
{
Errors[task_id]++; /* Log error */
}
/* Set event for task_3 */
status = NU_Set_Events(&Event_Group_0, TASK4_EVENT, NU_OR);
} /* End While (1) */
}
/**************************************************************************/
/* */
/* FUNCTION "format_ramdisk" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This task will set up the format parameters and then */
/* call NU_Format() to format the ramdisk. */
/* */
/* AUTHOR */
/* Accelerated Technology */
/* CALLED FROM */
/* */
/* task_0 */
/* */
/* ROUTINES CALLED */
/* */
/* NU_Format Formats the disk */
/* user of the file system. */
/* on the disk. */
/* */
/* INPUTS */
/* driveno The number of the */
/* drive to format */
/* OUTPUTS */
/* NU_SUCCESS If the filesystem disk was */
/* successfully initialized. */
/* NUF_BAD_USER Not a file user. */
/* NUF_BADDRIVE Invalid drive specified. */
/* NUF_NOT_OPENED The disk is not opened yet. */
/* NUF_FATCORE Fat cache table too small. */
/* NUF_BADPARM Invalid parameter specified. */
/* NUF_BADDISK Bad Disk. */
/* NUF_NO_PARTITION No partition in disk. */
/* NUF_NOFAT No FAT type in this */
/* partition. */
/* NUF_FMTCSIZE Too many clusters for this */
/* partition. */
/* NUF_FMTFSIZE File allocation table too */
/* small. */
/* NUF_FMTRSIZE Numroot must be an even */
/* multiple of 16. */
/* NUF_INVNAME Volume lable includes */
/* invalid character. */
/* NUF_NO_MEMORY Can't allocate internal */
/* buffer. */
/* NUF_NO_BLOCK No block buffer available. */
/* NUF_IO_ERROR Driver IO error. */
/* NUF_INTERNAL Nucleus FILE internal error. */
/* */
/**************************************************************************/
STATUS format_ramdisk(INT16 driveno)
{
STATUS status;
FMTPARMS fmt;
/* Setup Format parameters */
fmt.oemname[0] = 'N';
fmt.oemname[1] = 'U';
fmt.oemname[2] = 'F';
fmt.oemname[3] = 'I';
fmt.oemname[4] = 'L';
fmt.oemname[5] = 'E';
fmt.oemname[6] = ' ';
fmt.oemname[7] = ' ';
fmt.oemname[8] = '\0';
fmt.secpalloc = (UINT8) 2;
/* must be a multiple of 2. This
number indicates the number of
sectors (blocks) per cluster.
This value is the minimum number
of bytes that are written to or
read from the disk at a time. */
fmt.secreserved = (UINT16) 1;
fmt.numfats = (UINT8) 1;
/* since redundant fats aren't used
only have one fat. */
fmt.numroot = (UINT16) 64; /* number of files in root */
fmt.bytepsec = (UINT16) 512;
fmt.mediadesc = (UINT8) 0xFD;
fmt.partdisk = (UINT8)0;
/* No partition */
fmt.secptrk = (UINT16) NRAMDISKBLOCKS/4;
fmt.numhead = (UINT16) 2;
fmt.numcyl = (UINT16) 2;
fmt.physical_drive_no = 0;
fmt.binary_volume_label = 0x12345678L;
fmt.text_volume_label[0] = '\0';
/* Format the Ram Disk */
status = NU_Format(driveno, &fmt);
/* Return status from NU_Format() */
return(status);
}
#ifdef NU_SERIAL
/************************************************************************/
/* */
/* FUNCTION "display_task" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This task sends global data out Serial port. */
/* Then it checks to see if a key has been pressed. If */
/* it has, it reads the key and sends it back out the */
/* serial port. After that it sleeps for awhile and */
/* then repeats the entire process. */
/* */
/* AUTHOR */
/* Accelerated Technology */
/* CALLED FROM */
/* */
/* kernel Started by task_0. */
/* */
/* ROUTINES CALLED */
/* */
/* Calls multiple uart routines */
/* */
/************************************************************************/
void display_task(UNSIGNED argc, VOID *argv)
{
STATUS status;
int ii; /* Local loop counter */
/* Access argc and argv just to avoid compilation warnings. */
status = (STATUS)argc + (STATUS)argv;
while(1)
{
/* Print out the system variables. */
NU_Printf("****************************************");
NU_Printf("***************************************\n\r");
NU_Printf(NU_Release_Information());
NU_Printf("\n\r");
NU_Printf("Copyright (c) 1993-2002 ATI - Nucleus ");
NU_Printf("FILE - Nucleus MNT v. 2.3.2 ");
NU_Printf("\n\r");
NU_Printf("****************************************");
NU_Printf("***************************************\n\r");
NU_Printf("Demo Variable Status: ");
NU_Printf("\n\r");
NU_Printf(" Task0 Task1 Task2 Task3 Task4\n\r");
NU_Printf("Files Created -> ");
for (ii=0; ii < NUM_TASKS; ii++)
{
NU_Printf("%10d",Files_Created[ii]);
}
NU_Printf("\n\r");
NU_Printf("Files Deleted -> ");
for (ii=0; ii < NUM_TASKS; ii++)
{
NU_Printf("%10d", Files_Deleted[ii]);
}
NU_Printf("\n\r");
NU_Printf("Files Renamed -> ");
for (ii=0; ii < NUM_TASKS; ii++)
{
NU_Printf("%10d", Files_Renamed[ii]);
}
NU_Printf("\n\r");
NU_Printf("Files Read -> ");
for (ii=0; ii < NUM_TASKS; ii++)
{
NU_Printf("%10d", Files_Read[ii]);
}
NU_Printf("\n\r");
NU_Printf("Dirs Created -> ");
for (ii=0; ii < NUM_TASKS; ii++)
{
NU_Printf("%10d", Directories_Created[ii]);
}
NU_Printf("\n\r");
NU_Printf("Dirs Deleted -> ");
for (ii=0; ii < NUM_TASKS; ii++)
{
NU_Printf("%10d", Directories_Deleted[ii]);
}
NU_Printf("\n\r");
NU_Printf("Errors -> ");
for (ii=0; ii < NUM_TASKS; ii++)
{
NU_Printf("%10d", Errors[ii]);
}
NU_Printf("\n\r");
NU_Printf("\n\n\n\r");
/* Sleep 2 seconds */
NU_Sleep(50);
}
}
#endif
/*---------------------------------------------*/
void bail_out(void)
{
NU_Suspend_Task(NU_Current_Task_Pointer());
}
/* Debug routine for FIQ */
VOID INT_FIQ_Lisr()
{
#ifdef NU_PRINTF
printf("FIQ Timer has fired\n");
#endif
NU_Printf("FIQ Timer has fired\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -