📄 flashdiskstart.c
字号:
/*
**********************************************************************
* Micrium, Inc.
* 949 Crestview Circle
* Weston, FL 33327-1848
*
* uC/FS
*
* (c) Copyright 2001 - 2003, Micrium, Inc.
* All rights reserved.
*
***********************************************************************
----------------------------------------------------------------------
File : Flash_Sample.c
Purpose : Sample program for using the file system with Flash driver
---------------------------END-OF-HEADER------------------------------
*/
#include "fs_api.h"
#include <stdio.h>
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
void MainTask(void);
void MainTask(void) {
/* buffers used to read and write to file */
char acWriteText[20] = "Hello World";
char acReadText[20];
FS_FILE* pFile;
if (FS_IoCtl("flash:", FS_CMD_REQUIRES_FORMAT, 0, 0)) {
FS_FormatLow("flash:"); /* Erase & Low-level format the flash */
FS_Format("flash:", NULL); /* High-level format the flash */
}
/* Now Flash is ready to be used with file system */
pFile = FS_FOpen("flash:\\hello.txt", "w+"); /* open a file for read/write */
FS_FWrite(acWriteText, 1, sizeof(acWriteText), pFile); /* write to file */
FS_FSeek(pFile, 0, FS_SEEK_SET); /* set file position to 0 */
FS_FRead(acReadText, 1, sizeof(acReadText), pFile); /* read the file */
FS_X_Log("This text was written to flash:\\hello.txt: \n");
FS_X_Log(acReadText);
FS_FClose(pFile); /* Close the file */
}
/*************************** End of file ****************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -