2020#include " OSPIFBlockDevice.h"
2121#include < string.h>
2222#include " rtos/ThisThread.h"
23- #if defined(TARGET_MX25LM51245G)
24- #include " MX25LM51245G_config.h"
25- #endif
2623
2724#ifndef MBED_CONF_MBED_TRACE_ENABLE
2825#define MBED_CONF_MBED_TRACE_ENABLE 0
@@ -51,18 +48,6 @@ using namespace mbed;
5148#define OSPIF_STATUS_BIT_WEL 0x2 // Write Enable Latch
5249#define OSPIF_NO_QUAD_ENABLE (-1 )
5350
54- // Configuration Register2 address
55- #define OSPIF_CR2_OPI_EN_ADDR 0x00000000
56- #define OSPIF_CR2_BANK_STATUS_ADDR 0xc0000000
57- #define OSPIF_CR2_RWWDI ((uint8_t )0x00 ) /* !< No active program or erase operation */
58- #define OSPIF_CR2_RWWDS ((uint8_t )0x01 ) /* !< Program/erase in other bank */
59- #define OSPIF_CR2_RWWBS ((uint8_t )0x03 ) /* !< program/erase operation in addressed bank */
60-
61- #ifdef MX_FLASH_SUPPORT_RWW
62- #define MX25LM51245G_BANK_SIZE 0x01000000 /* 16 MBytes */
63- #define MX25LM51245G_BANK_SIZE_MASK ~(MX25LM51245G_BANK_SIZE - 1 ) /* 0xFF000000 */
64- #endif
65-
6651/* SFDP Header Parsing */
6752/* **********************/
6853#define OSPIF_RSFDP_DUMMY_CYCLES 8
@@ -177,6 +162,21 @@ using namespace mbed;
177162// Length of data returned from RDID instruction
178163#define OSPI_RDID_DATA_LENGTH 3
179164
165+ #ifdef NEED_DEFINE_SFDP_PARA
166+ uint8_t _sfdp_head_table[32 ] = {0x53 , 0x46 , 0x44 , 0x50 , 0x06 , 0x01 , 0x02 , 0xFF , 0x00 , 0x06 , 0x01 ,
167+ 0x10 , 0x30 , 0x00 , 0x00 , 0xFF , 0xC2 , 0x00 , 0x01 , 0x04 , 0x10 , 0x01 ,
168+ 0x00 , 0xFF , 0x84 , 0x00 , 0x01 , 0x02 , 0xC0 , 0x00 , 0x00 , 0xFF
169+ };
170+ uint8_t _sfdp_basic_param_table[64 ] = {0x30 , 0xFF , 0xFB , 0xFF , 0xFF , 0xFF , 0xFF , 0x1F , 0xFF , 0xFF ,
171+ 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0x01 , 0x14 , 0xEC ,
172+ 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0x0C , 0x20 ,
173+ 0x10 , 0xDC , 0x00 , 0xFF , 0x00 , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
174+ 0x81 , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
175+ 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
176+ 0xFF , 0x50 , 0xF9 , 0x80
177+ };
178+ uint8_t _sfdp_4_byte_inst_table[8 ] = {0x7F , 0xEF , 0xFF , 0xFF , 0x21 , 0x5C , 0xDC , 0x14 };
179+ #endif
180180
181181/* Init function to initialize Different Devices CS static list */
182182static PinName *generate_initialized_active_ospif_csel_arr ();
@@ -407,7 +407,7 @@ int OSPIFBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
407407
408408#ifdef MX_FLASH_SUPPORT_RWW
409409 bool need_wait;
410- need_wait = (_wait_flag != NOT_STARTED) && ((addr & MX25LM51245G_BANK_SIZE_MASK ) == _busy_bank);
410+ need_wait = (_wait_flag != NOT_STARTED) && ((addr & MX25LW51245G_BANK_SIZE_MASK ) == _busy_bank);
411411
412412 // Wait for ready
413413 if (need_wait) {
@@ -499,7 +499,7 @@ int OSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
499499
500500#ifdef MX_FLASH_SUPPORT_RWW
501501 _wait_flag = WRITE_WAIT_STARTED;
502- _busy_bank = addr & MX25LM51245G_BANK_SIZE_MASK ;
502+ _busy_bank = addr & MX25LW51245G_BANK_SIZE_MASK ;
503503
504504 _mutex.unlock ();
505505
@@ -512,7 +512,7 @@ int OSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
512512 goto exit_point;
513513 }
514514 _mutex.unlock ();
515- #endif
515+ #endif
516516 buffer = static_cast <const uint8_t *>(buffer) + chunk;
517517 addr += chunk;
518518 size -= chunk;
@@ -606,7 +606,7 @@ int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size)
606606
607607#ifdef MX_FLASH_SUPPORT_RWW
608608 _wait_flag = ERASE_WAIT_STARTED;
609- _busy_bank = addr & MX25LM51245G_BANK_SIZE_MASK ;
609+ _busy_bank = addr & MX25LW51245G_BANK_SIZE_MASK ;
610610
611611 _mutex.unlock ();
612612
@@ -1631,7 +1631,7 @@ bool OSPIFBlockDevice::_is_mem_ready_rww(bd_addr_t addr, uint8_t rw)
16311631 static uint32_t rww_cnt = 0 ; // For testing
16321632 static uint32_t rwe_cnt = 0 ; // For testing
16331633
1634- bd_addr_t bank_addr = addr & MX25LM51245G_BANK_SIZE_MASK ;
1634+ bd_addr_t bank_addr = addr & MX25LW51245G_BANK_SIZE_MASK ;
16351635
16361636 if ((_wait_flag == NOT_STARTED) || (!rw && bank_addr != _busy_bank)) {
16371637 return mem_ready;
0 commit comments