DRV_AT25_Initialize Function

C

SYS_MODULE_OBJ DRV_AT25_Initialize(
const SYS_MODULE_INDEX drvIndex,
const SYS_MODULE_INIT * const init
)

Summary

Initializes the AT25 EEPROM device

Description

This routine initializes the AT25 EEPROM device driver making it ready for clients to open and use. The initialization data is specified by the init parameter. It is a single instance driver, so this API should be called only once.

Precondition

None.

Parameters

ParamDescription
drvIndexIdentifier for the instance to be initialized.
initPointer to the init data structure containing any data necessary to initialize the driver.

Returns

If successful, returns a valid handle to a driver instance object. Otherwise, returns SYS_MODULE_OBJ_INVALID.

Example

SYS_MODULE_OBJ sysObjDrvAT25;

DRV_AT25_PLIB_INTERFACE drvAT25PlibAPI = {
    .writeRead = (DRV_AT25_PLIB_WRITE_READ)SPI0_WriteRead,
    .write = (DRV_AT25_PLIB_WRITE)SPI0_Write,
    .read = (DRV_AT25_PLIB_READ)SPI0_Read,
    .isBusy = (DRV_AT25_PLIB_IS_BUSY)SPI0_IsBusy,
    .callbackRegister = (DRV_AT25_PLIB_CALLBACK_REGISTER)SPI0_CallbackRegister,
};

DRV_AT25_INIT drvAT25InitData = {
    .spiPlib = &drvAT25PlibAPI,
    .numClients = DRV_AT25_CLIENTS_NUMBER_IDX,
    .pageSize = DRV_AT25_EEPROM_PAGE_SIZE,
    .flashSize = DRV_AT25_EEPROM_FLASH_SIZE,
    .blockStartAddress = 0x0,
    .chipSelectPin = DRV_AT25_CHIP_SELECT_PIN_IDX,
    .holdPin = DRV_AT25_HOLD_PIN_IDX,
    .writeProtectPin = DRV_AT25_WP_PIN_IDX,
};

sysObjDrvAT25 = DRV_AT25_Initialize(DRV_AT25_INDEX, (SYS_MODULE_INIT *)&drvAT25InitData);

Remarks

This routine must be called before any other DRV_AT25 routine is called. This routine should only be called once during system initialization.