git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5032 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
2fa014a7be
commit
6f470322d0
|
@ -44,14 +44,82 @@ using namespace chibios_fs;
|
|||
*/
|
||||
namespace chibios_fatfs {
|
||||
|
||||
typedef struct {
|
||||
uint32_t msg_code;
|
||||
union {
|
||||
struct {
|
||||
|
||||
};
|
||||
} op;
|
||||
} wmsg_t;
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSWrapper::FatFSServerThread *
|
||||
* chibios_fatfs::FatFSFileWrapper *
|
||||
*------------------------------------------------------------------------*/
|
||||
FatFSWrapper::FatFSServerThread::FatFSServerThread(void) :
|
||||
FatFSFileWrapper::FatFSFileWrapper(void) : fs(NULL) {
|
||||
|
||||
}
|
||||
|
||||
FatFSFileWrapper::FatFSFileWrapper(FatFSWrapper *fsref) : fs(fsref) {
|
||||
|
||||
}
|
||||
|
||||
size_t FatFSFileWrapper::write(const uint8_t *bp, size_t n) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t FatFSFileWrapper::read(uint8_t *bp, size_t n) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
msg_t FatFSFileWrapper::put(uint8_t b) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
msg_t FatFSFileWrapper::get(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t FatFSFileWrapper::getAndClearLastError(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
fileoffset_t FatFSFileWrapper::getSize(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
fileoffset_t FatFSFileWrapper::getPosition(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t FatFSFileWrapper::setPosition(fileoffset_t offset) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSFilesPool *
|
||||
*------------------------------------------------------------------------*/
|
||||
FatFSFilesPool::FatFSFilesPool(void) : MemoryPoolBuffer<FatFSFileWrapper,
|
||||
FATFS_MAX_FILES>() {
|
||||
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSServerThread *
|
||||
*------------------------------------------------------------------------*/
|
||||
FatFSServerThread::FatFSServerThread(void) :
|
||||
BaseStaticThread<FATFS_THREAD_STACK_SIZE>() {
|
||||
}
|
||||
|
||||
msg_t FatFSWrapper::FatFSServerThread::main() {
|
||||
msg_t FatFSServerThread::main() {
|
||||
msg_t sts;
|
||||
|
||||
setName("fatfs");
|
||||
|
@ -72,14 +140,14 @@ namespace chibios_fatfs {
|
|||
}
|
||||
}
|
||||
|
||||
void FatFSWrapper::FatFSServerThread::stop(void) {
|
||||
void FatFSServerThread::stop(void) {
|
||||
|
||||
sendMessage(MSG_TERMINATE);
|
||||
wait();
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSWrapper *
|
||||
* chibios_fatfs::FatFSWrapper *
|
||||
*------------------------------------------------------------------------*/
|
||||
FatFSWrapper::FatFSWrapper(void) {
|
||||
|
||||
|
@ -132,6 +200,11 @@ namespace chibios_fatfs {
|
|||
(void)fname;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void FatFSWrapper::close(BaseFileStreamInterface *file) {
|
||||
|
||||
(void)file;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -46,6 +46,13 @@
|
|||
#define FATFS_THREAD_PRIORITY NORMALPRIO
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum number of open files.
|
||||
*/
|
||||
#if !defined(FATFS_MAX_FILES) || defined(__DOXYGEN__)
|
||||
#define FATFS_MAX_FILES 16
|
||||
#endif
|
||||
|
||||
using namespace chibios_rt;
|
||||
using namespace chibios_fs;
|
||||
|
||||
|
@ -54,6 +61,59 @@ using namespace chibios_fs;
|
|||
*/
|
||||
namespace chibios_fatfs {
|
||||
|
||||
class FatFSWrapper;
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSFileWrapper *
|
||||
*------------------------------------------------------------------------*/
|
||||
class FatFSFileWrapper : public BaseFileStreamInterface {
|
||||
friend class FatFSWrapper;
|
||||
|
||||
protected:
|
||||
FatFSWrapper *fs;
|
||||
|
||||
public:
|
||||
FatFSFileWrapper(void);
|
||||
FatFSFileWrapper(FatFSWrapper *fsref);
|
||||
|
||||
virtual size_t write(const uint8_t *bp, size_t n);
|
||||
virtual size_t read(uint8_t *bp, size_t n);
|
||||
virtual msg_t put(uint8_t b);
|
||||
virtual msg_t get(void);
|
||||
virtual uint32_t getAndClearLastError(void);
|
||||
virtual fileoffset_t getSize(void);
|
||||
virtual fileoffset_t getPosition(void);
|
||||
virtual uint32_t setPosition(fileoffset_t offset);
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSFilesPool *
|
||||
*------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Class of memory pool of @p FatFSFileWrapper objects.
|
||||
*/
|
||||
class FatFSFilesPool : public MemoryPoolBuffer<FatFSFileWrapper,
|
||||
FATFS_MAX_FILES> {
|
||||
public:
|
||||
FatFSFilesPool(void);
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSServerThread *
|
||||
*------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Class of the internal server thread.
|
||||
*/
|
||||
class FatFSServerThread : public BaseStaticThread<FATFS_THREAD_STACK_SIZE> {
|
||||
private:
|
||||
FatFSFilesPool files;
|
||||
protected:
|
||||
virtual msg_t main(void);
|
||||
public:
|
||||
FatFSServerThread(void);
|
||||
virtual void stop(void);
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* chibios_fatfs::FatFSWrapper *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
@ -61,17 +121,10 @@ namespace chibios_fatfs {
|
|||
* @brief Class of the FatFS wrapper.
|
||||
*/
|
||||
class FatFSWrapper : public chibios_fs::BaseFileSystemInterface {
|
||||
friend class FatFSFileWrapper;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Class of the internal server thread.
|
||||
*/
|
||||
class FatFSServerThread : public BaseStaticThread<FATFS_THREAD_STACK_SIZE> {
|
||||
protected:
|
||||
virtual msg_t main(void);
|
||||
public:
|
||||
FatFSServerThread(void);
|
||||
virtual void stop(void);
|
||||
} server;
|
||||
FatFSServerThread server;
|
||||
|
||||
public:
|
||||
FatFSWrapper(void);
|
||||
|
@ -82,6 +135,7 @@ namespace chibios_fatfs {
|
|||
virtual BaseFileStreamInterface *openForRead(const char *fname);
|
||||
virtual BaseFileStreamInterface *openForWrite(const char *fname);
|
||||
virtual BaseFileStreamInterface *create(const char *fname);
|
||||
virtual void close(BaseFileStreamInterface *file);
|
||||
|
||||
/**
|
||||
* @brief Mounts the file system.
|
||||
|
|
14
os/fs/fs.hpp
14
os/fs/fs.hpp
|
@ -64,13 +64,6 @@ namespace chibios_fs {
|
|||
*/
|
||||
class BaseFileStreamInterface : public chibios_rt::BaseSequentialStreamInterface {
|
||||
public:
|
||||
/**
|
||||
* @brief File close and object destruction.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
virtual ~BaseFileStreamInterface(void) = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns an implementation dependent error code.
|
||||
*
|
||||
|
@ -191,6 +184,13 @@ namespace chibios_fs {
|
|||
* @api
|
||||
*/
|
||||
virtual BaseFileStreamInterface *create(const char *fname) = 0;
|
||||
|
||||
/**
|
||||
* @brief Closes a file.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
virtual void close(BaseFileStreamInterface *file) = 0;
|
||||
};
|
||||
}
|
||||
#endif /* _FS_HPP_ */
|
||||
|
|
|
@ -2081,7 +2081,7 @@ namespace chibios_rt {
|
|||
* @brief Template class encapsulating a mailbox and its elements.
|
||||
*/
|
||||
template<class T, size_t N>
|
||||
class MemoryPoolBuffer : MemoryPool {
|
||||
class MemoryPoolBuffer : public MemoryPool {
|
||||
private:
|
||||
T pool_buf[N];
|
||||
|
||||
|
|
Loading…
Reference in New Issue