X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fdrv%2Fflash_avr.h;h=0897132c358809eb3c024c0c9779a739479a7345;hb=c4091308dd2d35b7a79b3b0632ade5594b6fedf4;hp=c64fc699b34019d40d1163be810d999672fa8268;hpb=dd6db266344e7bf6d58673d7ce5b5b3a9ed9e64d;p=bertos.git diff --git a/bertos/cpu/avr/drv/flash_avr.h b/bertos/cpu/avr/drv/flash_avr.h index c64fc699..0897132c 100644 --- a/bertos/cpu/avr/drv/flash_avr.h +++ b/bertos/cpu/avr/drv/flash_avr.h @@ -42,15 +42,43 @@ #include #include +#include + + +/** + * Definition of type for avr flash module. + */ +typedef uint16_t avr_page_t; /** * FlashAvr KFile context structure. */ -typedef struct KFileFlashAvr +typedef struct FlashAvr { - KFile fd; ///< File descriptor. -} KFileFlashAvr; + /** + * 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; @@ -60,16 +88,16 @@ typedef struct KFileFlashAvr #define KFT_FLASHAVR MAKE_ID('F', 'L', 'A', 'V') /** - * Convert + ASSERT from generic KFile to KFileFlashAvr. + * Convert + ASSERT from generic KFile to FlashAvr. */ -INLINE KFileFlashAvr * KFILEFLASHAVR(KFile *fd) +INLINE FlashAvr * FLASHAVR_CAST(KFile *fd) { ASSERT(fd->_type == KFT_FLASHAVR); - return (KFileFlashAvr *)fd; + return (FlashAvr *)fd; } -void flash_avr_init(struct KFile *fd); +void flash_avr_init(struct FlashAvr *fd);