Add flash module. Refactor the cpu implementation.
[bertos.git] / bertos / cpu / arm / drv / flash_at91.h
index 1dcd9829131d6a0b00c20ce5b9bdb687cb199fdd..0b6c8d663676d7a3be29c69550bed5709fe7cee0 100644 (file)
 #include <io/arm.h>
 
 
+#define FLASH_PAGE_SIZE FLASH_PAGE_SIZE_BYTES
+
 /**
  * Define data type to manage page and memory address.
  */
-typedef uint32_t arm_page_t;
-typedef uint32_t arm_page_addr_t;
+typedef uint32_t page_t;
+typedef uint32_t page_addr_t;
+
+struct Flash;
 
 /**
  * FlashAt91 KFile context structure.
+ *
+ * DEPREACTED STRUCTURE!
+ * Use EmbFlash instead
+ *
+ * \{
  */
 typedef struct FlashAt91
 {
@@ -71,32 +80,26 @@ typedef struct FlashAt91
        /**
         * Current buffered page.
         */
-       arm_page_t curr_page;
+       page_t curr_page;
 
        /**
         * Temporary buffer cointaing data block to
         * write on flash.
         */
        uint8_t page_buf[FLASH_PAGE_SIZE_BYTES];
-
-
 } FlashAt91;
+/* \} */
 
-/**
- * ID for FlashAt91
- */
-#define KFT_FLASHAT91 MAKE_ID('F', 'A', '9', '1')
+void flash_hw_init(struct Flash *fd);
 
 /**
- * Convert + ASSERT from generic KFile to FlashAt91.
+ * WARNING!
+ * This function is DEPRECADED!
+ * use the emb_flash module instead.
  */
-INLINE FlashAt91 * FLASHAT91_CAST(KFile *fd)
+INLINE void flash_at91_init(struct FlashAt91 *fd)
 {
-       ASSERT(fd->_type == KFT_FLASHAT91);
-       return (FlashAt91 *)fd;
+       flash_hw_init((struct Flash *)fd);
 }
 
-
-void flash_at91_init(FlashAt91 *fd);
-
-#endif
+#endif /* DRV_FLASH_ARM_H */