X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fdrv%2Fflash_avr.c;h=03740dd7c5c121a506fac670e9048103124a698d;hb=b3f61b96f21a6d4c491a65e607c5f41fdb028363;hp=8bdd2f91ef7ca4c36ee628b5e9c7b5a21293ca26;hpb=37df46aa8f8cb8e89b92c6c8de6a047fcaad9e37;p=bertos.git diff --git a/bertos/cpu/avr/drv/flash_avr.c b/bertos/cpu/avr/drv/flash_avr.c index 8bdd2f91..03740dd7 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. */ @@ -141,7 +140,7 @@ static void flash_avr_flush(FlashAvr *fd) */ static int flash_avr_kfileFlush(struct KFile *_fd) { - FlashAvr *fd = FLASHAVRKFILE(_fd); + FlashAvr *fd = FLASHAVR_CAST(_fd); flash_avr_flush(fd); return 0; } @@ -170,7 +169,7 @@ static void flash_avr_loadPage(FlashAvr *fd, avr_page_t page) */ static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size) { - FlashAvr *fd = FLASHAVRKFILE(_fd); + FlashAvr *fd = FLASHAVR_CAST(_fd); const uint8_t *buf =(const uint8_t *)_buf; avr_page_t page; @@ -179,7 +178,7 @@ static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size) 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); + size = MIN((kfile_off_t)size, fd->fd.size - fd->fd.seek_pos); LOG_INFO("Writing at pos[%u]\n", fd->fd.seek_pos); while (size) @@ -224,7 +223,7 @@ static void flash_avr_open(struct FlashAvr *fd) */ static int flash_avr_close(struct KFile *_fd) { - FlashAvr *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) { - FlashAvr *_fd = FLASHAVRKFILE(fd); + FlashAvr *_fd = FLASHAVR_CAST(fd); flash_avr_close(fd); flash_avr_open(_fd); return fd; @@ -248,9 +247,9 @@ static struct KFile *flash_avr_reopen(struct KFile *fd) */ static size_t flash_avr_read(struct KFile *_fd, void *buf, size_t size) { - FlashAvr *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); + size = MIN((kfile_off_t)size, fd->fd.size - fd->fd.seek_pos); LOG_INFO("Reading at pos[%u]\n", fd->fd.seek_pos); // Flush current buffered page (if modified).