aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2015-03-11 00:16:09 +1000
committerinmarket <andrewh@inmarket.com.au>2015-03-11 00:16:09 +1000
commit84ae564bfc20337a1cee21c734c1cea5bb6a272c (patch)
treec40164e5ea422303dc93e10939a5d4b8289879d5 /src
parent865b7887d067254259e67d67c046497caa616d2c (diff)
downloaduGFX-84ae564bfc20337a1cee21c734c1cea5bb6a272c.tar.gz
uGFX-84ae564bfc20337a1cee21c734c1cea5bb6a272c.tar.bz2
uGFX-84ae564bfc20337a1cee21c734c1cea5bb6a272c.zip
Support ChibiOS V3 changes to the FileStream API
Diffstat (limited to 'src')
-rw-r--r--src/gfile/gfile.h9
-rw-r--r--src/gfile/gfile_fs_chibios.c27
-rw-r--r--src/gos/gos_chibios.c4
3 files changed, 26 insertions, 14 deletions
diff --git a/src/gfile/gfile.h b/src/gfile/gfile.h
index cc1e9c4b..ad590fbc 100644
--- a/src/gfile/gfile.h
+++ b/src/gfile/gfile.h
@@ -307,20 +307,21 @@ extern "C" {
#if (GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS) || defined(__DOXYGEN__)
/**
- * @brief Open file from a ChibiOS BaseFileStream
+ * @brief Open file from a ChibiOS FileStream
*
- * @param[in] BaseFileStreamPtr The BaseFileStream to open as a GFILE
+ * @param[in] FileStreamPtr The BaseFileStream (ChibiOS V2) or FileStream (ChibiOS V3) to open as a GFILE
* @param[in] mode The mode.
*
* @return Valid GFILE on success, 0 otherwise
*
* @note The modes are the same modes as in @p gfileOpen(). The
- * open mode is NOT compared against the BaseFileStream capabilities.
+ * open mode is NOT compared against the FileStream capabilities.
* @note Supported operations are: read, write, getpos, setpos, eof and getsize
*
* @api
*/
- GFILE * gfileOpenBaseFileStream(void *BaseFileStreamPtr, const char *mode);
+ GFILE * gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode);
+ #define gfileOpenBaseFileStream(f,m) gfileOpenChibiOSFileStream(f,m)
#endif
#if GFILE_NEED_MEMFS || defined(__DOXYGEN__)
diff --git a/src/gfile/gfile_fs_chibios.c b/src/gfile/gfile_fs_chibios.c
index 72826e28..9c3b156f 100644
--- a/src/gfile/gfile_fs_chibios.c
+++ b/src/gfile/gfile_fs_chibios.c
@@ -6,7 +6,7 @@
*/
/********************************************************
- * The ChibiOS BaseFileStream file-system
+ * The ChibiOS FileStream file-system
********************************************************/
#include "gfx.h"
@@ -34,23 +34,32 @@ static const GFILEVMT FsCHIBIOSVMT = {
#endif
};
+#if CH_KERNEL_MAJOR == 2
+ #define FileStream BaseFileStream
+ #define fileStreamClose chFileStreamClose
+ #define fileStreamRead chSequentialStreamRead
+ #define fileStreamWrite chSequentialStreamWrite
+ #define fileStreamSeek chFileStreamSeek
+ #define fileStreamGetSize chFileStreamGetSize
+#endif
+
static void ChibiOSBFSClose(GFILE *f) {
- chFileStreamClose(((BaseFileStream *)f->obj));
+ fileStreamClose(((FileStream *)f->obj));
}
static int ChibiOSBFSRead(GFILE *f, void *buf, int size) {
- return chSequentialStreamRead(((BaseFileStream *)f->obj), (uint8_t *)buf, size);
+ return fileStreamRead(((FileStream *)f->obj), (uint8_t *)buf, size);
}
static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size) {
- return chSequentialStreamWrite(((BaseFileStream *)f->obj), (uint8_t *)buf, size);
+ return fileStreamWrite(((FileStream *)f->obj), (uint8_t *)buf, size);
}
static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos) {
- chFileStreamSeek(((BaseFileStream *)f->obj), pos);
+ fileStreamSeek(((FileStream *)f->obj), pos);
return TRUE;
}
-static long int ChibiOSBFSGetsize(GFILE *f) { return chFileStreamGetSize(((BaseFileStream *)f->obj)); }
-static bool_t ChibiOSBFSEof(GFILE *f) { return f->pos >= chFileStreamGetSize(((BaseFileStream *)f->obj)); }
+static long int ChibiOSBFSGetsize(GFILE *f) { return fileStreamGetSize(((FileStream *)f->obj)); }
+static bool_t ChibiOSBFSEof(GFILE *f) { return f->pos >= fileStreamGetSize(((FileStream *)f->obj)); }
-GFILE * gfileOpenBaseFileStream(void *BaseFileStreamPtr, const char *mode) {
+GFILE * gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode) {
GFILE * f;
// Get an empty file and set the flags
@@ -59,7 +68,7 @@ GFILE * gfileOpenBaseFileStream(void *BaseFileStreamPtr, const char *mode) {
// File is open - fill in all the details
f->vmt = &FsCHIBIOSVMT;
- f->obj = BaseFileStreamPtr;
+ f->obj = FileStreamPtr;
f->pos = 0;
f->flags |= GFILEFLG_OPEN|GFILEFLG_CANSEEK;
return f;
diff --git a/src/gos/gos_chibios.c b/src/gos/gos_chibios.c
index faa007b5..62f5d8ee 100644
--- a/src/gos/gos_chibios.c
+++ b/src/gos/gos_chibios.c
@@ -28,7 +28,9 @@
#if !CH_CFG_USE_SEMAPHORES
#error "GOS: CH_CFG_USE_SEMAPHORES must be defined in chconf.h"
#endif
-
+
+#else
+ #error "GOS: Unsupported version of ChibiOS"
#endif
void _gosInit(void)