Easier VFS integration.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15187 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-12-04 11:19:22 +00:00
parent 1a92311b0c
commit e8520182e0
15 changed files with 51 additions and 49 deletions

View File

@ -69,7 +69,7 @@
* @brief Enables the VFS FatFS Driver.
*/
#if !defined(VFS_CFG_ENABLE_DRV_FATFS) || defined(__DOXYGEN__)
#define VFS_CFG_ENABLE_DRV_FATFS TRUE
#define VFS_CFG_ENABLE_DRV_FATFS FALSE
#endif
/** @} */

View File

@ -20,11 +20,6 @@
#include "ch.h"
#include "hal.h"
#include "vfs.h"
#include "drvoverlay.h"
#include "drvstreams.h"
#if defined(DEMO_USE_FATFS)
#include "drvfatfs.h"
#endif
#include "rt_test_root.h"
#include "oslib_test_root.h"
@ -35,7 +30,6 @@
#include "portab.h"
/*===========================================================================*/
/* Card insertion monitor. */
/*===========================================================================*/
@ -45,7 +39,7 @@
*/
static event_source_t inserted_event, removed_event;
#if defined(DEMO_USE_FATFS)
#if VFS_CFG_ENABLE_DRV_FATFS == TRUE
#define POLLING_INTERVAL 10
#define POLLING_DELAY 10
@ -216,7 +210,7 @@ static void InsertHandler(eventid_t id) {
(void)id;
#if defined(DEMO_USE_FATFS)
#if VFS_CFG_ENABLE_DRV_FATFS == TRUE
msg_t err;
#if HAL_USE_SDC
@ -249,7 +243,7 @@ static void RemoveHandler(eventid_t id) {
(void)id;
#if defined(DEMO_USE_FATFS)
#if VFS_CFG_ENABLE_DRV_FATFS == TRUE
#if HAL_USE_SDC
sdcDisconnect(&PORTAB_SDCD1);
#else
@ -317,7 +311,7 @@ int main(void) {
sdStart(&PORTAB_SD1, NULL);
nullObjectInit(&nullstream);
#if defined(DEMO_USE_FATFS)
#if VFS_CFG_ENABLE_DRV_FATFS == TRUE
/* Activates the SDC driver using default configuration.*/
sdcStart(&PORTAB_SDCD1, NULL);

View File

@ -108,8 +108,6 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk
# VFS files (optional).
include $(CHIBIOS)/os/vfs/vfs.mk
include $(CHIBIOS)/os/vfs/drivers/overlay/drvoverlay.mk
include $(CHIBIOS)/os/vfs/drivers/streams/drvstreams.mk
# Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional).

View File

@ -108,9 +108,6 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk
# VFS files (optional).
include $(CHIBIOS)/os/vfs/vfs.mk
include $(CHIBIOS)/os/vfs/drivers/overlay/drvoverlay.mk
include $(CHIBIOS)/os/vfs/drivers/streams/drvstreams.mk
include $(CHIBIOS)/os/vfs/drivers/fatfs/drvfatfs.mk
# Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional).
@ -159,7 +156,7 @@ CPPWARN = -Wall -Wextra -Wundef
#
# List all user C define here, like -D_DEBUG=1
UDEFS = -DDEMO_USE_FATFS
UDEFS =
# Define ASM defines here
UADEFS =

View File

@ -28,7 +28,8 @@
#include <string.h>
#include "vfs.h"
#include "drvfatfs.h"
#if (VFS_CFG_ENABLE_DRV_FATFS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@ -530,4 +531,6 @@ msg_t drvFatFSUnmount(const char *name) {
return translate_error(res);
}
#endif /* VFS_CFG_ENABLE_DRV_FATFS == TRUE */
/** @} */

View File

@ -28,6 +28,8 @@
#ifndef DRVFATFS_H
#define DRVFATFS_H
#if (VFS_CFG_ENABLE_DRV_FATFS == TRUE) || defined(__DOXYGEN__)
#include "ff.h"
/*===========================================================================*/
@ -186,6 +188,8 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
#endif /* VFS_CFG_ENABLE_DRV_FATFS == TRUE */
#endif /* DRVFATFS_H */
/** @} */

View File

@ -1,9 +0,0 @@
# List of all the FatFS VFS driver files.
DRVFATFSSRC := $(CHIBIOS)/os/vfs/drivers/fatfs/drvfatfs.c
# Required include directories
DRVFATFSINC := $(CHIBIOS)/os/vfs/drivers/fatfs
# Shared variables
ALLCSRC += $(DRVFATFSSRC)
ALLINC += $(DRVFATFSINC)

View File

@ -28,7 +28,8 @@
#include <string.h>
#include "vfs.h"
#include "drvoverlay.h"
#if (VFS_CFG_ENABLE_DRV_OVERLAY == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@ -310,4 +311,6 @@ msg_t drvOverlayRegisterDriver(vfs_overlay_driver_t *vodp,
return err;
}
#endif /* VFS_CFG_ENABLE_DRV_OVERLAY == TRUE */
/** @} */

View File

@ -28,6 +28,8 @@
#ifndef DRVOVERLAY_H
#define DRVOVERLAY_H
#if (VFS_CFG_ENABLE_DRV_OVERLAY == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
/*===========================================================================*/
@ -158,6 +160,8 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
#endif /* VFS_CFG_ENABLE_DRV_OVERLAY == TRUE */
#endif /* DRVOVERLAY_H */
/** @} */

View File

@ -1,9 +0,0 @@
# List of all the overlay VFS driver files.
DRVOVERLAYSRC := $(CHIBIOS)/os/vfs/drivers/overlay/drvoverlay.c
# Required include directories
DRVOVERLAYINC := $(CHIBIOS)/os/vfs/drivers/overlay
# Shared variables
ALLCSRC += $(DRVOVERLAYSRC)
ALLINC += $(DRVOVERLAYINC)

View File

@ -28,7 +28,8 @@
#include <string.h>
#include "vfs.h"
#include "drvstreams.h"
#if (VFS_CFG_ENABLE_DRV_STREAMS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@ -306,4 +307,6 @@ vfs_driver_t *drvStreamsObjectInit(vfs_streams_driver_t *vsdp,
return (vfs_driver_t *)vsdp;
}
#endif /* VFS_CFG_ENABLE_DRV_STREAMS == TRUE */
/** @} */

View File

@ -28,6 +28,8 @@
#ifndef DRVSTREAMS_H
#define DRVSTREAMS_H
#if (VFS_CFG_ENABLE_DRV_STREAMS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
/*===========================================================================*/
@ -194,6 +196,8 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
#endif /* VFS_CFG_ENABLE_DRV_STREAMS == TRUE */
#endif /* DRVSTREAMS_H */
/** @} */

View File

@ -1,9 +0,0 @@
# List of all the streams VFS driver files.
DRVSTREAMSSRC := $(CHIBIOS)/os/vfs/drivers/streams/drvstreams.c
# Required include directories
DRVSTREAMSINC := $(CHIBIOS)/os/vfs/drivers/streams
# Shared variables
ALLCSRC += $(DRVSTREAMSSRC)
ALLINC += $(DRVSTREAMSINC)

View File

@ -84,6 +84,19 @@
#include "vfsnodes.h"
#include "vfsdrivers.h"
/* File System drivers.*/
#if VFS_CFG_ENABLE_DRV_OVERLAY == TRUE
#include "drvoverlay.h"
#endif
#if VFS_CFG_ENABLE_DRV_STREAMS == TRUE
#include "drvstreams.h"
#endif
#if VFS_CFG_ENABLE_DRV_FATFS == TRUE
#include "drvfatfs.h"
#endif
/* Application code is suppored to export this symbol, it is expected to
exists.*/
extern vfs_driver_t *vfs_root;

View File

@ -1,9 +1,15 @@
# List of all the ChibiOS/VFS files.
VFSSRC := $(CHIBIOS)/os/vfs/src/vfsparser.c \
$(CHIBIOS)/os/vfs/src/vfs.c
$(CHIBIOS)/os/vfs/src/vfs.c \
$(CHIBIOS)/os/vfs/drivers/fatfs/drvfatfs.c \
$(CHIBIOS)/os/vfs/drivers/overlay/drvoverlay.c \
$(CHIBIOS)/os/vfs/drivers/streams/drvstreams.c
# Required include directories
VFSINC := $(CHIBIOS)/os/vfs/include
VFSINC := $(CHIBIOS)/os/vfs/include \
$(CHIBIOS)/os/vfs/drivers/fatfs \
$(CHIBIOS)/os/vfs/drivers/overlay \
$(CHIBIOS)/os/vfs/drivers/streams
# Shared variables
ALLCSRC += $(VFSSRC)