flash25.h

Go to the documentation of this file.
00001 
00041 #ifndef DRV_FLASH25_H
00042 #define DRV_FLASH25_H
00043 
00044 #include <kern/kfile.h>
00045 #include <cfg/compiler.h>
00046 
00047 
00048 #include <appconfig.h>
00049 
00053 typedef uint32_t flash25Addr_t;
00054 typedef uint32_t flash25Size_t;
00055 typedef uint8_t flash25Offset_t;
00056 
00057 
00066 #define FLASH25_AT25F2048         1
00067 
00068 #if CONFIG_FLASH25 == FLASH25_AT25F2048
00069     #define FLASH25_MANUFACTURER_ID    0x1F  // ATMEL
00070     #define FLASH25_DEVICE_ID          0x63  // Device ID
00071     #define FLASH25_PAGE_SIZE          256   // Page size in byte
00072     #define FLASH25_NUM_SECTOR         4     // Number of section in serial memory
00073     #define FLASH25_SECTOR_SIZE        65536UL // Section size in byte
00074     #define FLASH25_MEM_SIZE           FLASH25_NUM_SECTOR * FLASH25_SECTOR_SIZE
00075     #define FLASH25_NUM_PAGE           FLASH25_MEM_SIZE / FLASH25_PAGE_SIZE
00076 #elif
00077     #error Nothing memory defined in CONFIG_FLASH25 are support.
00078 #endif
00079 
00080 #define RDY_BIT     0x1 // Statuts of write cycle
00081 /* \} */
00082 
00086 typedef enum {
00087     FLASH25_WREN            = 0x6,  
00088     FLASH25_WRDI            = 0x4,  
00089     FLASH25_RDSR            = 0x5,  
00090     FLASH25_WRSR            = 0x1,  
00091     FLASH25_READ            = 0x3,  
00092     FLASH25_PROGRAM         = 0x2,  
00093     FLASH25_SECTORE_ERASE   = 0x52, 
00094     FLASH25_CHIP_ERASE      = 0x62, 
00095     FLASH25_RDID            = 0x15 
00096 } Flash25Opcode;
00097 
00101 #if CONFIG_FLASH25 != FLASH25_AT25F2048
00102     #error Nothing memory defined in CONFIG_FLASH25 are support.
00103 #endif
00104 
00105 typedef enum {
00106     FLASH25_SECT1            = 0x0,      
00107     FLASH25_SECT2            = 0x10000,  
00108     FLASH25_SECT3            = 0x20000,  
00109     FLASH25_SECT4            = 0x30000,  
00110 } Flash25Sector;
00111 
00112 void flash25_init(struct KFile *fd, struct KFile *_channel);
00113 void flash25_chipErase(void);
00114 void flash25_sectorErase(Flash25Sector sector);
00115 bool flash25_test(KFile *channel);
00116 
00117 #endif /* DRV_FLASH25_H */
00118