git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9609 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
5a3cec6d00
commit
562e6c0313
|
@ -105,4 +105,89 @@ void mfsStop(MFSDriver *devp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mounts a managed flash storage.
|
||||||
|
* @details This functions checks the storage internal state and eventually
|
||||||
|
* performs the required initialization or repair operations.
|
||||||
|
*
|
||||||
|
* @param[in] devp pointer to the @p MFSDriver object
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
mfs_error_t mfsMount(MFSDriver *devp) {
|
||||||
|
|
||||||
|
(void)devp;
|
||||||
|
|
||||||
|
return MFS_NOERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unmounts a manage flash storage.
|
||||||
|
*/
|
||||||
|
mfs_error_t mfsUnmount(MFSDriver *devp) {
|
||||||
|
|
||||||
|
(void)devp;
|
||||||
|
|
||||||
|
return MFS_NOERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieves and reads a data record.
|
||||||
|
*
|
||||||
|
* @param[in] devp pointer to the @p MFSDriver object
|
||||||
|
* @param[in] id record numeric identifier
|
||||||
|
* @param[in,out] np on input is the maximum buffer size, on return it is
|
||||||
|
* the size of the data copied into the buffer
|
||||||
|
* @param[in] buffer pointer to a buffer for record data
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
mfs_error_t mfsReadRecord(MFSDriver *devp, uint32_t id,
|
||||||
|
uint32_t *np, uint8_t *buffer) {
|
||||||
|
|
||||||
|
(void)devp;
|
||||||
|
(void)id;
|
||||||
|
(void)np;
|
||||||
|
(void)buffer;
|
||||||
|
|
||||||
|
return MFS_NOERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates or updates a data record.
|
||||||
|
*
|
||||||
|
* @param[in] devp pointer to the @p MFSDriver object
|
||||||
|
* @param[in] id record numeric identifier
|
||||||
|
* @param[in] n size of data to be written, it cannot be zero
|
||||||
|
* @param[in] buffer pointer to a buffer for record data
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
mfs_error_t mfsUpdateRecord(MFSDriver *devp, uint32_t id,
|
||||||
|
uint32_t n, const uint8_t *buffer) {
|
||||||
|
|
||||||
|
(void)devp;
|
||||||
|
(void)id;
|
||||||
|
(void)n;
|
||||||
|
(void)buffer;
|
||||||
|
|
||||||
|
return MFS_NOERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erases a data record.
|
||||||
|
*
|
||||||
|
* @param[in] devp pointer to the @p MFSDriver object
|
||||||
|
* @param[in] id record numeric identifier
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
mfs_error_t mfsEraseRecord(MFSDriver *devp, uint32_t id) {
|
||||||
|
|
||||||
|
(void)devp;
|
||||||
|
(void)id;
|
||||||
|
|
||||||
|
return MFS_NOERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -52,17 +52,32 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Driver state machine possible states.
|
* @brief Type of driver state machine states.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MFS_UNINIT = 0,
|
MFS_UNINIT = 0,
|
||||||
MFS_STOP = 1,
|
MFS_STOP = 1,
|
||||||
MFS_READY = 2,
|
MFS_READY = 2,
|
||||||
MFS_ACTIVE = 3
|
MFS_MOUNTED = 3,
|
||||||
|
MFS_ACTIVE = 4
|
||||||
} mfs_state_t;
|
} mfs_state_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Bank header.
|
* @brief Type of an MFS error code.
|
||||||
|
* @note Errors are negative integers, informative warnings are positive
|
||||||
|
* integers.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
MFS_NOERROR = 0,
|
||||||
|
MFS_REPAIR_WARNING = 1,
|
||||||
|
MFS_GC_WARNING = 2,
|
||||||
|
MFS_ID_NOT_FOUND = -1,
|
||||||
|
MFS_CRC_ERROR = -2,
|
||||||
|
MFS_FLASH_FAILURE = -3
|
||||||
|
} mfs_error_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a bank header.
|
||||||
* @note The header resides in the first 16 bytes of a bank extending
|
* @note The header resides in the first 16 bytes of a bank extending
|
||||||
* to the next page boundary.
|
* to the next page boundary.
|
||||||
*/
|
*/
|
||||||
|
@ -86,7 +101,7 @@ typedef struct {
|
||||||
} mfs_bank_header_t;
|
} mfs_bank_header_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Data block header.
|
* @brief Type of a data block header.
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
|
@ -119,6 +134,22 @@ typedef struct {
|
||||||
* @brief Flash driver associated to this MFS instance.
|
* @brief Flash driver associated to this MFS instance.
|
||||||
*/
|
*/
|
||||||
BaseFlash *flashp;
|
BaseFlash *flashp;
|
||||||
|
/**
|
||||||
|
* @brief Base sector index for bank 0.
|
||||||
|
*/
|
||||||
|
flash_sector_t bank0_start;
|
||||||
|
/**
|
||||||
|
* #brief Number of sectors for bank 0.
|
||||||
|
*/
|
||||||
|
flash_sector_t bank0_sectors;
|
||||||
|
/**
|
||||||
|
* @brief Base sector index for bank 1.
|
||||||
|
*/
|
||||||
|
flash_sector_t bank1_start;
|
||||||
|
/**
|
||||||
|
* #brief Number of sectors for bank 1.
|
||||||
|
*/
|
||||||
|
flash_sector_t bank1_sectors;
|
||||||
} MFSConfig;
|
} MFSConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,6 +182,13 @@ extern "C" {
|
||||||
void mfsObjectInit(MFSDriver *devp);
|
void mfsObjectInit(MFSDriver *devp);
|
||||||
void mfsStart(MFSDriver *devp, const MFSConfig *config);
|
void mfsStart(MFSDriver *devp, const MFSConfig *config);
|
||||||
void mfsStop(MFSDriver *devp);
|
void mfsStop(MFSDriver *devp);
|
||||||
|
mfs_error_t mfsMount(MFSDriver *devp);
|
||||||
|
mfs_error_t mfsUnmount(MFSDriver *devp);
|
||||||
|
mfs_error_t mfsReadRecord(MFSDriver *devp, uint32_t id,
|
||||||
|
uint32_t *np, uint8_t *buffer);
|
||||||
|
mfs_error_t mfsUpdateRecord(MFSDriver *devp, uint32_t id,
|
||||||
|
uint32_t n, const uint8_t *buffer);
|
||||||
|
mfs_error_t mfsEraseRecord(MFSDriver *devp, uint32_t id);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -99,6 +99,7 @@ include $(CHIBIOS)/os/rt/rt.mk
|
||||||
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
||||||
# Other files (optional).
|
# Other files (optional).
|
||||||
include $(CHIBIOS)/os/ex/Micron/m25q.mk
|
include $(CHIBIOS)/os/ex/Micron/m25q.mk
|
||||||
|
include $(CHIBIOS)/os/ex/subsystems/mfs/mfs.mk
|
||||||
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
|
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
|
||||||
|
|
||||||
# Define linker script file here
|
# Define linker script file here
|
||||||
|
@ -115,6 +116,7 @@ CSRC = $(STARTUPSRC) \
|
||||||
$(BOARDSRC) \
|
$(BOARDSRC) \
|
||||||
$(STREAMSSRC) \
|
$(STREAMSSRC) \
|
||||||
$(M25QSRC) \
|
$(M25QSRC) \
|
||||||
|
$(MFSSRC) \
|
||||||
main.c
|
main.c
|
||||||
|
|
||||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
@ -148,7 +150,7 @@ ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
|
||||||
INCDIR = $(CHIBIOS)/os/license \
|
INCDIR = $(CHIBIOS)/os/license \
|
||||||
$(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
|
$(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
|
||||||
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(M25QINC) \
|
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(M25QINC) \
|
||||||
$(STREAMSINC) $(CHIBIOS)/os/various
|
$(MFSINC) $(STREAMSINC) $(CHIBIOS)/os/various
|
||||||
|
|
||||||
#
|
#
|
||||||
# Project, sources and paths
|
# Project, sources and paths
|
||||||
|
|
Loading…
Reference in New Issue