Move kfile interface to the io/ directory.
[bertos.git] / bertos / drv / dataflash.h
index 61858167b66f3f92461f0760b5732e72af622e3c..a60f30eaebd7858dfb0b0f1fc33e9efbf7b43166 100644 (file)
  *
  * -->
  *
- * \brief Function library for AT45DB081D Flash memory.
+ * \brief Function library for dataflash AT45DB family.
  *
+ * \version $Id$
  *
- * \version $Id: dataflash.h 20677 2008-02-19 14:29:52Z batt $
  * \author Daniele Basile <asterix@develer.com>
+ *
+ * $WIZ$ module_name = "dataflash"
+ * $WIZ$ module_depends = "kfile"
+ * $WIZ$ module_configuration = "bertos/cfg/cfg_dataflash.h"
+ * $WIZ$ module_hw = "bertos/hw/hw_dataflash.h", "bertos/hw/hw_dataflash.c"
  */
 
 
 #ifndef DRV_DATAFLASH_H
 #define DRV_DATAFLASH_H
 
-#include <kern/kfile.h>
 #include <cfg/compiler.h>
 
-#include <appconfig.h>
-
+#include <io/kfile.h>
+#include <fs/battfs.h>
 
 /**
  * Type definitions for dflash memory.
@@ -72,9 +76,10 @@ typedef void (dataflash_setCS_t)(bool);
  */
 typedef enum DataflashType
 {
-       DFT_AT45DB041B,
+       DFT_AT45DB041B = 0,
        DFT_AT45DB081D,
        DFT_AT45DB161D,
+       DFT_AT45DB642D,
        DFT_CNT
 } DataflashType;
 
@@ -82,7 +87,7 @@ typedef enum DataflashType
 /**
  * Dataflash KFile context structure.
  */
-typedef struct KFileDataflash
+typedef struct DataFlash
 {
        KFile fd;                       ///< File descriptor.
        KFile *channel;                 ///< Dataflash comm channel (usually SPI).
@@ -91,7 +96,7 @@ typedef struct KFileDataflash
        bool page_dirty;                ///< True if current_page is dirty (needs to be flushed).
        dataflash_setReset_t *setReset; ///< Callback used to set reset pin of dataflash.
        dataflash_setCS_t *setCS;       ///< Callback used to set CS pin of dataflash.
-} KFileDataflash;
+} DataFlash;
 
 /**
  * ID for dataflash.
@@ -99,12 +104,12 @@ typedef struct KFileDataflash
 #define KFT_DATAFLASH MAKE_ID('D', 'F', 'L', 'H')
 
 /**
- * Convert + ASSERT from generic KFile to KFileDataflash.
+ * Convert + ASSERT from generic KFile to DataFlash.
  */
-INLINE KFileDataflash * KFILEDATAFLASH(KFile *fd)
+INLINE DataFlash * DATAFLASH_CAST(KFile *fd)
 {
        ASSERT(fd->_type == KFT_DATAFLASH);
-       return (KFileDataflash *)fd;
+       return (DataFlash *)fd;
 }
 
 #define RESET_PULSE_WIDTH     10 ///< Width of reset pulse in usec.
@@ -182,6 +187,20 @@ typedef struct DataflashInfo
 } DataflashInfo;
 
 
-bool dataflash_init(KFileDataflash *fd, KFile *ch, DataflashType type, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset);
+bool dataflash_init(DataFlash *fd, KFile *ch, DataflashType type, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset);
+bool dataflash_diskInit(struct BattFsSuper *d, DataFlash *fd, pgcnt_t *page_array);
+
+/**
+ * To test data falsh drive you could use
+ * this functions. To use these functions make sure to include in your make file the
+ * drv/datafalsh_test.c source.
+ *
+ * (see drv/datafalsh_test.c for more detail)
+ */
+int dataflash_testSetup(void);
+/* For backward compatibility */
+#define dataflash_testSetUp() dataflash_testSetup()
+int dataflash_testRun(void);
+int dataflash_testTearDown(void);
 
 #endif /* DRV_DATAFLASH_H */