Add flag param in the new flash api.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 1 Sep 2010 10:58:48 +0000 (10:58 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 1 Sep 2010 10:58:48 +0000 (10:58 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4215 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/drv/flash.h

index 9552a2e6a7b76172b780610176db5dad7509014f..461b67c47fda21af2b62fc0d50568cef1ae1965d 100644 (file)
 #include <io/kfile.h>
 #include <io/kfile_block.h>
 
+#include <cpu/attr.h>
+
+#if COMPILER_C99
+       #define flash_init(...)           PP_CAT(flash_init ## _, COUNT_PARMS(__VA_ARGS__)) (__VA_ARGS__)
+#else
+       #define flash_init(args...)       PP_CAT(flash_init ## _, COUNT_PARMS(args)) (args)
+#endif
+
 /*
  * Embedded flash error flags
  */
@@ -91,24 +99,21 @@ INLINE Flash *FLASH_CAST(KBlock *fls)
        return (Flash *)fls;
 }
 
-void flash_hw_init(Flash *fls);
-void flash_hw_initUnbuffered(Flash *fls);
+void flash_hw_init(Flash *fls, int flags);
+void flash_hw_initUnbuffered(Flash *fls, int flags);
 
 #include CPU_HEADER(flash)
 
-INLINE void flash_init(Flash *fls)
-{
-       flash_hw_init(fls);
-
-       #if !CONFIG_FLASH_DISABLE_OLD_API
-               kfileblock_init(&fls->fdblk, &fls->blk);
-       #endif /* !CONFIG_FLASH_DISABLE_OLD_API */
-}
+#define flash_init_2(fls, flags)    (flags & KB_OPEN_UNBUFF) ? \
+                                                                               flash_hw_initUnbuffered(fls, flags) : flash_hw_init(fls, flags)
 
-INLINE void flash_initUnbuffered(Flash *fls)
+#if !CONFIG_FLASH_DISABLE_OLD_API
+INLINE DEPRECATED void flash_init_1(Flash *fls)
 {
-       flash_hw_initUnbuffered(fls);
+       flash_hw_init(fls, 0);
+       kfileblock_init(&fls->fdblk, &fls->blk);
 }
+#endif /* !CONFIG_FLASH_DISABLE_OLD_API */
 
 #include CPU_HEADER(flash)