From 5853468b688f4ef103db8977ea633c596a64b8b1 Mon Sep 17 00:00:00 2001 From: qwert Date: Fri, 18 Jul 2008 13:13:12 +0000 Subject: [PATCH] Refactor code, moved page_modified variable in KFileFlashAvr struct git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1495 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/avr/drv/flash_avr.c | 13 +++++-------- bertos/cpu/avr/drv/flash_avr.h | 9 ++++++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bertos/cpu/avr/drv/flash_avr.c b/bertos/cpu/avr/drv/flash_avr.c index a0792e3c..73075cde 100644 --- a/bertos/cpu/avr/drv/flash_avr.c +++ b/bertos/cpu/avr/drv/flash_avr.c @@ -74,10 +74,7 @@ typedef uint16_t avr_page_addr_t; */ static uint8_t page_buf[SPM_PAGESIZE]; -/** - * Flag for checking if current page is modified. - */ -bool page_modified; + @@ -91,7 +88,7 @@ bool page_modified; */ static void flash_avr_flush(KFileFlashAvr *fd) { - if (page_modified) + if (fd->page_modified) { kprintf("Flushing page %d\n", fd->curr_page); @@ -132,7 +129,7 @@ static void flash_avr_flush(KFileFlashAvr *fd) */ ATOMIC(boot_rww_enable()); - page_modified = false; + fd->page_modified = false; kprintf("Done.\n"); } } @@ -196,7 +193,7 @@ static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size) size_t wr_len = MIN(size, SPM_PAGESIZE - page_addr); memcpy(page_buf + page_addr, buf, wr_len); - page_modified = true; + fd->page_modified = true; buf += wr_len; fd->fd.seek_pos += wr_len; @@ -219,7 +216,7 @@ static void flash_avr_open(struct KFileFlashAvr *fd) fd->fd.seek_pos = 0; fd->fd.size = (uint16_t)(FLASHEND - CONFIG_FLASH_AVR_BOOTSIZE + 1); - page_modified = false; + fd->page_modified = false; kprintf("Flash file opened\n"); } diff --git a/bertos/cpu/avr/drv/flash_avr.h b/bertos/cpu/avr/drv/flash_avr.h index 5115d10b..bb7698ab 100644 --- a/bertos/cpu/avr/drv/flash_avr.h +++ b/bertos/cpu/avr/drv/flash_avr.h @@ -55,13 +55,20 @@ typedef uint16_t avr_page_t; */ typedef struct KFileFlashAvr { - KFile fd; ///< File descriptor. + /** + * File descriptor. + */ + KFile fd; /** * Current buffered page. */ avr_page_t curr_page; + /** + * Flag for checking if current page is modified. + */ + bool page_modified; } KFileFlashAvr; -- 2.25.1