| Description | The function Init initializes the Flash programming algorithm for a NAND Flash memory device. The parameter cfg is a pointer specifying the device configuration, which also contains default data positions as described in Page Layout Structure. The function is part of the NAND Driver. The prototype is defined in the file File_Config.h. Developers must customize the function. Init is invoked by the function finit at system startup. |
| Example |
/* NAND Device Driver Control Block */
NAND_DRV nand0_drv = {
Init,
UnInit,
PageRead,
PageWrite,
BlockErase
};
static U32 Init (NAND_DRV_CFG *cfg) {
U32 pgSz, cyc;
pgSz = cfg->PageSize;
switch (pgSz) {
case 528:
case 2112:
break;
default:
return ERR_NAND_UNSUPPORTED;
}
FLASHCLK_CTRL = 0x00000022; /* Setup NAND Flash Clock Control */
MLC_CEH = 0; /* Force nCE assert */
MLC_CMD = NAND_CMD_RESET; /* Reset NAND Flash */
if (!StatusFlag (NAND_CHIP_BUSY)) { /* Wait while NAND busy */
return ERR_NAND_HW_TOUT;
}
cyc = cfg->AddrCycles; /* Get address cycles */
MLC_LOCK_PR = 0xA25E; /* Unlock MLC_ICR register */
MLC_ICR = ((cyc == 4) << 1) |
((pgSz == 2112) << 2);
MLC_LOCK_PR = 0xA25E; /* Unlock MLC_TIME register */
MLC_TIME_REG = (3 << 24) | (11 << 19) | (4 << 16) | (2 << 12) |
(4 << 8) | ( 3 << 4) | (4 << 0);
P3_OUTP_SET |= (1 << 19); /* Disable write protect */
return RTV_NOERR;
}
|