STM32 - How to include FatFS library properly to header files?

77 Views Asked by At

I am creating a new project on STM32CubeIDE to write some data to a SDCard with FatFS. When I want to include "fatfs.h" file in other header files i get a lot of unknown type name errors.

I created a project on STM32CubeIDE with STM32F429ZET selected as my target. I enabled SDIO and FATFS. I changed nothing and generated code.

When I want to mount, I can do it easily in main.c file since fatfs.h file is already included in main.c by stm32cubeide.

I want to move all sdcard related codes in another file called sd.c and sd.h. To do that, I created a folder called User, under Core folder, created 2 new files named sd.c and sd.h and added the path to User folder to the compiler. Then, I deleted the the #include "fatfs.h" line from main.c and included "sd.h" file in main.h. Here are sd.c and sd.h files:

SD.C:

#include "sd.h"

SD.H:

#ifndef USER_SD_H_
#define USER_SD_H_
#include "fatfs.h"
#endif /* USER_SD_H_ */

When I do it that way, I get many unknown type name errors in files "fatfs.h", "sd_diskio.c", "sd_diskio.h" and "ff_gen_drv.h". How can i include FATFS properly? Here's the full compile report:

https://pastebin.ubuntu.com/p/2Fr3bDz4HS/

0

There are 0 best solutions below