DRV_AT24_Initialize Function

C

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

Summary

Initializes the AT24 EEPROM device

Description

This routine initializes the AT24 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 sysObjDrvAT24;

DRV_AT24_PLIB_INTERFACE drvAT24PlibAPI = {
    .writeRead = (DRV_AT24_PLIB_WRITE_READ)TWIHS0_WriteRead,
    .write = (DRV_AT24_PLIB_WRITE)TWIHS0_Write,
    .read = (DRV_AT24_PLIB_READ)TWIHS0_Read,
    .isBusy = (DRV_AT24_PLIB_IS_BUSY)TWIHS0_IsBusy,
    .errorGet = (DRV_AT24_PLIB_ERROR_GET)TWIHS0_ErrorGet,
    .callbackRegister = (DRV_AT24_PLIB_CALLBACK_REGISTER)TWIHS0_CallbackRegister,
};

DRV_AT24_INIT drvAT24InitData = {
    .i2cPlib = &drvAT24PlibAPI,
    .slaveAddress = 0x57,
    .pageSize = DRV_AT24_EEPROM_PAGE_SIZE,
    .flashSize = DRV_AT24_EEPROM_FLASH_SIZE,
    .numClients = DRV_AT24_CLIENTS_NUMBER_IDX,
    .blockStartAddress = 0x0,
};

sysObjDrvAT24 = DRV_AT24_Initialize(DRV_AT24_INDEX, (SYS_MODULE_INIT *)&drvAT24InitData);

Remarks

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