X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fdrv%2Fflash_avr.c;h=daaf4d9b6f72a071eeec902a2283f6609a2d5699;hb=515886be3106584a6d695d4b5453730121b91f74;hp=c64f935b8a7ff76ab5e818d901c9a5dcc92c7eec;hpb=b59de1faa4a3d4656d9ffe3e2cc513abc55fb6b3;p=bertos.git diff --git a/bertos/cpu/avr/drv/flash_avr.c b/bertos/cpu/avr/drv/flash_avr.c index c64f935b..daaf4d9b 100644 --- a/bertos/cpu/avr/drv/flash_avr.c +++ b/bertos/cpu/avr/drv/flash_avr.c @@ -50,9 +50,9 @@ #include #include - // Define logging setting (for cfg/log.h module). -#define LOG_LEVEL CONFIG_FLASH_AVR_LOG_LEVEL -#define LOG_VERBOSITY CONFIG_FLASH_AVR_LOG_VERBOSITY +// Define log settings for cfg/log.h +#define LOG_LEVEL CONFIG_FLASH_AVR_LOG_LEVEL +#define LOG_FORMAT CONFIG_FLASH_AVR_LOG_FORMAT #include #include @@ -66,7 +66,6 @@ #include - /** * Definition of type for avr flash module. */ @@ -83,7 +82,7 @@ typedef uint16_t avr_page_addr_t; * * This function is only use internally in this module. */ -static void flash_avr_flush(FlashAvrKFile *fd) +static void flash_avr_flush(FlashAvr *fd) { if (fd->page_dirty) { @@ -141,7 +140,7 @@ static void flash_avr_flush(FlashAvrKFile *fd) */ static int flash_avr_kfileFlush(struct KFile *_fd) { - FlashAvrKFile *fd = FLASHAVRKFILE(_fd); + FlashAvr *fd = FLASHAVR_CAST(_fd); flash_avr_flush(fd); return 0; } @@ -151,7 +150,7 @@ static int flash_avr_kfileFlush(struct KFile *_fd) * Check current page and if \a page is different, load it in * temporary buffer. */ -static void flash_avr_loadPage(FlashAvrKFile *fd, avr_page_t page) +static void flash_avr_loadPage(FlashAvr *fd, avr_page_t page) { if (page != fd->curr_page) { @@ -170,7 +169,7 @@ static void flash_avr_loadPage(FlashAvrKFile *fd, avr_page_t page) */ static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size) { - FlashAvrKFile *fd = FLASHAVRKFILE(_fd); + FlashAvr *fd = FLASHAVR_CAST(_fd); const uint8_t *buf =(const uint8_t *)_buf; avr_page_t page; @@ -207,7 +206,7 @@ static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size) * \a name and \a mode are unused, cause flash memory is * threated like one file. */ -static void flash_avr_open(struct FlashAvrKFile *fd) +static void flash_avr_open(struct FlashAvr *fd) { fd->curr_page = 0; memcpy_P(fd->page_buf, (const char *)(fd->curr_page * SPM_PAGESIZE), SPM_PAGESIZE); @@ -224,7 +223,7 @@ static void flash_avr_open(struct FlashAvrKFile *fd) */ static int flash_avr_close(struct KFile *_fd) { - FlashAvrKFile *fd = FLASHAVRKFILE(_fd); + FlashAvr *fd = FLASHAVR_CAST(_fd); flash_avr_flush(fd); LOG_INFO("Flash file closed\n"); return 0; @@ -235,7 +234,7 @@ static int flash_avr_close(struct KFile *_fd) */ static struct KFile *flash_avr_reopen(struct KFile *fd) { - FlashAvrKFile *_fd = FLASHAVRKFILE(fd); + FlashAvr *_fd = FLASHAVR_CAST(fd); flash_avr_close(fd); flash_avr_open(_fd); return fd; @@ -248,7 +247,7 @@ static struct KFile *flash_avr_reopen(struct KFile *fd) */ static size_t flash_avr_read(struct KFile *_fd, void *buf, size_t size) { - FlashAvrKFile *fd = FLASHAVRKFILE(_fd); + FlashAvr *fd = FLASHAVR_CAST(_fd); ASSERT(fd->fd.seek_pos + (kfile_off_t)size <= (kfile_off_t)fd->fd.size); size = MIN((uint32_t)size, fd->fd.size - fd->fd.seek_pos); @@ -272,7 +271,7 @@ static size_t flash_avr_read(struct KFile *_fd, void *buf, size_t size) /** * Init AVR flash read/write file. */ -void flash_avr_init(struct FlashAvrKFile *fd) +void flash_avr_init(struct FlashAvr *fd) { memset(fd, 0, sizeof(*fd)); DB(fd->fd._type = KFT_FLASHAVR);