X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fdrv%2Fflash_avr.h;h=0897132c358809eb3c024c0c9779a739479a7345;hb=32d1445272120a254d77ce8d1af1f527da7a2c17;hp=5115d10befde2431238b2b82c6808b5401ce028d;hpb=e2f204cc87c855c1bca96b96b9ebb71397a818b9;p=bertos.git diff --git a/bertos/cpu/avr/drv/flash_avr.h b/bertos/cpu/avr/drv/flash_avr.h index 5115d10b..0897132c 100644 --- a/bertos/cpu/avr/drv/flash_avr.h +++ b/bertos/cpu/avr/drv/flash_avr.h @@ -42,6 +42,7 @@ #include #include +#include /** @@ -53,17 +54,31 @@ typedef uint16_t avr_page_t; /** * FlashAvr KFile context structure. */ -typedef struct KFileFlashAvr +typedef struct FlashAvr { - KFile fd; ///< File descriptor. + /** + * File descriptor. + */ + KFile fd; /** - * Current buffered page. - */ + * 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]; + -} KFileFlashAvr; +} FlashAvr; @@ -73,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 KFileFlashAvr *fd); +void flash_avr_init(struct FlashAvr *fd);