stm32的flash分为code area和data area吗
答案:1 悬赏:60 手机版
解决时间 2021-01-11 09:05
- 提问者网友:难遇难求
- 2021-01-10 19:13
stm32的flash分为code area和data area吗
最佳答案
- 五星知识达人网友:行路难
- 2021-01-10 20:28
给stm32移植fatfs文件系统,今天终于取得阶段性胜利。只需要提供这样几个函数即可
DSTATUS disk_initialize (BYTE);
DSTATUS disk_status (BYTE);
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); // 如果实现只读的文件系统就不需要了。
DRESULT disk_ioctl (BYTE, BYTE, void*);
移植成功后,可以用如下方式读取SD卡了,实在太方便了,和PC机上编程差不了多少。
unsigned int i;
BYTE buffer[512]; // file copy buffer
FATFS fs; // Work area (file system object) for logical drive
FIL fsrc; // file objects
FRESULT res; // FatFs function common result code
UINT br; // File R/W count
USART1_Puts("Now, I'll read file 'i2c/uart.lst'.\n");
// Register a work area for logical drive 0
f_mount(0, &fs);
// Open source file
res = f_open(&fsrc, "i2c/uart.lst", FA_OPEN_EXISTING | FA_READ);
if (res)
{
USART1_Puts("Can't open i2c/uart.lst for read. :-(\n");
goto exit;
}
for (;;) {
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
if (res || br == 0) break; // error or eof
for( i = 0; i < br; ++i )
USART1_Putc(buffer[i]);
}
f_close(&fsrc);
exit:
// Unregister a work area before discard it
f_mount(0, NULL);
DSTATUS disk_initialize (BYTE);
DSTATUS disk_status (BYTE);
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); // 如果实现只读的文件系统就不需要了。
DRESULT disk_ioctl (BYTE, BYTE, void*);
移植成功后,可以用如下方式读取SD卡了,实在太方便了,和PC机上编程差不了多少。
unsigned int i;
BYTE buffer[512]; // file copy buffer
FATFS fs; // Work area (file system object) for logical drive
FIL fsrc; // file objects
FRESULT res; // FatFs function common result code
UINT br; // File R/W count
USART1_Puts("Now, I'll read file 'i2c/uart.lst'.\n");
// Register a work area for logical drive 0
f_mount(0, &fs);
// Open source file
res = f_open(&fsrc, "i2c/uart.lst", FA_OPEN_EXISTING | FA_READ);
if (res)
{
USART1_Puts("Can't open i2c/uart.lst for read. :-(\n");
goto exit;
}
for (;;) {
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
if (res || br == 0) break; // error or eof
for( i = 0; i < br; ++i )
USART1_Putc(buffer[i]);
}
f_close(&fsrc);
exit:
// Unregister a work area before discard it
f_mount(0, NULL);
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯