在线时间73 小时
UID2074257
注册时间2014-2-19
NXP金币15
TA的每日心情 | 开心 2019-9-17 17:18 |
---|
签到天数: 3 天 连续签到: 1 天 [LV.2]偶尔看看I
高级会员

- 积分
- 967
- 最后登录
- 2019-10-9
|
如题
我在k60flash上创建一个文件并初始化写入多字节数据
/* Open the flash device */
flash_set_file = fopen(FLASH_NAME, "rb");
if (flash_set_file == NULL) {
printf("\nUnable to open file %s", FLASH_NAME);
_task_block();
}
//初始化数据
system_time_struct.adjust_space = 0x24;
system_time_struct.timeServe = 0x00;
system_time_struct.timeZone = 0x1B;
// Disable sector cache
ioctl(flash_set_file, FLASH_IOCTL_ENABLE_SECTOR_CACHE, NULL);
// Move STRING_SIZE Bytes back
fseek(flash_set_file, -4, IO_SEEK_END);
//写入数据
len = write(flash_set_file, &system_time_struct, sizeof(system_time_struct));
单独更新某字节数据时,数据无法写入.错误代码:2563
memset(system_time_struct, 0, sizeof(system_time_struct));
system_time_struct.adjust_space = 0x11;
system_time_struct.timeServe = 0x11;
system_time_struct.timeZone = 0x11;
//Move STRING_SIZE Bytes back
fseek(flash_set_file, -4, IO_SEEK_END);
// Unprotecting the the FLASH might be required
ioctl_param = 0;
ioctl(flash_set_file, FLASH_IOCTL_WRITE_PROTECT, &ioctl_param);
len = write(flash_set_file, &system_time_struct, sizeof(system_time_struct));
if (len != sizeof(system_time_struct)) {
printf("\nError writing to the file. Error code: %d", _io_ferror(flash_set_file));
_task_block();
}
更新数据时,len=-1,错误代码:2563
请大神指点迷津:
1. K60自带MFS文件系统,是不是可以直接像操作文件一样管理flash存储?不用擦除数据,再写入数据,而根据地址寻找直接操作数据?
2. _io_ferror(flash_set_file)函数返回的错误代码,如何解析?是不是有相应的文档?
|
|