From 4d3fba9abb5ddc9324e9ea5e629fd1c5f8a787b4 Mon Sep 17 00:00:00 2001 From: asterix Date: Tue, 16 Oct 2007 08:28:43 +0000 Subject: [PATCH] Add Kfile interface prototipe. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@883 38d2e660-2303-0410-9eaa-f027e97ec537 --- drv/dflash.c | 70 +++++++++++++++++++++++++++++++++++++--------------- drv/dflash.h | 14 +++-------- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/drv/dflash.c b/drv/dflash.c index 8aad1f54..815d9570 100644 --- a/drv/dflash.c +++ b/drv/dflash.c @@ -104,25 +104,6 @@ static void send_cmd(dflashAddr_t page_addr, dflashAddr_t byte_addr, DFlashOpcod } - -//TODO: deve ritornare un bool? -/** - * Init data flash memory interface. - */ -void dflash_init(struct _KFile *fd) -{ - // Set up data flash programming functions. - fd->open = dflash_open; - fd->close = dflash_close; - fd->read = dflash_read; - fd->write = dflash_write; - fd->seek = dflash_seek; - - // Init data flash memory and micro pin. - dflash_pin_init(); -} - - /** * Reset dataflash memory function. * @@ -130,7 +111,7 @@ void dflash_init(struct _KFile *fd) * with one pulse reset long about 10usec. * */ -void dflash_reset(void) +static void dflash_reset(void) { CS_ENABLE(); RESET_ENABLE(); @@ -322,3 +303,52 @@ static void dflash_write_block(dflashAddr_t byte_addr, DFlashOpcode opcode, uint CS_DISABLE(); } + +/** + * Open data flash file \a fd + * \a name and \a mode are unused, cause flash memory is + * threated like one file. + */ +static bool dflash_open(struct _KFile *fd, UNUSED_ARG(const char *, name), UNUSED_ARG(int, mode)) +{ +} + +/** + * Close file \a fd + */ +static bool dflash_close(UNUSED_ARG(struct _KFile *,fd)) +{ +} + +/** + * Move \a fd file seek position of \a offset bytes + * from current position. + */ +static int32_t dflash_seek(struct _KFile *fd, int32_t offset, KSeekMode whence) +{ +} + +/** + * Read from file \a fd \a size bytes and put it in buffer \a buf + * \return the number of bytes read. + */ +static size_t dflash_read(struct _KFile *fd, void *buf, size_t size) +{ +} + +//TODO: deve ritornare un bool? +/** + * Init data flash memory interface. + */ +void dflash_init(struct _KFile *fd) +{ + // Set up data flash programming functions. + fd->open = dflash_open; + fd->close = dflash_close; + fd->read = dflash_read; + fd->write = dflash_write; + fd->seek = dflash_seek; + + // Init data flash memory and micro pin. + dflash_pin_init(); +} \ No newline at end of file diff --git a/drv/dflash.h b/drv/dflash.h index 7d06adec..50fe2d0e 100644 --- a/drv/dflash.h +++ b/drv/dflash.h @@ -43,6 +43,8 @@ #include +#include + #include #include @@ -201,17 +203,7 @@ typedef enum { /* \}*/ } DFlashOpcode; -bool dflash_init(void); -void dflash_reset(void); -uint8_t dflash_stat(void); - -uint8_t dflash_cmd(dflashAddr_t page_addr, dflashAddr_t byte_addr, DFlashOpcode opcode); - -uint8_t dflash_read_byte(dflashAddr_t page_addr, dflashAddr_t byte_addr, DFlashOpcode opcode); -void dflash_read_block(dflashAddr_t page_addr, dflashAddr_t byte_addr, DFlashOpcode opcode, uint8_t *block, dflashSize_t len); - -void dflash_write_byte(dflashAddr_t byte_addr, DFlashOpcode opcode, uint8_t data); -void dflash_write_block(dflashAddr_t byte_addr, DFlashOpcode opcode, uint8_t *block, dflashSize_t len); +void dflash_init(struct _KFile *fd) #endif /* DFLASH_H */ -- 2.25.1