I want to store some data to sd card using FATFS (STM32 micro-controller), but i have a problem i want to create a new file every time if there is already a file (from older experiments). So can someone give an example how to do that? For example if there is already an existing file called TEST1.TXT on the sd card, the program should create TEST2.TXT, if TEST2.TXT exist then TEST3.TXT and so on...
FATFS myFATAFS;
FIL myFILE;
unsigned int testByte;
if(f_mount(&myFATAFS,SD_Path, 1)== FR_OK){
char myPath[] = "TEST1.TXT\n";
f_open(&myFILE, myPath, FA_WRITE | FA_CREATE_NEW);
//do something
f_close(&myFILE);
HAL_GPIO_TogglePin(LED2_GPIO_type, LED2_GPIO_pin);
}