Merge branch "preempt" in "trunk".
[bertos.git] / bertos / cpu / avr / drv / flash_avr.h
index 7b4317d97106029c5bbab80e341f88a153ef6060..0897132c358809eb3c024c0c9779a739479a7345 100644 (file)
 
 #include <cfg/compiler.h>
 #include <kern/kfile.h>
+#include <avr/io.h>
+
+
+/**
+ * Definition of type for avr flash module.
+ */
+typedef uint16_t avr_page_t;
+
+
+/**
+ * FlashAvr KFile context structure.
+ */
+typedef struct FlashAvr
+{
+       /**
+        * File descriptor.
+        */
+       KFile fd;
+
+       /**
+        * Current buffered page.
+        */
+       avr_page_t curr_page;
+
+       /**
+        * Flag for checking if current page is modified.
+        */
+       bool page_dirty;
+
+       /**
+        * Temporary buffer cointaing data block to
+        * write on flash.
+        */
+       uint8_t page_buf[SPM_PAGESIZE];
+
+
+} FlashAvr;
+
+
+
+/**
+ * ID for FlashAvr
+ */
+#define KFT_FLASHAVR MAKE_ID('F', 'L', 'A', 'V')
+
+/**
+ * Convert + ASSERT from generic KFile to FlashAvr.
+ */
+INLINE FlashAvr * FLASHAVR_CAST(KFile *fd)
+{
+       ASSERT(fd->_type == KFT_FLASHAVR);
+       return (FlashAvr *)fd;
+}
+
+
+void flash_avr_init(struct FlashAvr *fd);
 
-bool flash_avr_test(void);
-void flash_avr_init(struct KFile *fd);
 
 
 #endif /* DRV_FLASH_AVR_H */