Change save fuinction for SD card calibration data
This commit is contained in:
parent
42ca1a01b5
commit
d04d8ebf9d
@ -43,29 +43,25 @@ static void get_controller_folder_path(char *path, size_t size)
|
|||||||
* @param[in,out] controller_folder
|
* @param[in,out] controller_folder
|
||||||
* @return 0 if opened, 1 if created and opened, -1 if error.
|
* @return 0 if opened, 1 if created and opened, -1 if error.
|
||||||
*/
|
*/
|
||||||
static int open_or_create_controller_folder(DIR *controller_folder)
|
static int create_controller_folder(void)
|
||||||
{
|
{
|
||||||
char foldername[48];
|
char foldername[48];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
FRESULT filesystem_result;
|
FRESULT filesystem_result;
|
||||||
|
DIR folder;
|
||||||
if (!controller_folder)
|
|
||||||
return -1001;
|
|
||||||
|
|
||||||
get_controller_folder_path(foldername, sizeof(foldername));
|
get_controller_folder_path(foldername, sizeof(foldername));
|
||||||
|
|
||||||
/* Check if folder is present */
|
/* Check if folder is present */
|
||||||
filesystem_result = f_opendir(controller_folder, foldername);
|
filesystem_result = f_opendir(&folder, foldername);
|
||||||
if (filesystem_result == FR_OK) {
|
if (filesystem_result == FR_OK) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
f_closedir(&folder);
|
||||||
} else {
|
} else {
|
||||||
filesystem_result = f_mkdir(foldername);
|
filesystem_result = f_mkdir(foldername);
|
||||||
if (filesystem_result == FR_OK) {
|
if (filesystem_result == FR_OK) {
|
||||||
filesystem_result = f_opendir(controller_folder, foldername);
|
f_closedir(&folder);
|
||||||
if (filesystem_result == FR_OK)
|
ret = 1;
|
||||||
ret = 1;
|
|
||||||
else
|
|
||||||
ret = -1;
|
|
||||||
} else {
|
} else {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@ -79,7 +75,6 @@ static int open_or_create_controller_folder(DIR *controller_folder)
|
|||||||
|
|
||||||
int sd_card_settings_save_calibration(float sens_deviation, float offset, bool active)
|
int sd_card_settings_save_calibration(float sens_deviation, float offset, bool active)
|
||||||
{
|
{
|
||||||
DIR folder;
|
|
||||||
FIL cal_file;
|
FIL cal_file;
|
||||||
int status;
|
int status;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
@ -87,8 +82,8 @@ int sd_card_settings_save_calibration(float sens_deviation, float offset, bool a
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
char buff[256];
|
char buff[256];
|
||||||
|
|
||||||
status = open_or_create_controller_folder(&folder);
|
status = create_controller_folder();
|
||||||
f_closedir(&folder);
|
|
||||||
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
return -2;
|
return -2;
|
||||||
|
Loading…
Reference in New Issue
Block a user