X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fdrv%2Fflash_avr.h;h=4a0aea73f88eaacb05f61198121333d0c0ee1f8f;hb=b59de1faa4a3d4656d9ffe3e2cc513abc55fb6b3;hp=f078c38e6be99359a50aaee49ba51bf9655b291d;hpb=dd4647adfe027ca0bc84c8fae1fb39a400922380;p=bertos.git diff --git a/bertos/cpu/avr/drv/flash_avr.h b/bertos/cpu/avr/drv/flash_avr.h index f078c38e..4a0aea73 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 FlashAvrKFile { - 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]; + + +} FlashAvrKFile; @@ -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 FlashAvrKFile. */ -INLINE KFileFlashAvr * KFILEFLASHAVR(KFile *fd) +INLINE FlashAvrKFile * FLASHAVRKFILE(KFile *fd) { ASSERT(fd->_type == KFT_FLASHAVR); - return (KFileFlashAvr *)fd; + return (FlashAvrKFile *)fd; } -void flash_avr_init(struct KFileFlashAvr *fd); +void flash_avr_init(struct FlashAvrKFile *fd);