1.1.3.3.1 DRV_GENERICCODEC_Initialize Function
SYS_MODULE_OBJ DRV_GENERICCODEC_Initialize ( const SYS_MODULE_INDEX drvIndex, const SYS_MODULE_INIT *const init );
Summary
Initializes hardware and data for the instance of the Generic Codec module
Description
This routine initializes the Generic Codec 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.
Preconditions
DRV_I2S_Initialize must be called before calling this function to initialize the data interface of this Codec driver. DRV_I2C_Initialize must be called if SPI driver is used for handling the control interface of this Codec driver.
Parameters
Parameters | Description |
---|---|
drvIndex | Identifier for the driver instance to be initialized |
init | Pointer to the data structure containing any data necessary to initialize the hardware. This pointer may be null if no data is required and default initialization is to be used. |
Returns
If successful, returns a valid handle to a driver instance object. Otherwise, it returns SYS_MODULE_OBJ_INVALID.
Remarks
This routine must be called before any other Generic Codec routine is called.
This routine should only be called once during system initialization unless DRV_GENERICCODEC_Deinitialize is called to deinitialize the driver instance. This routine will NEVER block for hardware access.
Example
DRV_GENERICCODEC_INIT init; SYS_MODULE_OBJ objectHandle; init->inUse = true; init->status = SYS_STATUS_BUSY; init->numClients = 0; init->i2sDriverModuleIndex = genercicodecInit->i2sDriverModuleIndex; init->i2cDriverModuleIndex = genercicodecInit->i2cDriverModuleIndex; init->samplingRate = DRV_GENERICCODEC_AUDIO_SAMPLING_RATE; init->audioDataFormat = DRV_GENERICCODEC_AUDIO_DATA_FORMAT_MACRO; init->isInInterruptContext = false; init->commandCompleteCallback = (DRV_GENERICCODEC_COMMAND_EVENT_HANDLER)0; init->commandContextData = 0; init->mclk_multiplier = DRV_GENERICCODEC_MCLK_SAMPLE_FREQ_MULTPLIER; objectHandle = DRV_GENERICCODEC_Initialize(DRV_GENERICCODEC_0, (SYS_MODULE_INIT*)init); if (SYS_MODULE_OBJ_INVALID == objectHandle) { _// Handle error_ }
C
SYS_MODULE_OBJ DRV_GENERICCODEC_Initialize(const SYS_MODULE_INDEX drvIndex, const
SYS_MODULE_INIT * const init);