-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: Load config from embedded fat12 file system
- Loading branch information
Showing
19 changed files
with
343 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
#pragma once | ||
|
||
int cf_init( | ||
void); | ||
const char *path); | ||
|
||
char *const *cf_get_pp_config( | ||
const char *tag); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,123 @@ | ||
/* | ||
* NodeFlight - platform for embedded control systems | ||
* Copyright (C) 2020 Max Sikström | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "disk_access.h" | ||
|
||
disk_access_t *disk_access[FF_VOLUMES]; | ||
#include "ff.h" | ||
|
||
#define DEBUG 0 | ||
|
||
#if DEBUG | ||
#include "vendor/tinyprintf/tinyprintf.h" | ||
#define PRINTF(...) tfp_printf(__VA_ARGS__) | ||
#else | ||
#define PRINTF(...) do {} while(0) | ||
#endif | ||
|
||
static disk_access_t *disk_access[FF_VOLUMES]; | ||
static int disks_mounted = 0; | ||
|
||
static FATFS *disk_fs[FF_VOLUMES]; | ||
|
||
/* Mount names */ | ||
const char *VolumeStr[FF_VOLUMES] = { | ||
"not_mounted_a", "not_mounted_b", "not_mounted_c", "not_mounted_d" | ||
}; | ||
|
||
void disk_access_init( | ||
void) | ||
{ | ||
int i; | ||
disks_mounted = 0; | ||
for (i = 0; i < FF_VOLUMES; i++) { | ||
disk_access[i] = NULL; | ||
disk_fs[i] = NULL; | ||
} | ||
} | ||
|
||
int disk_access_register( | ||
int disk_id, | ||
disk_access_t *dacc) | ||
{ | ||
if (disk_id < 0 || disk_id >= FF_VOLUMES) { | ||
char id_string[3] = "0:"; | ||
if (disks_mounted >= FF_VOLUMES) { | ||
return -1; | ||
} | ||
if (disk_access[disk_id] != NULL) { | ||
int disk_id = disks_mounted++; | ||
disk_access[disk_id] = dacc; | ||
VolumeStr[disk_id] = dacc->name; | ||
|
||
/* Allocate FATFS */ | ||
disk_fs[disk_id] = pvPortMalloc(sizeof(FATFS)); | ||
if (disk_fs[disk_id] == NULL) { | ||
return -1; | ||
} | ||
|
||
/* Mount via disk id */ | ||
id_string[0] = '0' + disk_id; | ||
if (FR_OK != f_mount(disk_fs[disk_id], id_string, 0)) { | ||
return -1; | ||
} | ||
disk_access[disk_id] = dacc; | ||
return 0; | ||
} | ||
|
||
disk_access_t *disk_access_get( | ||
int disk_id) | ||
/* | ||
* diskio interface for fatfs | ||
*/ | ||
|
||
DSTATUS disk_initialize ( | ||
BYTE pdrv) | ||
{ | ||
PRINTF("disk_initialize(%u)\n", pdrv); | ||
return disk_access[pdrv]->initialize(disk_access[pdrv]->storage); | ||
} | ||
|
||
DSTATUS disk_status ( | ||
BYTE pdrv) | ||
{ | ||
if (disk_id < 0 || disk_id >= FF_VOLUMES) { | ||
return NULL; | ||
} | ||
return disk_access[disk_id]; | ||
PRINTF("disk_status(%u)\n", pdrv); | ||
return disk_access[pdrv]->status(disk_access[pdrv]->storage); | ||
} | ||
|
||
DRESULT disk_read ( | ||
BYTE pdrv, | ||
BYTE *buff, | ||
LBA_t sector, | ||
UINT count) | ||
{ | ||
PRINTF("disk_read(%u, %p, %lu, %u)\n", pdrv, buff, sector, count); | ||
return disk_access[pdrv]->read(disk_access[pdrv]->storage, buff, sector, count); | ||
} | ||
|
||
DRESULT disk_write ( | ||
BYTE pdrv, | ||
const BYTE *buff, | ||
LBA_t sector, | ||
UINT count) | ||
{ | ||
PRINTF("disk_write(%u, %p, %lu, %u)\n", pdrv, buff, sector, count); | ||
return disk_access[pdrv]->write(disk_access[pdrv]->storage, buff, sector, count); | ||
} | ||
|
||
DRESULT disk_ioctl ( | ||
BYTE pdrv, | ||
BYTE cmd, | ||
void *buff) | ||
{ | ||
PRINTF("disk_ioctl(%u, %u, %p)\n", pdrv, cmd, buff); | ||
return disk_access[pdrv]->ioctl(disk_access[pdrv]->storage, cmd, buff); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.