projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix "Found unknown command" doxygen warnings.
[bertos.git]
/
bertos
/
cpu
/
avr
/
drv
/
flash_avr.c
diff --git
a/bertos/cpu/avr/drv/flash_avr.c
b/bertos/cpu/avr/drv/flash_avr.c
index fc87fec547f725f5a9e6a2bac9be2090402ba5c3..03740dd7c5c121a506fac670e9048103124a698d 100644
(file)
--- a/
bertos/cpu/avr/drv/flash_avr.c
+++ b/
bertos/cpu/avr/drv/flash_avr.c
@@
-50,6
+50,11
@@
#include <cfg/debug.h>
#include <cpu/irq.h>
#include <cfg/debug.h>
#include <cpu/irq.h>
+// Define log settings for cfg/log.h
+#define LOG_LEVEL CONFIG_FLASH_AVR_LOG_LEVEL
+#define LOG_FORMAT CONFIG_FLASH_AVR_LOG_FORMAT
+#include <cfg/log.h>
+
#include <drv/wdt.h>
#include <kern/kfile.h>
#include <drv/wdt.h>
#include <kern/kfile.h>
@@
-61,7
+66,6
@@
#include <string.h>
#include <string.h>
-
/**
* Definition of type for avr flash module.
*/
/**
* Definition of type for avr flash module.
*/
@@
-76,18
+80,19
@@
typedef uint16_t avr_page_addr_t;
* Write current buffered page in flash memory (if modified).
* This function erase flash memory page before writing.
*
* Write current buffered page in flash memory (if modified).
* This function erase flash memory page before writing.
*
- * This function is only use internaly in this module.
+ * This function is only use internal
l
y in this module.
*/
*/
-static void flash_avr_flush(
KFile
FlashAvr *fd)
+static void flash_avr_flush(FlashAvr *fd)
{
if (fd->page_dirty)
{
{
if (fd->page_dirty)
{
- kprintf("Flushing page %d\n", fd->curr_page);
+
+ LOG_INFO("Flushing page %d\n", fd->curr_page);
// Wait while the SPM instruction is busy.
boot_spm_busy_wait();
// Wait while the SPM instruction is busy.
boot_spm_busy_wait();
-
kprintf
("Filling temparary page buffer...");
+
LOG_INFO
("Filling temparary page buffer...");
// Fill the temporary buffer of the AVR
for (avr_page_addr_t page_addr = 0; page_addr < SPM_PAGESIZE; page_addr += 2)
// Fill the temporary buffer of the AVR
for (avr_page_addr_t page_addr = 0; page_addr < SPM_PAGESIZE; page_addr += 2)
@@
-96,11
+101,11
@@
static void flash_avr_flush(KFileFlashAvr *fd)
ATOMIC(boot_page_fill(page_addr, word));
}
ATOMIC(boot_page_fill(page_addr, word));
}
-
kprintf
("Done.\n");
+
LOG_INFO
("Done.\n");
wdt_reset();
wdt_reset();
-
kprintf
("Erasing page, addr %u...", fd->curr_page * SPM_PAGESIZE);
+
LOG_INFO
("Erasing page, addr %u...", fd->curr_page * SPM_PAGESIZE);
/* Page erase */
ATOMIC(boot_page_erase(fd->curr_page * SPM_PAGESIZE));
/* Page erase */
ATOMIC(boot_page_erase(fd->curr_page * SPM_PAGESIZE));
@@
-108,8
+113,8
@@
static void flash_avr_flush(KFileFlashAvr *fd)
/* Wait until the memory is erased. */
boot_spm_busy_wait();
/* Wait until the memory is erased. */
boot_spm_busy_wait();
-
kprintf
("Done.\n");
-
kprintf
("Writing page, addr %u...", fd->curr_page * SPM_PAGESIZE);
+
LOG_INFO
("Done.\n");
+
LOG_INFO
("Writing page, addr %u...", fd->curr_page * SPM_PAGESIZE);
/* Store buffer in flash page. */
ATOMIC(boot_page_write(fd->curr_page * SPM_PAGESIZE));
/* Store buffer in flash page. */
ATOMIC(boot_page_write(fd->curr_page * SPM_PAGESIZE));
@@
-122,7
+127,7
@@
static void flash_avr_flush(KFileFlashAvr *fd)
ATOMIC(boot_rww_enable());
fd->page_dirty = false;
ATOMIC(boot_rww_enable());
fd->page_dirty = false;
-
kprintf
("Done.\n");
+
LOG_INFO
("Done.\n");
}
}
}
}
@@
-135,7
+140,7
@@
static void flash_avr_flush(KFileFlashAvr *fd)
*/
static int flash_avr_kfileFlush(struct KFile *_fd)
{
*/
static int flash_avr_kfileFlush(struct KFile *_fd)
{
-
KFileFlashAvr *fd = KFILEFLASHAVR
(_fd);
+
FlashAvr *fd = FLASHAVR_CAST
(_fd);
flash_avr_flush(fd);
return 0;
}
flash_avr_flush(fd);
return 0;
}
@@
-145,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.
*/
* Check current page and if \a page is different, load it in
* temporary buffer.
*/
-static void flash_avr_loadPage(
KFile
FlashAvr *fd, avr_page_t page)
+static void flash_avr_loadPage(FlashAvr *fd, avr_page_t page)
{
if (page != fd->curr_page)
{
{
if (page != fd->curr_page)
{
@@
-153,7
+158,7
@@
static void flash_avr_loadPage(KFileFlashAvr *fd, avr_page_t page)
// Load page
memcpy_P(fd->page_buf, (const char *)(page * SPM_PAGESIZE), SPM_PAGESIZE);
fd->curr_page = page;
// Load page
memcpy_P(fd->page_buf, (const char *)(page * SPM_PAGESIZE), SPM_PAGESIZE);
fd->curr_page = page;
-
kprintf
("Loaded page %d\n", fd->curr_page);
+
LOG_INFO
("Loaded page %d\n", fd->curr_page);
}
}
}
}
@@
-164,7
+169,7
@@
static void flash_avr_loadPage(KFileFlashAvr *fd, avr_page_t page)
*/
static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size)
{
*/
static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size)
{
-
KFileFlashAvr *fd = KFILEFLASHAVR
(_fd);
+
FlashAvr *fd = FLASHAVR_CAST
(_fd);
const uint8_t *buf =(const uint8_t *)_buf;
avr_page_t page;
const uint8_t *buf =(const uint8_t *)_buf;
avr_page_t page;
@@
-173,9
+178,9
@@
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);
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);
-
kprintf
("Writing at pos[%u]\n", fd->fd.seek_pos);
+
LOG_INFO
("Writing at pos[%u]\n", fd->fd.seek_pos);
while (size)
{
page = fd->fd.seek_pos / SPM_PAGESIZE;
while (size)
{
page = fd->fd.seek_pos / SPM_PAGESIZE;
@@
-192,7
+197,7
@@
static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size)
size -= wr_len;
total_write += wr_len;
}
size -= wr_len;
total_write += wr_len;
}
-
kprintf
("written %u bytes\n", total_write);
+
LOG_INFO
("written %u bytes\n", total_write);
return total_write;
}
return total_write;
}
@@
-201,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.
*/
* \a name and \a mode are unused, cause flash memory is
* threated like one file.
*/
-static void flash_avr_open(struct
KFile
FlashAvr *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);
{
fd->curr_page = 0;
memcpy_P(fd->page_buf, (const char *)(fd->curr_page * SPM_PAGESIZE), SPM_PAGESIZE);
@@
-210,7
+215,7
@@
static void flash_avr_open(struct KFileFlashAvr *fd)
fd->fd.size = (uint16_t)(FLASHEND - CONFIG_FLASH_AVR_BOOTSIZE + 1);
fd->page_dirty = false;
fd->fd.size = (uint16_t)(FLASHEND - CONFIG_FLASH_AVR_BOOTSIZE + 1);
fd->page_dirty = false;
-
kprintf
("Flash file opened\n");
+
LOG_INFO
("Flash file opened\n");
}
/**
}
/**
@@
-218,9
+223,9
@@
static void flash_avr_open(struct KFileFlashAvr *fd)
*/
static int flash_avr_close(struct KFile *_fd)
{
*/
static int flash_avr_close(struct KFile *_fd)
{
-
KFileFlashAvr *fd = KFILEFLASHAVR
(_fd);
+
FlashAvr *fd = FLASHAVR_CAST
(_fd);
flash_avr_flush(fd);
flash_avr_flush(fd);
-
kprintf
("Flash file closed\n");
+
LOG_INFO
("Flash file closed\n");
return 0;
}
return 0;
}
@@
-229,7
+234,7
@@
static int flash_avr_close(struct KFile *_fd)
*/
static struct KFile *flash_avr_reopen(struct KFile *fd)
{
*/
static struct KFile *flash_avr_reopen(struct KFile *fd)
{
-
KFileFlashAvr *_fd = KFILEFLASHAVR
(fd);
+
FlashAvr *_fd = FLASHAVR_CAST
(fd);
flash_avr_close(fd);
flash_avr_open(_fd);
return fd;
flash_avr_close(fd);
flash_avr_open(_fd);
return fd;
@@
-242,11
+247,11
@@
static struct KFile *flash_avr_reopen(struct KFile *fd)
*/
static size_t flash_avr_read(struct KFile *_fd, void *buf, size_t size)
{
*/
static size_t flash_avr_read(struct KFile *_fd, void *buf, size_t size)
{
-
KFileFlashAvr *fd = KFILEFLASHAVR
(_fd);
+
FlashAvr *fd = FLASHAVR_CAST
(_fd);
ASSERT(fd->fd.seek_pos + (kfile_off_t)size <= (kfile_off_t)fd->fd.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);
-
kprintf
("Reading at pos[%u]\n", fd->fd.seek_pos);
+
LOG_INFO
("Reading at pos[%u]\n", fd->fd.seek_pos);
// Flush current buffered page (if modified).
flash_avr_flush(fd);
// Flush current buffered page (if modified).
flash_avr_flush(fd);
@@
-259,14
+264,14
@@
static size_t flash_avr_read(struct KFile *_fd, void *buf, size_t size)
memcpy_P(buf, pgm_addr, size);
fd->fd.seek_pos += size;
memcpy_P(buf, pgm_addr, size);
fd->fd.seek_pos += size;
-
kprintf
("Read %u bytes\n", size);
+
LOG_INFO
("Read %u bytes\n", size);
return size;
}
/**
* Init AVR flash read/write file.
*/
return size;
}
/**
* Init AVR flash read/write file.
*/
-void flash_avr_init(struct
KFile
FlashAvr *fd)
+void flash_avr_init(struct FlashAvr *fd)
{
memset(fd, 0, sizeof(*fd));
DB(fd->fd._type = KFT_FLASHAVR);
{
memset(fd, 0, sizeof(*fd));
DB(fd->fd._type = KFT_FLASHAVR);