*
* -->
*
- * \brief Self programming routines (interface).
- *
- * \version $Id$
* \author Francesco Sacchi <batt@develer.com>
* \author Daniele Basile <asterix@develer.com>
+ *
+ * \brief AVR Internal flash read/write driver.
+ *
+ *
*/
-#ifndef DRV_FLASH_AVR_H
-#define DRV_FLASH_AVR_H
+#ifndef FLASH_AT91_H
+#define FLASH_AT91_H
+
+#include <cpu/types.h>
#include <cfg/compiler.h>
-#include <kern/kfile.h>
+#include <kern/kfile.h>
-/**
- * FlashAvr KFile context structure.
- */
-typedef struct KFileFlashAvr
-{
- KFile fd; ///< File descriptor.
-} KFileFlashAvr;
+#include <avr/io.h>
+#define FLASH_PAGE_SIZE SPM_PAGESIZE
/**
- * ID for FlashAvr
+ * Definition of type for avr flash module.
*/
-#define KFT_FLASHAVR MAKE_ID('F', 'L', 'A', 'V')
+typedef uint16_t page_t;
+
+/* Forward declaration */
+struct Flash;
/**
- * Convert + ASSERT from generic KFile to KFileFlashAvr.
+ * FlashAvr KFile context structure.
+ * DEPREACTED STRUCTURE!
+ * Use Flash instead
+ *
+ * \{
*/
-INLINE KFileFlashAvr * KFILEFLASHAVR(KFile *fd)
+typedef struct FlashAvr
{
- ASSERT(fd->_type == KFT_FLASHAVR);
- return (KFileFlashAvr *)fd;
-}
+ /**
+ * File descriptor.
+ */
+ KFile fd;
+ /**
+ * Flag for checking if current page is modified.
+ */
+ bool page_dirty;
-void flash_avr_init(struct KFileFlashAvr *fd);
+ /**
+ * Current buffered page.
+ */
+ page_t curr_page;
+ /**
+ * Temporary buffer cointaing data block to
+ * write on flash.
+ */
+ uint8_t page_buf[SPM_PAGESIZE];
+} FlashAvr;
+/* \} */
+void flash_hw_init(struct Flash *fd);
+
+/**
+ * WARNING!
+ * This function is DEPRECADED!
+ * use the flash module instead.
+ */
+INLINE void flash_avr_init(struct FlashAvr *fd)
+{
+ flash_hw_init((struct Flash *)fd);
+}
#endif /* DRV_FLASH_AVR_H */