FatFS now functional on STM32H7xx, added a target to the VFS demo.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15551 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2022-03-22 08:32:36 +00:00
parent d62c01ac48
commit 7fbd1ae369
10 changed files with 78 additions and 2 deletions

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/

View File

@ -216,6 +216,13 @@ static struct {
vfs_fatfs_file_node_c file_nodes[DRV_CFG_FATFS_FILE_NODES_NUM];
} vfs_fatfs_driver_static;
/**
* @brief Static members of @p vfs_fatfs_driver_c (non-cached).
*/
static struct {
FATFS fs[DRV_CFG_FATFS_FS_NUM];
} __nocache_vfs_fatfs_driver_static;
/*===========================================================================*/
/* Module local functions. */
/*===========================================================================*/
@ -816,7 +823,7 @@ void __drv_fatfs_init(void) {
chCoreAllocAlignedI);
chPoolObjectInit(&vfs_fatfs_driver_static.fs_nodes_pool,
sizeof (FATFS),
chCoreAllocAlignedI);
NULL);
/* Preloading pools.*/
chPoolLoadArray(&vfs_fatfs_driver_static.dir_nodes_pool,
@ -825,6 +832,9 @@ void __drv_fatfs_init(void) {
chPoolLoadArray(&vfs_fatfs_driver_static.file_nodes_pool,
&vfs_fatfs_driver_static.file_nodes[0],
DRV_CFG_FATFS_FILE_NODES_NUM);
chPoolLoadArray(&vfs_fatfs_driver_static.fs_nodes_pool,
&__nocache_vfs_fatfs_driver_static.fs[0],
DRV_CFG_FATFS_FS_NUM);
}
/**
@ -855,6 +865,7 @@ vfs_driver_c *drvFatFSObjectInit(vfs_fatfs_driver_c *vffdp) {
*/
msg_t drvFatFSMount(const char *name, bool mountnow) {
FATFS *fs;
FRESULT res;
fs = f_getfs(name);
if (fs == NULL) {
@ -864,7 +875,12 @@ msg_t drvFatFSMount(const char *name, bool mountnow) {
}
}
return translate_error(f_mount(fs, name, (BYTE)(mountnow ? 1 : 0)));
res = f_mount(fs, name, (BYTE)(mountnow ? 1 : 0));
if (res != FR_OK) {
chPoolFree(&vfs_fatfs_driver_static.fs_nodes_pool, (void *)fs);
}
return translate_error(res);
}
/**

View File

@ -43,6 +43,10 @@
/*===========================================================================*/
/* Configuration options checks.*/
#if !defined(DRV_CFG_FATFS_FS_NUM)
#error "DRV_CFG_FATFS_FS_NUM not defined in vfsconf.h"
#endif
#if !defined(DRV_CFG_FATFS_DIR_NODES_NUM)
#error "DRV_CFG_FATFS_DIR_NODES_NUM not defined in vfsconf.h"
#endif

View File

@ -141,6 +141,13 @@
*/
/*===========================================================================*/
/**
* @brief Maximum number of FatFS file systems mounted.
*/
#if !defined(DRV_CFG_FATFS_FS_NUM) || defined(__DOXYGEN__)
#define DRV_CFG_FATFS_FS_NUM 1
#endif
/**
* @brief Number of directory nodes pre-allocated in the pool.
*/