1.1.5.1.1 DRV_I2S_Initialize Function

SYS_MODULE_OBJ DRV_I2S_Initialize

(

const SYS_MODULE_INDEX index, const SYS_MODULE_INIT * const init

)

Summary

Initializes the I2S instance for the specified driver index.

Description

This routine initializes the I2S driver instance for the specified driver index, making it ready for clients to open and use it. The initialization data is specified by the init parameter. The initialization may fail if the number of driver objects allocated are insufficient or if the specified driver instance is already initialized. The driver instance index is independent of the I2S module ID. For example, driver instance 0 can be assigned to I2S2.

Preconditions

None.

Parameters

ParametersDescription
indexIdentifier 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.

Remarks

This routine must be called before any other I2S routine is called.

This routine should only be called once during system initialization. This routine will NEVER block for hardware access.

Example

_// The following code snippet shows an example I2S driver initialization._

SYS_MODULE_OBJ objectHandle;

I2S_PLIB_API drvUsart0PlibAPI = {

{ .readCallbackRegister = I2S1_ReadCallbackRegister,

.read = I2S1_Read,

.readIsBusy = I2S1_ReadIsBusy,

.readCountGet = I2S1_ReadCountGet, .writeCallbackRegister = I2S1_WriteCallbackRegister,

.write = I2S1_Write,

.writeIsBusy = I2S1_WriteIsBusy,

.writeCountGet = I2S1_WriteCountGet,

.errorGet = I2S1_ErrorGet

}

};

DRV_I2S_INIT drvUsart0InitData =

{

.i2sPlib = &drvUsart0PlibAPI,

.interruptI2S = I2S1_IRQn,

.queueSizeTransmit = DRV_I2S_XMIT_QUEUE_SIZE_IDX0,

.queueSizeReceive = DRV_I2S_RCV_QUEUE_SIZE_IDX0,

.dmaChannelTransmit = SYS_DMA_CHANNEL_NONE,

.dmaChannelReceive = SYS_DMA_CHANNEL_NONE,

.i2sTransmitAddress = I2S1_TRANSMIT_ADDRESS,

.i2sReceiveAddress = I2S1_RECEIVE_ADDRESS,

.interruptDMA = XDMAC_IRQn

}; objectHandle = DRV_I2S_Initialize(DRV_I2S_INDEX_1, (SYS_MODULE_INIT*)&drvUsart0InitData); if (SYS_MODULE_OBJ_INVALID == objectHandle) {

_// Handle error_

}

C

SYS_MODULE_OBJ DRV_I2S_Initialize(const SYS_MODULE_INDEX index, const SYS_MODULE_INIT * const init);