projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Modify the module selection page
[bertos.git]
/
bertos
/
drv
/
flash25.c
diff --git
a/bertos/drv/flash25.c
b/bertos/drv/flash25.c
index 1bb50fc8d2637b3ffcaf8e593293279823ab5ecd..22639161032f8a0ac395c604690ce9328b7155a4 100644
(file)
--- a/
bertos/drv/flash25.c
+++ b/
bertos/drv/flash25.c
@@
-27,10
+27,9
@@
* the GNU General Public License.
*
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
* the GNU General Public License.
*
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
- *
* -->
*
* -->
*
- *
\brief Function library for serial Flash memory.
+ * \brief Function library for serial Flash memory.
*
* Module provide a kfile interface, that ensure an abstraction
* from comunication channel and give a standard interface.
*
* Module provide a kfile interface, that ensure an abstraction
* from comunication channel and give a standard interface.
@@
-45,9
+44,7
@@
* We use a spi bus, thus include hardware specific definition.
* If you use another channel you must redefine this macros.
*/
* We use a spi bus, thus include hardware specific definition.
* If you use another channel you must redefine this macros.
*/
-#include "hw_spi.h"
-
-#include <appconfig.h>
+#include "hw/hw_spi.h"
#include <cfg/macros.h>
#include <cfg/debug.h>
#include <cfg/macros.h>
#include <cfg/debug.h>
@@
-57,16
+54,14
@@
#include <kern/kfile.h>
#include <kern/kfile.h>
-#if CONFIG_KERNEL
-#include <kern/proc.h>
-#endif
+#include <cpu/power.h> /* cpu_relax() */
-#warning
t
his file was change, but is untest!
+#warning
FIXME:T
his file was change, but is untest!
/**
* Wait until flash memory is ready.
*/
/**
* Wait until flash memory is ready.
*/
-static void flash25_waitReady(
KFile
Flash25 *fd)
+static void flash25_waitReady(Flash25 *fd)
{
uint8_t stat;
{
uint8_t stat;
@@
-81,17
+76,15
@@
static void flash25_waitReady(KFileFlash25 *fd)
if (!(stat & RDY_BIT))
break;
if (!(stat & RDY_BIT))
break;
- #if CONFIG_KERNEL
- else
- proc_switch();
- #endif
+
+ cpu_relax();
}
}
/**
* Send a single command to serial flash memory.
*/
}
}
/**
* Send a single command to serial flash memory.
*/
-static void flash25_sendCmd(
KFile
Flash25 *fd, Flash25Opcode cmd)
+static void flash25_sendCmd(Flash25 *fd, Flash25Opcode cmd)
{
CS_ENABLE();
{
CS_ENABLE();
@@
-106,7
+99,7
@@
static void flash25_sendCmd(KFileFlash25 *fd, Flash25Opcode cmd)
* try to read manufacturer id of serial memory,
* then check if is equal to selected type.
*/
* try to read manufacturer id of serial memory,
* then check if is equal to selected type.
*/
-static bool flash25_pin_init(
KFile
Flash25 *fd)
+static bool flash25_pin_init(Flash25 *fd)
{
uint8_t device_id;
uint8_t manufacturer;
{
uint8_t device_id;
uint8_t manufacturer;
@@
-142,7
+135,7
@@
static bool flash25_pin_init(KFileFlash25 *fd)
*/
static KFile * flash25_reopen(struct KFile *_fd)
{
*/
static KFile * flash25_reopen(struct KFile *_fd)
{
-
KFileFlash25 *fd = KFILEFLASH25
(_fd);
+
Flash25 *fd = FLASH25_CAST
(_fd);
fd->fd.seek_pos = 0;
fd->fd.size = FLASH25_MEM_SIZE;
fd->fd.seek_pos = 0;
fd->fd.size = FLASH25_MEM_SIZE;
@@
-178,10
+171,10
@@
static size_t flash25_read(struct KFile *_fd, void *buf, size_t size)
{
uint8_t *data = (uint8_t *)buf;
{
uint8_t *data = (uint8_t *)buf;
-
KFileFlash25 *fd = KFILEFLASH25
(_fd);
+
Flash25 *fd = FLASH25_CAST
(_fd);
- ASSERT(fd->fd.seek_pos + size <= fd->fd.size);
- size = MIN((
uint32
_t)size, fd->fd.size - fd->fd.seek_pos);
+ ASSERT(fd->fd.seek_pos +
(kfile_off_t)
size <= fd->fd.size);
+ size = MIN((
kfile_off
_t)size, fd->fd.size - fd->fd.seek_pos);
//kprintf("Reading at addr[%lu], size[%d]\n", fd->seek_pos, size);
CS_ENABLE();
//kprintf("Reading at addr[%lu], size[%d]\n", fd->seek_pos, size);
CS_ENABLE();
@@
-231,11
+224,11
@@
static size_t flash25_write(struct KFile *_fd, const void *_buf, size_t size)
flash25Size_t wr_len;
const uint8_t *data = (const uint8_t *) _buf;
flash25Size_t wr_len;
const uint8_t *data = (const uint8_t *) _buf;
-
KFileFlash25 *fd = KFILEFLASH25
(_fd);
+
Flash25 *fd = FLASH25_CAST
(_fd);
- ASSERT(fd->fd.seek_pos + size <= fd->fd.size);
+ ASSERT(fd->fd.seek_pos +
(kfile_off_t)
size <= fd->fd.size);
- size = MIN((
flash25Size
_t)size, fd->fd.size - fd->fd.seek_pos);
+ size = MIN((
kfile_off
_t)size, fd->fd.size - fd->fd.seek_pos);
while (size)
{
while (size)
{
@@
-284,7
+277,7
@@
static size_t flash25_write(struct KFile *_fd, const void *_buf, size_t size)
total_write += wr_len;
}
total_write += wr_len;
}
- kprintf("written %u bytes\n", total_write);
+ kprintf("written %
l
u bytes\n", total_write);
return total_write;
}
return total_write;
}
@@
-296,7
+289,7
@@
static size_t flash25_write(struct KFile *_fd, const void *_buf, size_t size)
* \note A sector size is FLASH25_SECTOR_SIZE.
* This operation could take a while.
*/
* \note A sector size is FLASH25_SECTOR_SIZE.
* This operation could take a while.
*/
-void flash25_sectorErase(
KFile
Flash25 *fd, Flash25Sector sector)
+void flash25_sectorErase(Flash25 *fd, Flash25Sector sector)
{
/*
{
/*
@@
-332,8
+325,7
@@
void flash25_sectorErase(KFileFlash25 *fd, Flash25Sector sector)
*/
flash25_waitReady(fd);
*/
flash25_waitReady(fd);
- DB(kprintf("Erased sector [%d] in %d ms\n", sector, ticks_to_ms(timer_clock() - start_time)));
-
+ DB(kprintf("Erased sector [%ld] in %ld ms\n", (unsigned long)sector, (unsigned long)ticks_to_ms(timer_clock() - start_time)));
}
/**
}
/**
@@
-343,7
+335,7
@@
void flash25_sectorErase(KFileFlash25 *fd, Flash25Sector sector)
*
* \note This operation could take a while.
*/
*
* \note This operation could take a while.
*/
-void flash25_chipErase(
KFile
Flash25 *fd)
+void flash25_chipErase(Flash25 *fd)
{
/*
* Erase all chip could take a while,
{
/*
* Erase all chip could take a while,
@@
-366,14
+358,14
@@
void flash25_chipErase(KFileFlash25 *fd)
*/
flash25_waitReady(fd);
*/
flash25_waitReady(fd);
- DB(kprintf("Erased all memory in %d ms\n", ticks_to_ms(timer_clock() - start_time)));
+ DB(kprintf("Erased all memory in %
l
d ms\n", ticks_to_ms(timer_clock() - start_time)));
}
/**
* Init data flash memory interface.
*/
}
/**
* Init data flash memory interface.
*/
-void flash25_init(
KFile
Flash25 *fd, KFile *ch)
+void flash25_init(Flash25 *fd, KFile *ch)
{
ASSERT(fd);
{
ASSERT(fd);