Description
Source
Call Graph
Start Line: 473
unsigned char RawNandFlash_Initialize(struct RawNandFlash *raw, const struct NandFlashModel *model, unsigned int commandAddress, unsigned int addressAddress, unsigned int dataAddress, const Pin pinChipEnable, const Pin pinReadyBusy)
{
TRACE_DEBUG("RawNandFlash_Initialize()\r\n");
// Initialize fields
raw->commandAddress = commandAddress;
raw->addressAddress = addressAddress;
raw->dataAddress = dataAddress;
raw->pinChipEnable = pinChipEnable;
raw->pinReadyBusy = pinReadyBusy;
// Reset
RawNandFlash_Reset(raw);
// If model is not provided, autodetect it
if (!model) {
TRACE_DEBUG("No model provided, trying autodetection ...\n\r");
if (NandFlashModel_Find(nandFlashModelList,
NandFlashModelList_SIZE,
RawNandFlash_ReadId(raw),
&(raw->model))) {
TRACE_ERROR(
"RawNandFlash_Initialize: Could not autodetect chip.\n\r");
return NandCommon_ERROR_UNKNOWNMODEL;
}
}
else {
// Copy provided model
raw->model = *model;
}
return 0;
}