projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for more i2c devices.
[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 daaf4d9b6f72a071eeec902a2283f6609a2d5699..af1d6de89c2a7aaa6897b6b5403ef23c8c01d505 100644
(file)
--- a/
bertos/cpu/avr/drv/flash_avr.c
+++ b/
bertos/cpu/avr/drv/flash_avr.c
@@
-32,7
+32,6
@@
*
* \brief Self programming routines.
*
*
* \brief Self programming routines.
*
- * \version $Id$
* \author Francesco Sacchi <batt@develer.com>
* \author Daniele Basile <asterix@develer.com>
*
* \author Francesco Sacchi <batt@develer.com>
* \author Daniele Basile <asterix@develer.com>
*
@@
-56,8
+55,9
@@
#include <cfg/log.h>
#include <drv/wdt.h>
#include <cfg/log.h>
#include <drv/wdt.h>
+#include <drv/flash.h>
-#include <
kern
/kfile.h>
+#include <
io
/kfile.h>
#include <avr/io.h>
#include <avr/boot.h>
#include <avr/io.h>
#include <avr/boot.h>
@@
-69,9
+69,7
@@
/**
* Definition of type for avr flash module.
*/
/**
* Definition of type for avr flash module.
*/
-typedef uint16_t avr_page_addr_t;
-
-
+typedef uint16_t page_addr_t;
/**
/**
@@
-82,7
+80,7
@@
typedef uint16_t avr_page_addr_t;
*
* This function is only use internally in this module.
*/
*
* This function is only use internally in this module.
*/
-static void flash_avr_flush(Flash
Avr
*fd)
+static void flash_avr_flush(Flash *fd)
{
if (fd->page_dirty)
{
{
if (fd->page_dirty)
{
@@
-95,7
+93,7
@@
static void flash_avr_flush(FlashAvr *fd)
LOG_INFO("Filling temparary page buffer...");
// Fill the temporary buffer of the AVR
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)
+ for (page_addr_t page_addr = 0; page_addr < SPM_PAGESIZE; page_addr += 2)
{
uint16_t word = ((uint16_t)fd->page_buf[page_addr + 1] << 8) | fd->page_buf[page_addr];
{
uint16_t word = ((uint16_t)fd->page_buf[page_addr + 1] << 8) | fd->page_buf[page_addr];
@@
-140,7
+138,7
@@
static void flash_avr_flush(FlashAvr *fd)
*/
static int flash_avr_kfileFlush(struct KFile *_fd)
{
*/
static int flash_avr_kfileFlush(struct KFile *_fd)
{
- Flash
Avr *fd = FLASHAVR
_CAST(_fd);
+ Flash
*fd = FLASH
_CAST(_fd);
flash_avr_flush(fd);
return 0;
}
flash_avr_flush(fd);
return 0;
}
@@
-150,7
+148,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(Flash
Avr *fd, avr_
page_t page)
+static void flash_avr_loadPage(Flash
*fd,
page_t page)
{
if (page != fd->curr_page)
{
{
if (page != fd->curr_page)
{
@@
-169,16
+167,16
@@
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)
{
*/
static size_t flash_avr_write(struct KFile *_fd, const void *_buf, size_t size)
{
- Flash
Avr *fd = FLASHAVR
_CAST(_fd);
+ Flash
*fd = FLASH
_CAST(_fd);
const uint8_t *buf =(const uint8_t *)_buf;
const uint8_t *buf =(const uint8_t *)_buf;
-
avr_
page_t page;
-
avr_
page_addr_t page_addr;
+ page_t page;
+ page_addr_t page_addr;
size_t total_write = 0;
ASSERT(fd->fd.seek_pos + (kfile_off_t)size <= (kfile_off_t)fd->fd.size);
size_t total_write = 0;
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)
LOG_INFO("Writing at pos[%u]\n", fd->fd.seek_pos);
while (size)
@@
-206,7
+204,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 Flash
Avr
*fd)
+static void flash_avr_open(struct Flash *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);
@@
-223,7
+221,7
@@
static void flash_avr_open(struct FlashAvr *fd)
*/
static int flash_avr_close(struct KFile *_fd)
{
*/
static int flash_avr_close(struct KFile *_fd)
{
- Flash
Avr *fd = FLASHAVR
_CAST(_fd);
+ Flash
*fd = FLASH
_CAST(_fd);
flash_avr_flush(fd);
LOG_INFO("Flash file closed\n");
return 0;
flash_avr_flush(fd);
LOG_INFO("Flash file closed\n");
return 0;
@@
-234,9
+232,9
@@
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)
{
- Flash
Avr *_fd = FLASHAVR
_CAST(fd);
+ Flash
*_fd = FLASH
_CAST(fd);
flash_avr_close(fd);
flash_avr_close(fd);
- flash_avr_open(_fd);
+ flash_avr_open(
(struct Flash *)
_fd);
return fd;
}
return fd;
}
@@
-247,9
+245,9
@@
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)
{
- Flash
Avr *fd = FLASHAVR
_CAST(_fd);
+ Flash
*fd = FLASH
_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);
LOG_INFO("Reading at pos[%u]\n", fd->fd.seek_pos);
// Flush current buffered page (if modified).
LOG_INFO("Reading at pos[%u]\n", fd->fd.seek_pos);
// Flush current buffered page (if modified).
@@
-271,10
+269,10
@@
static size_t flash_avr_read(struct KFile *_fd, void *buf, size_t size)
/**
* Init AVR flash read/write file.
*/
/**
* Init AVR flash read/write file.
*/
-void flash_
avr_init(struct FlashAvr
*fd)
+void flash_
hw_init(struct Flash
*fd)
{
memset(fd, 0, sizeof(*fd));
{
memset(fd, 0, sizeof(*fd));
- DB(fd->fd._type = KFT_FLASH
AVR
);
+ DB(fd->fd._type = KFT_FLASH);
// Set up flash programming functions.
fd->fd.reopen = flash_avr_reopen;
// Set up flash programming functions.
fd->fd.reopen = flash_avr_reopen;