X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fflash25.h;h=96aab7489eacd0b2a6b79c9dc559569686e85298;hb=3d3f1c948f803155daf4e06f126294e05b74c370;hp=e45dbed4e4b6e76fefb05c5b7c0d19a531df76c7;hpb=791e167e053bdd9250d34a9a5ccae6ccde4d6679;p=bertos.git diff --git a/bertos/drv/flash25.h b/bertos/drv/flash25.h index e45dbed4..96aab748 100644 --- a/bertos/drv/flash25.h +++ b/bertos/drv/flash25.h @@ -33,19 +33,21 @@ * \brief Function library for serial Flash memory. * * - * \version $Id$ * \author Daniele Basile + * + * $WIZ$ module_name = "flash25" + * $WIZ$ module_depends = "kfile" + * $WIZ$ module_configuration = "bertos/cfg/cfg_flash25.h" */ #ifndef DRV_FLASH25_H #define DRV_FLASH25_H -#include +#include "cfg/cfg_flash25.h" #include - -#include +#include /** * Type definition for serial flash memory. @@ -54,6 +56,29 @@ typedef uint32_t flash25Addr_t; typedef uint32_t flash25Size_t; typedef uint8_t flash25Offset_t; +/** + * Flash25 KFile context structure. + */ +typedef struct Flash25 +{ + KFile fd; ///< File descriptor. + KFile *channel; ///< Dataflash comm channel (usually SPI). +} Flash25; + +/** + * ID for dataflash. + */ +#define KFT_FLASH25 MAKE_ID('F', 'L', '2', '5') + + +/** + * Convert + ASSERT from generic KFile to Flash25. + */ +INLINE Flash25 * FLASH25_CAST(KFile *fd) +{ + ASSERT(fd->_type == KFT_FLASH25); + return (Flash25 *)fd; +} /** * Memory definition. @@ -61,7 +86,8 @@ typedef uint8_t flash25Offset_t; * \note Below are defined valid serial flash memory support to * this drive. Every time we call flash25_init() function we check * if memory defined are right (see flash25.c form more detail). - * \{ + * + * $WIZ$ flash25_list = "FLASH25_AT25F2048" */ #define FLASH25_AT25F2048 1 @@ -78,7 +104,6 @@ typedef uint8_t flash25Offset_t; #endif #define RDY_BIT 0x1 // Statuts of write cycle -/* \} */ /** * Serial flash opcode commands. @@ -109,9 +134,9 @@ typedef enum { FLASH25_SECT4 = 0x30000, ///< Sector 4 (0x30000 -0x3FFFF) } Flash25Sector; -void flash25_init(struct KFile *fd, struct KFile *_channel); -void flash25_chipErase(void); -void flash25_sectorErase(Flash25Sector sector); +void flash25_init(Flash25 *fd, KFile *ch); +void flash25_chipErase(Flash25 *fd); +void flash25_sectorErase(Flash25 *fd, Flash25Sector sector); bool flash25_test(KFile *channel); #endif /* DRV_FLASH25_H */