SPIFI_DEV_FAMILY_T *SPIFI_REG_FAMILY_Micron_2Byte_SStatus(void)
{
static SPIFI_DEV_FAMILY_T handle;
static SPIFI_FAM_DESC_T desc;
/* Store the device specific info so it can be returned */
desc.pFamName = "Micron N25QxxxA based family";
desc.pDevList = &devHead;
desc.prvDataSize = PRVDATASIZE;
desc.pPrvDevGetID = deviceGetID;
desc.pPrvDevSetup = devSetup;
desc.pPrvDevRegister = devRegister;
/* Save the descriptor in the handle */
handle.pDesc = &desc;
/* Make sure that the base list is empty and the count reflects 0 */
devHead.pNext = NULL;
devCount = 0;
{
/* ID Micron N25Q128A */
static const SPIFI_DEV_PDATA_T pData = {"N25Q128A", { {0x20, 0xBA, 0x18}, 0, {0}}, /* JEDEC ID, extCount, ext data */
256, /* # of blocks */
0x10000, /* block size 64kB */
4096, /* # of sub-blocks */
0x1000, /* sub-block size 4kB */
0x100, /* page size 256B */
32768, /* max single read bytes ??? noch nicht geändert */
108000000, /* max clock rate 108 MHz */
(SPIFI_CAP_QUAD | SPIFI_CAP_FULLLOCK | SPIFI_CAP_NOBLOCK | SPIFI_CAP_SUBBLKERASE) /* capabilitites */
// (SPIFI_CAP_QUAD | SPIFI_CAP_FULLLOCK | SPIFI_CAP_NOBLOCK | SPIFI_CAP_SUBBLKERASE) /* capabilitites */
};
static SPIFI_DEV_DATA_T data;
data.pDevData = &pData;
devRegister(&handle, &data);
}
/* finally return the handle */
return &handle;
} |
/* Read Identification */
static void deviceGetID(uint32_t spifiAddr, SPIFI_DEVICE_ID_T *pID)
{
uint8_t idx;
volatile uint32_t intStatusRegister;
volatile uint32_t intControlRegister;
LPC_SPIFI_CHIPHW_T *pSpifiCtrlAddr = (LPC_SPIFI_CHIPHW_T *) spifiAddr;
/* Wait for command to complete */
spifi_HW_WaitCMD(pSpifiCtrlAddr);
/* Read ID command, plus read 3 bytes on data */
spifi_HW_SetCmd(pSpifiCtrlAddr,
(SPIFI_CMD_OPCODE(CMD_RDID) | SPIFI_CMD_DATALEN(3 + pID->extCount) | SPIFI_CMD_FIELDFORM(SPIFI_FIELDFORM_ALL_SERIAL) | SPIFI_CMD_FRAMEFORM(SPIFI_FRAMEFORM_OP)));
/* Get info from the device */
pID->mfgId[0] = spifi_HW_GetData8(pSpifiCtrlAddr); /* Manufacturers ID */
pID->mfgId[1] = spifi_HW_GetData8(pSpifiCtrlAddr); /* Memory Type */
pID->mfgId[2] = spifi_HW_GetData8(pSpifiCtrlAddr); /* Memmory Capacity */
/* Read the specified number of extended bytes */
for (idx = 0; idx < pID->extCount; ++idx)
{
pID->extId[idx] = spifi_HW_GetData8(pSpifiCtrlAddr);
}
spifi_HW_WaitCMD(pSpifiCtrlAddr);
} |
#define CMD_RDID 0x9F/**< Read Identification */ |
/* Initialize LPCSPIFILIB library, do not reset the interface */ spifiInit(C_SPIFICTLREGBASE, true); /* Register the family for the device */ spifiRegisterFamily(SPIFI_REG_FAMILY_MicronN25Q); /* Get required memory for detected device, this may vary per device family */ intMemSize = spifiGetHandleMemSize(C_SPIFICTLREGBASE); |