BeRTOS
|
00001 00044 #ifndef DRV_FLASH25_H 00045 #define DRV_FLASH25_H 00046 00047 #include "cfg/cfg_flash25.h" 00048 #include <cfg/compiler.h> 00049 00050 #include <io/kfile.h> 00051 00055 typedef uint32_t flash25Addr_t; 00056 typedef uint32_t flash25Size_t; 00057 typedef uint8_t flash25Offset_t; 00058 00062 typedef struct Flash25 00063 { 00064 KFile fd; 00065 KFile *channel; 00066 } Flash25; 00067 00071 #define KFT_FLASH25 MAKE_ID('F', 'L', '2', '5') 00072 00073 00077 INLINE Flash25 * FLASH25_CAST(KFile *fd) 00078 { 00079 ASSERT(fd->_type == KFT_FLASH25); 00080 return (Flash25 *)fd; 00081 } 00082 00092 #define FLASH25_AT25F2048 1 00093 00094 #if CONFIG_FLASH25 == FLASH25_AT25F2048 00095 #define FLASH25_MANUFACTURER_ID 0x1F // ATMEL 00096 #define FLASH25_DEVICE_ID 0x63 // Device ID 00097 #define FLASH25_PAGE_SIZE 256 // Page size in byte 00098 #define FLASH25_NUM_SECTOR 4 // Number of section in serial memory 00099 #define FLASH25_SECTOR_SIZE 65536UL // Section size in byte 00100 #define FLASH25_MEM_SIZE FLASH25_NUM_SECTOR * FLASH25_SECTOR_SIZE 00101 #define FLASH25_NUM_PAGE FLASH25_MEM_SIZE / FLASH25_PAGE_SIZE 00102 #else 00103 #error Nothing memory defined in CONFIG_FLASH25 are support. 00104 #endif 00105 00106 #define RDY_BIT 0x1 // Statuts of write cycle 00107 00111 typedef enum { 00112 FLASH25_WREN = 0x6, 00113 FLASH25_WRDI = 0x4, 00114 FLASH25_RDSR = 0x5, 00115 FLASH25_WRSR = 0x1, 00116 FLASH25_READ = 0x3, 00117 FLASH25_PROGRAM = 0x2, 00118 FLASH25_SECTORE_ERASE = 0x52, 00119 FLASH25_CHIP_ERASE = 0x62, 00120 FLASH25_RDID = 0x15 00121 } Flash25Opcode; 00122 00126 #if CONFIG_FLASH25 != FLASH25_AT25F2048 00127 #error Nothing memory defined in CONFIG_FLASH25 are support. 00128 #endif 00129 00130 typedef enum { 00131 FLASH25_SECT1 = 0x0, 00132 FLASH25_SECT2 = 0x10000, 00133 FLASH25_SECT3 = 0x20000, 00134 FLASH25_SECT4 = 0x30000, 00135 } Flash25Sector; 00136 00137 void flash25_init(Flash25 *fd, KFile *ch); 00138 void flash25_chipErase(Flash25 *fd); 00139 void flash25_sectorErase(Flash25 *fd, Flash25Sector sector); 00140 bool flash25_test(KFile *channel); 00141 00142 #endif /* DRV_FLASH25_H */ 00143