* \author Daniele Basile <asterix@develer.com>
*
* $WIZ$ module_name = "flash"
-* $WIZ$ module_depends = "kfile"
+* $WIZ$ module_depends = "kfile", "kfile_block", "kblock"
+* $WIZ$ module_configuration = "bertos/cfg/cfg_emb_flash.h"
*/
#ifndef DRV_FLASH_H
#include "cfg/cfg_emb_flash.h"
#include <cfg/macros.h>
+#include <cfg/compiler.h>
#include <io/kblock.h>
#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
*/
#define FLASH_WR_OK 0 ///< Write ok.
#define FLASH_NOT_ERASED BV(1) ///< Flash memory was not erased before to write it.
#define FLASH_WR_PROTECT BV(2) ///< Write not allowed the flash memory was protected.
-#define FLASH_WR_TIMEOUT BV(3) ///<
+#define FLASH_WR_TIMEOUT BV(3) ///< Timeout while writing
+#define FLASH_WR_ERR BV(4) ///< Invalid command and/or a bad keywords
struct FlashHardware;
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)
#endif /* DRV_FLASH_H */