10 #ifndef __MX25_DEF_H__
11 #define __MX25_DEF_H__
15 #include "mx25flash_config.h"
33 #define HALF_WORD_MASK 0x0000ffff
39 #define Block_Offset 0x10000 // 64K Block size
40 #define Block32K_Offset 0x8000 // 32K Block size
41 #define Sector_Offset 0x1000 // 4K Sector size
42 #define Page_Offset 0x0100 // 256 Byte Page size
43 #define Page32_Offset 0x0020 // 32 Byte Page size (some products have smaller page size)
44 #define Block_Num (FlashSize / Block_Offset)
48 #define FLASH_WIP_MASK 0x01
49 #define FLASH_LDSO_MASK 0x02
50 #define FLASH_QE_MASK 0x40
52 #define FLASH_OTPLOCK_MASK 0x03
53 #define FLASH_4BYTE_MASK 0x04
54 #define FLASH_WPSEL_MASK 0x80
56 #define FLASH_DC_MASK 0x80
57 #define FLASH_DC_2BIT_MASK 0xC0
59 #define BLOCK_PROTECT_MASK 0xff
60 #define BLOCK_LOCK_MASK 0x01
65 #define CLK_PERIOD 26 // unit: ns
66 #define Min_Cycle_Per_Inst 1 // cycle count of one instruction
67 #define One_Loop_Inst 10 // instruction count of one loop (estimate)
75 #define FlashID 0xc22814
76 #define ElectronicID 0x14
79 #define FlashSize 0x100000 // 1 MB
80 #define CE_period 15625000 // tCE / ( CLK_PERIOD * Min_Cycle_Per_Inst *One_Loop_Inst)
81 #define tW 40000000 // 40ms
82 #define tDP 10000 // 10us
83 #define tBP 100000 // 100us
84 #define tPP 10000000 // 10ms
85 #define tSE 240000000 // 240ms
86 #define tBE32 1750000000 // 1.75s
87 #define tBE 3500000000 // 3.5s
88 #define tPUW 10000000 // 10ms
99 #define DUMMY_CONF_2READ 0x08040804
100 #define DUMMY_CONF_4READ 0x0A080406
101 #define DUMMY_CONF_FASTREAD 0x08080808
102 #define DUMMY_CONF_DREAD 0x08080808
103 #define DUMMY_CONF_QREAD 0x08080808
107 #define DUMMY_CONF_2READ 0x0A080604
108 #define DUMMY_CONF_4READ 0x0A080406
109 #define DUMMY_CONF_FASTREAD 0x0A080608
110 #define DUMMY_CONF_DREAD 0x0A080608
111 #define DUMMY_CONF_QREAD 0x0A080608
116 #define WriteStatusRegCycleTime tW / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
117 #define PageProgramCycleTime tPP / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
118 #define SectorEraseCycleTime tSE / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
119 #define BlockEraseCycleTime tBE / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
120 #define ChipEraseCycleTime CE_period
121 #define FlashFullAccessTime tPUW / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
124 #define ByteProgramCycleTime tBP / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
127 #define WriteSecuRegCycleTime tWSR / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
130 #define BlockErase32KCycleTime tBE32 / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
133 #define WriteExtRegCycleTime tWREAW / (CLK_PERIOD * Min_Cycle_Per_Inst * One_Loop_Inst)
138 #define FLASH_CMD_RDID 0x9F //RDID (Read Identification)
139 #define FLASH_CMD_RES 0xAB //RES (Read Electronic ID)
140 #define FLASH_CMD_REMS 0x90 //REMS (Read Electronic & Device ID)
143 #define FLASH_CMD_WRSR 0x01 //WRSR (Write Status Register)
144 #define FLASH_CMD_RDSR 0x05 //RDSR (Read Status Register)
145 #define FLASH_CMD_WRSCUR 0x2F //WRSCUR (Write Security Register)
146 #define FLASH_CMD_RDSCUR 0x2B //RDSCUR (Read Security Register)
147 #define FLASH_CMD_RDCR 0x15 //RDCR (Read Configuration Register)
150 #define FLASH_CMD_READ 0x03 //READ (1 x I/O)
151 #define FLASH_CMD_2READ 0xBB //2READ (2 x I/O)
152 #define FLASH_CMD_4READ 0xEB //4READ (4 x I/O)
153 #define FLASH_CMD_FASTREAD 0x0B //FAST READ (Fast read data)
154 #define FLASH_CMD_DREAD 0x3B //DREAD (1In/2 Out fast read)
155 #define FLASH_CMD_QREAD 0x6B //QREAD (1In/4 Out fast read)
156 #define FLASH_CMD_RDSFDP 0x5A //RDSFDP (Read SFDP)
159 #define FLASH_CMD_WREN 0x06 //WREN (Write Enable)
160 #define FLASH_CMD_WRDI 0x04 //WRDI (Write Disable)
161 #define FLASH_CMD_PP 0x02 //PP (page program)
162 #define FLASH_CMD_4PP 0x38 //4PP (Quad page program)
165 #define FLASH_CMD_SE 0x20 //SE (Sector Erase)
166 #define FLASH_CMD_BE32K 0x52 //BE32K (Block Erase 32kb)
167 #define FLASH_CMD_BE 0xD8 //BE (Block Erase)
168 #define FLASH_CMD_CE 0x60 //CE (Chip Erase) hex code: 60 or C7
171 #define FLASH_CMD_DP 0xB9 //DP (Deep Power Down)
172 #define FLASH_CMD_ENSO 0xB1 //ENSO (Enter Secured OTP)
173 #define FLASH_CMD_EXSO 0xC1 //EXSO (Exit Secured OTP)
175 #define FLASH_CMD_SBL 0x77 //SBL (Set Burst Length) new: 0x77
177 #define FLASH_CMD_SBL 0xC0 //SBL (Set Burst Length) Old: 0xC0
181 #define FLASH_CMD_RSTEN 0x66 //RSTEN (Reset Enable)
182 #define FLASH_CMD_RST 0x99 //RST (Reset Memory)
185 #ifdef LCR_CMD_0xDD_0xD5
190 #define FLASH_CMD_PGM_ERS_S 0xB0 //PGM/ERS Suspend (Suspends Program/Erase)
191 #define FLASH_CMD_PGM_ERS_R 0x30 //PGM/ERS Erase (Resumes Program/Erase)
192 #define FLASH_CMD_NOP 0x00 //NOP (No Operation)
196 FlashOperationSuccess,
224 void MX25_init(
void );
227 ReturnMsg MX25_RDID( uint32_t *Identification );
228 ReturnMsg MX25_RES( uint8_t *ElectricIdentification );
229 ReturnMsg MX25_REMS( uint16_t *REMS_Identification,
FlashStatus *fsptr );
231 ReturnMsg MX25_RDSR( uint8_t *StatusReg );
232 #ifdef SUPPORT_WRSR_CR
233 ReturnMsg MX25_WRSR( uint16_t UpdateValue );
235 ReturnMsg MX25_WRSR( uint8_t UpdateValue );
237 ReturnMsg MX25_RDSCUR( uint8_t *SecurityReg );
238 ReturnMsg MX25_WRSCUR(
void );
239 ReturnMsg MX25_RDCR( uint8_t *ConfigReg );
241 ReturnMsg MX25_READ( uint32_t flash_address, uint8_t *target_address, uint32_t byte_length );
242 ReturnMsg MX25_2READ( uint32_t flash_address, uint8_t *target_address, uint32_t byte_length );
243 ReturnMsg MX25_4READ( uint32_t flash_address, uint8_t *target_address, uint32_t byte_length );
244 ReturnMsg MX25_FASTREAD( uint32_t flash_address, uint8_t *target_address, uint32_t byte_length );
245 ReturnMsg MX25_DREAD( uint32_t flash_address, uint8_t *target_address, uint32_t byte_length );
246 ReturnMsg MX25_QREAD( uint32_t flash_address, uint8_t *target_address, uint32_t byte_length );
247 ReturnMsg MX25_RDSFDP( uint32_t flash_address, uint8_t *target_address, uint32_t byte_length );
249 ReturnMsg MX25_WREN(
void );
250 ReturnMsg MX25_WRDI(
void );
251 ReturnMsg MX25_PP( uint32_t flash_address, uint8_t *source_address, uint32_t byte_length );
252 ReturnMsg MX25_4PP( uint32_t flash_address, uint8_t *source_address, uint32_t byte_length );
254 ReturnMsg MX25_SE( uint32_t flash_address );
255 ReturnMsg MX25_BE32K( uint32_t flash_address );
256 ReturnMsg MX25_BE( uint32_t flash_address );
257 ReturnMsg MX25_CE(
void );
259 ReturnMsg MX25_DP(
void );
260 ReturnMsg MX25_ENSO(
void );
261 ReturnMsg MX25_EXSO(
void );
262 ReturnMsg MX25_SBL( uint8_t burstconfig );
264 ReturnMsg MX25_RSTEN(
void );
267 ReturnMsg MX25_PGM_ERS_S(
void );
268 ReturnMsg MX25_PGM_ERS_R(
void );
269 ReturnMsg MX25_NOP(
void );