From: qwert Date: Mon, 4 Aug 2008 15:51:50 +0000 (+0000) Subject: Refactor KFileFlash25 to Flash25KFile. Tested. X-Git-Tag: 2.0.0~393 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=4128f7132429072564952d3244d41e92bd3cfd46;p=bertos.git Refactor KFileFlash25 to Flash25KFile. Tested. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1541 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/flash25.c b/bertos/drv/flash25.c index e2356bdf..2e9c0652 100644 --- a/bertos/drv/flash25.c +++ b/bertos/drv/flash25.c @@ -64,7 +64,7 @@ /** * Wait until flash memory is ready. */ -static void flash25_waitReady(KFileFlash25 *fd) +static void flash25_waitReady(Flash25KFile *fd) { uint8_t stat; @@ -89,7 +89,7 @@ static void flash25_waitReady(KFileFlash25 *fd) /** * Send a single command to serial flash memory. */ -static void flash25_sendCmd(KFileFlash25 *fd, Flash25Opcode cmd) +static void flash25_sendCmd(Flash25KFile *fd, Flash25Opcode cmd) { CS_ENABLE(); @@ -104,7 +104,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. */ -static bool flash25_pin_init(KFileFlash25 *fd) +static bool flash25_pin_init(Flash25KFile *fd) { uint8_t device_id; uint8_t manufacturer; @@ -140,7 +140,7 @@ static bool flash25_pin_init(KFileFlash25 *fd) */ static KFile * flash25_reopen(struct KFile *_fd) { - KFileFlash25 *fd = KFILEFLASH25(_fd); + Flash25KFile *fd = FLASH25KFILE(_fd); fd->fd.seek_pos = 0; fd->fd.size = FLASH25_MEM_SIZE; @@ -176,7 +176,7 @@ static size_t flash25_read(struct KFile *_fd, void *buf, size_t size) { uint8_t *data = (uint8_t *)buf; - KFileFlash25 *fd = KFILEFLASH25(_fd); + Flash25KFile *fd = FLASH25KFILE(_fd); ASSERT(fd->fd.seek_pos + (kfile_size_t)size <= fd->fd.size); size = MIN((kfile_size_t)size, fd->fd.size - fd->fd.seek_pos); @@ -229,7 +229,7 @@ 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; - KFileFlash25 *fd = KFILEFLASH25(_fd); + Flash25KFile *fd = FLASH25KFILE(_fd); ASSERT(fd->fd.seek_pos + (kfile_size_t)size <= fd->fd.size); @@ -294,7 +294,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. */ -void flash25_sectorErase(KFileFlash25 *fd, Flash25Sector sector) +void flash25_sectorErase(Flash25KFile *fd, Flash25Sector sector) { /* @@ -341,7 +341,7 @@ void flash25_sectorErase(KFileFlash25 *fd, Flash25Sector sector) * * \note This operation could take a while. */ -void flash25_chipErase(KFileFlash25 *fd) +void flash25_chipErase(Flash25KFile *fd) { /* * Erase all chip could take a while, @@ -371,7 +371,7 @@ void flash25_chipErase(KFileFlash25 *fd) /** * Init data flash memory interface. */ -void flash25_init(KFileFlash25 *fd, KFile *ch) +void flash25_init(Flash25KFile *fd, KFile *ch) { ASSERT(fd); diff --git a/bertos/drv/flash25.h b/bertos/drv/flash25.h index 82b403f3..ed89384d 100644 --- a/bertos/drv/flash25.h +++ b/bertos/drv/flash25.h @@ -56,11 +56,11 @@ typedef uint8_t flash25Offset_t; /** * Flash25 KFile context structure. */ -typedef struct KFileFlash25 +typedef struct Flash25KFile { KFile fd; ///< File descriptor. KFile *channel; ///< Dataflash comm channel (usually SPI). -} KFileFlash25; +} Flash25KFile; /** * ID for dataflash. @@ -69,12 +69,12 @@ typedef struct KFileFlash25 /** - * Convert + ASSERT from generic KFile to KFileFlash25. + * Convert + ASSERT from generic KFile to Flash25KFile. */ -INLINE KFileFlash25 * KFILEFLASH25(KFile *fd) +INLINE Flash25KFile * FLASH25KFILE(KFile *fd) { ASSERT(fd->_type == KFT_FLASH25); - return (KFileFlash25 *)fd; + return (Flash25KFile *)fd; } /** @@ -131,9 +131,9 @@ typedef enum { FLASH25_SECT4 = 0x30000, ///< Sector 4 (0x30000 -0x3FFFF) } Flash25Sector; -void flash25_init(KFileFlash25 *fd, KFile *ch); -void flash25_chipErase(KFileFlash25 *fd); -void flash25_sectorErase(KFileFlash25 *fd, Flash25Sector sector); +void flash25_init(Flash25KFile *fd, KFile *ch); +void flash25_chipErase(Flash25KFile *fd); +void flash25_sectorErase(Flash25KFile *fd, Flash25Sector sector); bool flash25_test(KFile *channel); #endif /* DRV_FLASH25_H */ diff --git a/bertos/drv/flash25_test.c b/bertos/drv/flash25_test.c index 1506aaba..921cb4ea 100644 --- a/bertos/drv/flash25_test.c +++ b/bertos/drv/flash25_test.c @@ -53,7 +53,7 @@ bool flash25_test(KFile *channel) { - KFileFlash25 fd; + Flash25KFile fd; uint8_t test_buf[256]; /*