Clean up.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 10 Aug 2010 17:30:34 +0000 (17:30 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 10 Aug 2010 17:30:34 +0000 (17:30 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4159 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/drv/flash.h

index 509627428fcb183e2c66e6978a5c51fd69d50fb9..9119b44dfe37356550bade5576ab4e4ec5548b88 100644 (file)
 #ifndef DRV_FLASH_H
 #define DRV_FLASH_H
 
+#include "cfg/cfg_emb_flash.h"
+
 #include <cfg/macros.h>
 
 #include <io/kblock.h>
+#include <io/kfile.h>
+#include <io/kfile_block.h>
 
 /*
  * Embedded flash error flags
@@ -63,6 +67,12 @@ typedef struct Flash
 {
        KBlock blk;
        struct FlashHardware *hw;
+       #if !CONFIG_FLASH_DISABLE_OLD_API
+       union {
+               KFile fd;
+               KFileBlock fdblk;
+       } DEPRECATED;
+       #endif /* !CONFIG_FLASH_DISABLE_OLD_API */
 } Flash;
 
 /**
@@ -87,6 +97,10 @@ void flash_hw_initUnbuffered(Flash *fls);
 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 */
 }
 
 INLINE void flash_initUnbuffered(Flash *fls)
@@ -94,64 +108,6 @@ INLINE void flash_initUnbuffered(Flash *fls)
        flash_hw_initUnbuffered(fls);
 }
 
-#if 0
-/**
- * EmbFlash KFile context structure.
- */
-typedef struct Flash
-{
-       /**
-        * File descriptor.
-        */
-       KFile fd;
-
-       /**
-        * Flag for checking if current page is modified.
-        */
-       bool page_dirty;
-
-       /**
-        * Current buffered page.
-        */
-       page_t curr_page;
-
-       /**
-        * Temporary buffer cointaing data block to
-        * write on flash.
-        */
-       uint8_t page_buf[FLASH_PAGE_SIZE];
-} Flash;
-
-/**
-* ID for FLASH
-*/
-#define KFT_FLASH MAKE_ID('F', 'L', 'A', 'S')
-
-/**
-* Convert + ASSERT from generic KFile to Flash.
-*/
-INLINE Flash * FLASH_CAST(KFile *fd)
-{
-       ASSERT(fd->_type == KFT_FLASH);
-       return (Flash *)fd;
-}
-
-
-MOD_DEFINE(flash);
-
-/**
- *
- * Initialize PWM hw.
- */
-INLINE void flash_init(Flash *fd)
-{
-       flash_hw_init(fd);
-
-       MOD_INIT(flash);
-}
-
-#endif
-
 
 #endif /* DRV_FLASH_H */