aboutsummaryrefslogtreecommitdiffstats
path: root/os/fs/fatfs/fatfs_fsimpl.hpp
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-04 15:11:03 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-04 15:11:03 +0000
commit6f470322d0241e1923bd1d83d66f291aff571658 (patch)
tree7841acf3bdcc48add6bea4f23a7aef794e3e9531 /os/fs/fatfs/fatfs_fsimpl.hpp
parent2fa014a7be21c7d893fbbb2101c97c51971321b9 (diff)
downloadChibiOS-6f470322d0241e1923bd1d83d66f291aff571658.tar.gz
ChibiOS-6f470322d0241e1923bd1d83d66f291aff571658.tar.bz2
ChibiOS-6f470322d0241e1923bd1d83d66f291aff571658.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5032 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/fs/fatfs/fatfs_fsimpl.hpp')
-rw-r--r--os/fs/fatfs/fatfs_fsimpl.hpp74
1 files changed, 64 insertions, 10 deletions
diff --git a/os/fs/fatfs/fatfs_fsimpl.hpp b/os/fs/fatfs/fatfs_fsimpl.hpp
index cdb46bc66..2ab7fc4b0 100644
--- a/os/fs/fatfs/fatfs_fsimpl.hpp
+++ b/os/fs/fatfs/fatfs_fsimpl.hpp
@@ -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.