⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flash_test_simple.c

📁 niosii c程序 niosii c程序
💻 C
字号:
#include <stdio.h>
#include <string.h>
#include "sys/alt_flash.h"
#define BUF_SIZE 30
int main ()
{
alt_flash_fd* fd;
int ret_code;
char source[BUF_SIZE]="welcome to red logic world";
printf("the source is:%s\n",source);
char dest[BUF_SIZE];
/* Initialize the source buffer to all 0xAA */
//memset(source, 0xa, BUF_SIZE);
fd = alt_flash_open_dev("/dev/ext_flash");
if (fd)
{
  printf("flash open success.\n");
  ret_code = alt_write_flash(fd, 0, source, BUF_SIZE);
  if (!ret_code)
  {
    printf("data write to flash success.\n");
    ret_code = alt_read_flash(fd, 0, dest, BUF_SIZE);
    if (!ret_code)
    {
      printf("data read Success.\n");
      printf("data read is:");
      printf("%s\n",dest);
      printf("flash_test_simple end\n");
    }
  }   
  alt_flash_close_dev(fd);
}
else
{
printf("Can't open flash device\n");
}
return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -