30#include "mt25tl01g_conf.h"
56#define MT25TL01G_ERROR_INIT -1
57#define MT25TL01G_ERROR_COMMAND -2
58#define MT25TL01G_ERROR_TRANSMIT -3
59#define MT25TL01G_ERROR_RECEIVE -4
60#define MT25TL01G_ERROR_AUTOPOLLING -5
61#define MT25TL01G_ERROR_MEMORYMAPPED -6
90 MT25TL01G_STR_TRANSFER = 0,
91 MT25TL01G_DTR_TRANSFER
92} MT25TL01G_Transfer_t;
100 MT25TL01G_DUALFLASH_ENABLE =QSPI_DUALFLASH_ENABLE
126#define MT25TL01G_FLASH_SIZE 0x8000000
127#define MT25TL01G_SECTOR_SIZE 0x10000
128#define MT25TL01G_SUBSECTOR_SIZE 0x1000
129#define MT25TL01G_PAGE_SIZE 0x100
131#define MT25TL01G_DIE_ERASE_MAX_TIME 460000
132#define MT25TL01G_SECTOR_ERASE_MAX_TIME 1000
133#define MT25TL01G_SUBSECTOR_ERASE_MAX_TIME 400
139#define MT25TL01G_RESET_ENABLE_CMD 0x66
140#define MT25TL01G_RESET_MEMORY_CMD 0x99
143#define MT25TL01G_READ_ID_CMD 0x9E
144#define MT25TL01G_READ_ID_CMD2 0x9F
145#define MT25TL01G_MULTIPLE_IO_READ_ID_CMD 0xAF
146#define MT25TL01G_READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A
149#define MT25TL01G_READ_CMD 0x03
150#define MT25TL01G_READ_4_BYTE_ADDR_CMD 0x13
152#define MT25TL01G_FAST_READ_CMD 0x0B
153#define MT25TL01G_FAST_READ_DTR_CMD 0x0D
154#define MT25TL01G_FAST_READ_4_BYTE_ADDR_CMD 0x0C
155#define MT25TL01G_FAST_READ_4_BYTE_DTR_CMD 0x0E
157#define MT25TL01G_DUAL_OUT_FAST_READ_CMD 0x3B
158#define MT25TL01G_DUAL_OUT_FAST_READ_DTR_CMD 0x3D
159#define MT25TL01G_DUAL_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x3C
161#define MT25TL01G_DUAL_INOUT_FAST_READ_CMD 0xBB
162#define MT25TL01G_DUAL_INOUT_FAST_READ_DTR_CMD 0xBD
163#define MT25TL01G_DUAL_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xBC
165#define MT25TL01G_QUAD_OUT_FAST_READ_CMD 0x6B
166#define MT25TL01G_QUAD_OUT_FAST_READ_DTR_CMD 0x6D
167#define MT25TL01G_QUAD_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x6C
169#define MT25TL01G_QUAD_INOUT_FAST_READ_CMD 0xEB
170#define MT25TL01G_QUAD_INOUT_FAST_READ_DTR_CMD 0xED
171#define MT25TL01G_QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xEC
172#define MT25TL01G_QUAD_INOUT_FAST_READ_4_BYTE_DTR_CMD 0xEE
174#define MT25TL01G_WRITE_ENABLE_CMD 0x06
175#define MT25TL01G_WRITE_DISABLE_CMD 0x04
178#define MT25TL01G_READ_STATUS_REG_CMD 0x05
179#define MT25TL01G_WRITE_STATUS_REG_CMD 0x01
181#define MT25TL01G_READ_LOCK_REG_CMD 0xE8
182#define MT25TL01G_WRITE_LOCK_REG_CMD 0xE5
184#define MT25TL01G_READ_FLAG_STATUS_REG_CMD 0x70
185#define MT25TL01G_CLEAR_FLAG_STATUS_REG_CMD 0x50
187#define MT25TL01G_READ_NONVOL_CFG_REG_CMD 0xB5
188#define MT25TL01G_WRITE_NONVOL_CFG_REG_CMD 0xB1
190#define MT25TL01G_READ_VOL_CFG_REG_CMD 0x85
191#define MT25TL01G_WRITE_VOL_CFG_REG_CMD 0x81
193#define MT25TL01G_READ_ENHANCED_VOL_CFG_REG_CMD 0x65
194#define MT25TL01G_WRITE_ENHANCED_VOL_CFG_REG_CMD 0x61
196#define MT25TL01G_READ_EXT_ADDR_REG_CMD 0xC8
197#define MT25TL01G_WRITE_EXT_ADDR_REG_CMD 0xC5
200#define MT25TL01G_PAGE_PROG_CMD 0x02
201#define MT25TL01G_PAGE_PROG_4_BYTE_ADDR_CMD 0x12
203#define MT25TL01G_DUAL_IN_FAST_PROG_CMD 0xA2
204#define MT25TL01G_EXT_DUAL_IN_FAST_PROG_CMD 0xD2
206#define MT25TL01G_QUAD_IN_FAST_PROG_CMD 0x32
207#define MT25TL01G_EXT_QUAD_IN_FAST_PROG_CMD 0x38
208#define MT25TL01G_QUAD_IN_FAST_PROG_4_BYTE_ADDR_CMD 0x34
211#define MT25TL01G_SUBSECTOR_ERASE_CMD_4K 0x20
212#define MT25TL01G_SUBSECTOR_ERASE_4_BYTE_ADDR_CMD_4K 0x21
214#define MT25TL01G_SUBSECTOR_ERASE_CMD_32K 0x52
216#define MT25TL01G_SECTOR_ERASE_CMD 0xD8
217#define MT25TL01G_SECTOR_ERASE_4_BYTE_ADDR_CMD 0xDC
219#define MT25TL01G_DIE_ERASE_CMD 0xC7
221#define MT25TL01G_PROG_ERASE_RESUME_CMD 0x7A
222#define MT25TL01G_PROG_ERASE_SUSPEND_CMD 0x75
225#define MT25TL01G_READ_OTP_ARRAY_CMD 0x4B
226#define MT25TL01G_PROG_OTP_ARRAY_CMD 0x42
229#define MT25TL01G_ENTER_4_BYTE_ADDR_MODE_CMD 0xB7
230#define MT25TL01G_EXIT_4_BYTE_ADDR_MODE_CMD 0xE9
233#define MT25TL01G_ENTER_QUAD_CMD 0x35
234#define MT25TL01G_EXIT_QUAD_CMD 0xF5
235#define MT25TL01G_ENTER_DEEP_POWER_DOWN 0xB9
236#define MT25TL01G_RELEASE_FROM_DEEP_POWER_DOWN 0xAB
239#define MT25TL01G_READ_SECTOR_PROTECTION_CMD 0x2D
240#define MT25TL01G_PROGRAM_SECTOR_PROTECTION 0x2C
241#define MT25TL01G_READ_PASSWORD_CMD 0x27
242#define MT25TL01G_WRITE_PASSWORD_CMD 0x28
243#define MT25TL01G_UNLOCK_PASSWORD_CMD 0x29
244#define MT25TL01G_READ_GLOBAL_FREEZE_BIT 0xA7
245#define MT25TL01G_READ_VOLATILE_LOCK_BITS 0xE8
246#define MT25TL01G_WRITE_VOLATILE_LOCK_BITS 0xE5
248#define MT25TL01G_WRITE_4_BYTE_VOLATILE_LOCK_BITS 0xE1
249#define MT25TL01G_READ_4_BYTE_VOLATILE_LOCK_BITS 0xE0
251#define MT25TL01G_READ_OTP_ARRAY 0x4B
252#define MT25TL01G_PROGRAM_OTP_ARRAY 0x42
259#define MT25TL01G_SR_WIP ((uint8_t)0x01)
260#define MT25TL01G_SR_WREN ((uint8_t)0x02)
261#define MT25TL01G_SR_BLOCKPR ((uint8_t)0x5C)
262#define MT25TL01G_SR_PRBOTTOM ((uint8_t)0x20)
263#define MT25TL01G_SR_SRWREN ((uint8_t)0x80)
266#define MT25TL01G_NVCR_NBADDR ((uint16_t)0x0001)
267#define MT25TL01G_NVCR_SEGMENT ((uint16_t)0x0002)
268#define MT25TL01G_NVCR_DUAL ((uint16_t)0x0004)
269#define MT25TL01G_NVCR_QUAB ((uint16_t)0x0008)
270#define MT25TL01G_NVCR_RH ((uint16_t)0x0010)
271#define MT25TL01G_NVCR_DTRP ((uint16_t)0x0020)
272#define MT25TL01G_NVCR_ODS ((uint16_t)0x01C0)
273#define MT25TL01G_NVCR_XIP ((uint16_t)0x0E00)
274#define MT25TL01G_NVCR_NB_DUMMY ((uint16_t)0xF000)
277#define MT25TL01G_VCR_WRAP ((uint8_t)0x03)
278#define MT25TL01G_VCR_XIP ((uint8_t)0x08)
279#define MT25TL01G_VCR_NB_DUMMY ((uint8_t)0xF0)
282#define MT25TL01G_EAR_HIGHEST_SE ((uint8_t)0x03)
283#define MT25TL01G_EAR_THIRD_SEG ((uint8_t)0x02)
284#define MT25TL01G_EAR_SECOND_SEG ((uint8_t)0x01)
285#define MT25TL01G_EAR_LOWEST_SEG ((uint8_t)0x00)
288#define MT25TL01G_EVCR_ODS ((uint8_t)0x07)
289#define MT25TL01G_EVCR_RH ((uint8_t)0x10)
290#define MT25TL01G_EVCR_DTRP ((uint8_t)0x20)
291#define MT25TL01G_EVCR_DUAL ((uint8_t)0x40)
292#define MT25TL01G_EVCR_QUAD ((uint8_t)0x80)
295#define MT25TL01G_FSR_NBADDR ((uint8_t)0x01)
296#define MT25TL01G_FSR_PRERR ((uint8_t)0x02)
297#define MT25TL01G_FSR_PGSUS ((uint8_t)0x04)
298#define MT25TL01G_FSR_PGERR ((uint8_t)0x10)
299#define MT25TL01G_FSR_ERERR ((uint8_t)0x20)
300#define MT25TL01G_FSR_ERSUS ((uint8_t)0x40)
301#define MT25TL01G_FSR_READY ((uint8_t)0x80)
int32_t MT25TL01G_ProgEraseSuspend(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Program/Erases suspend. Interruption Program/Erase operations. After the device has entered Erase-Sus...
Definition: mt25tl01g.c:887
int32_t MT25TL01G_ReadID(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode, uint8_t *ID)
Read Flash 3 Byte IDs. Manufacturer ID, Memory type, Memory density SPI/QPI; 1-0-1/4-0-4.
Definition: mt25tl01g.c:846
int32_t MT25TL01G_ReleaseFromDeepPowerDown(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Release from deep power down. After CS# go high, system need wait tRES1 time for device ready....
Definition: mt25tl01g.c:982
int32_t MT25TL01G_EnterQPIMode(QSPI_HandleTypeDef *Ctx)
This function put QSPI memory in QPI mode (Quad I/O) from SPI mode. SPI -> QPI; 1-x-x -> 4-4-4 SPI; 1...
Definition: mt25tl01g.c:587
int32_t MT25TL01G_ReadDTR(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode, uint8_t *pData, uint32_t ReadAddr, uint32_t Size)
Reads an amount of data from the QSPI memory on DTR mode. SPI/QPI; 1-1-1/1-1-2/1-4-4/4-4-4.
Definition: mt25tl01g.c:319
int32_t MT25TL01G_EnableMemoryMappedModeSTR(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Reads an amount of data from the QSPI memory on STR mode. SPI/QPI; 1-1-1/1-2-2/1-4-4/4-4-4.
Definition: mt25tl01g.c:710
int32_t MT25TL01G_ChipErase(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Whole chip erase. SPI/QPI; 1-0-0/4-0-0.
Definition: mt25tl01g.c:518
int32_t MT25TL01G_ResetEnable(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Flash reset enable command SPI/QPI; 1-0-0, 4-0-0.
Definition: mt25tl01g.c:780
int32_t MT25TL01G_ReadSPBLockRegister(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode, uint8_t *SPBRegister)
Read SECTOR PROTECTION Block register value. SPI; 1-0-1.
Definition: mt25tl01g.c:1014
int32_t MT25TL01G_EnterDeepPowerDown(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Deep power down. The device is not active and all Write/Program/Erase instruction are ignored....
Definition: mt25tl01g.c:950
int32_t MT25TL01G_BlockErase(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode, uint32_t BlockAddress, MT25TL01G_Erase_t BlockSize)
Erases the specified block of the QSPI memory. MT25TL01G support 4K, 32K, 64K size block erase comman...
Definition: mt25tl01g.c:466
int32_t MT25TL01G_WriteDisable(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
This function reset the (WEL) Write Enable Latch bit. SPI/QPI; 1-0-0/4-0-0.
Definition: mt25tl01g.c:222
int32_t MT25TL01G_EnableMemoryMappedModeDTR(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Reads an amount of data from the QSPI memory on DTR mode. SPI/QPI; 1-1-1/1-1-2/1-4-4/4-4-4.
Definition: mt25tl01g.c:645
int32_t MT25TL01G_WriteEnable(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
This function send a Write Enable and wait it is effective.
Definition: mt25tl01g.c:173
int32_t MT25TL01G_ReadStatusRegister(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode, uint8_t *Value)
Read Flash Status register value SPI/QPI; 1-0-1/4-0-4.
Definition: mt25tl01g.c:549
int32_t MT25TL01G_Exit4BytesAddressMode(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Flash exit 4 Byte address mode. Effect 3/4 address byte commands only. SPI/QPI; 1-0-0/4-0-0.
Definition: mt25tl01g.c:103
int32_t MT25TL01G_GetFlashInfo(MT25TL01G_Info_t *pInfo)
Return the configuration of the QSPI memory.
Definition: mt25tl01g.c:44
int32_t MT25TL01G_Enter4BytesAddressMode(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
This function set the QSPI memory in 4-byte address mode SPI/QPI; 1-0-1/4-0-4.
Definition: mt25tl01g.c:61
int32_t MT25TL01G_AutoPollingMemReady(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Polling WIP(Write In Progress) bit become to 0 SPI/QPI;4-0-4.
Definition: mt25tl01g.c:134
int32_t MT25TL01G_ProgEraseResume(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Program/Erases resume. SPI/QPI; 1-0-0/4-0-0.
Definition: mt25tl01g.c:918
int32_t MT25TL01G_ResetMemory(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode)
Flash reset memory command SPI/QPI; 1-0-0, 4-0-0.
Definition: mt25tl01g.c:812
int32_t MT25TL01G_PageProgram(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode, uint8_t *pData, uint32_t WriteAddr, uint32_t Size)
Writes an amount of data to the QSPI memory. SPI/QPI; 1-1-1/1-2-2/1-4-4/4-4-4.
Definition: mt25tl01g.c:255
int32_t MT25TL01G_ReadSTR(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode, uint8_t *pData, uint32_t ReadAddr, uint32_t Size)
Reads an amount of data from the QSPI memory on STR mode. SPI/QPI; 1-1-1/1-2-2/1-4-4/4-4-4.
Definition: mt25tl01g.c:392
int32_t MT25TL01G_ExitQPIMode(QSPI_HandleTypeDef *Ctx)
This function put QSPI memory in SPI mode (Single I/O) from QPI mode. QPI -> SPI; 4-4-4 -> 1-x-x QPI;...
Definition: mt25tl01g.c:616
MT25TL01G_Erase_t
Definition: mt25tl01g.h:109
MT25TL01G_DualFlash_t
Definition: mt25tl01g.h:98
MT25TL01G_Interface_t
Definition: mt25tl01g.h:79
@ MT25TL01G_ERASE_32K
Definition: mt25tl01g.h:111
@ MT25TL01G_ERASE_64K
Definition: mt25tl01g.h:112
@ MT25TL01G_ERASE_CHIP
Definition: mt25tl01g.h:113
@ MT25TL01G_ERASE_4K
Definition: mt25tl01g.h:110
@ MT25TL01G_DUALFLASH_DISABLE
Definition: mt25tl01g.h:99
@ MT25TL01G_SPI_MODE
Definition: mt25tl01g.h:80
@ MT25TL01G_SPI_4IO_MODE
Definition: mt25tl01g.h:82
@ MT25TL01G_SPI_2IO_MODE
Definition: mt25tl01g.h:81
@ MT25TL01G_QPI_MODE
Definition: mt25tl01g.h:83
Definition: mt25tl01g.h:67
uint32_t EraseSectorsNumber
Definition: mt25tl01g.h:70
uint32_t ProgPageSize
Definition: mt25tl01g.h:71
uint32_t EraseSectorSize
Definition: mt25tl01g.h:69
uint32_t FlashSize
Definition: mt25tl01g.h:68
uint32_t ProgPagesNumber
Definition: mt25tl01g.h:72
Definition: mt25tl01g.h:46
uint32_t ProgPagesNumber
Definition: mt25tl01g.h:51
uint32_t FlashSize
Definition: mt25tl01g.h:47
uint32_t EraseSectorSize
Definition: mt25tl01g.h:48
uint32_t ProgPageSize
Definition: mt25tl01g.h:50
uint32_t EraseSectorsNumber
Definition: mt25tl01g.h:49