1.1.1.2.3 DRV_AK4953_Open Function

DRV_HANDLE DRV_AK4953_Open

(

const SYS_MODULE_INDEX drvIndex, const DRV_IO_INTENT ioIntent

)

Summary

Opens the specified AK4953 driver instance and returns a handle to it.

Description

This routine opens the specified AK4953 driver instance and provides a handle that must be provided to all other client-level operations to identify the caller and the instance of the driver. The ioIntent parameter defines how the client interacts with this driver instance.

The DRV_IO_INTENT_BLOCKING and DRV_IO_INTENT_NONBLOCKING ioIntent options are not relevant to this driver. All the data transfer functions of this driver are non blocking.

AK4953 can be opened with DRV_IO_INTENT_WRITE, or DRV_IO_INTENT_READ or DRV_IO_INTENT_WRITEREAD io_intent option. This decides whether the driver is used for headphone output, or microphone input or both modes simultaneously.

Specifying a DRV_IO_INTENT_EXCLUSIVE will cause the driver to provide exclusive access to this client. The driver cannot be opened by any other client.

Preconditions

Function DRV_AK4953_Initialize must have been called before calling this function.

Parameters

ParametersDescription
drvIndexIdentifier for the object instance to be opened
ioIntentZero or more of the values from the enumeration DRV_IO_INTENT "ORed" together to indicate the intended use of the driver. See function description for details.

Returns

If successful, the routine returns a valid open-instance handle (a number identifying both the caller and the module instance).

If an error occurs, the return value is DRV_HANDLE_INVALID. Error can occur

  • if the number of client objects allocated via DRV_AK4953_CLIENTS_NUMBER is insufficient.

  • if the client is trying to open the driver but driver has been opened exclusively by another client.

  • if the driver hardware instance being opened is not initialized or is invalid.

  • if the ioIntent options passed are not relevant to this driver.

Remarks

The handle returned is valid until the DRV_AK4953_Close routine is called. This routine will NEVER block waiting for hardware.If the requested intent flags are not supported, the routine will return DRV_HANDLE_INVALID. This function is thread safe in a RTOS application. It should not be called in an ISR.

Example

DRV_HANDLE handle; handle = DRV_AK4953_Open(DRV_AK4953_INDEX_0, DRV_IO_INTENT_WRITEREAD | DRV_IO_INTENT_EXCLUSIVE); if (DRV_HANDLE_INVALID == handle) {

_\/\/ Unable to open the driver_

_\/\/ May be the driver is not initialized or the initialization_ _\/\/ is not complete._

}

C

DRV_HANDLE DRV_AK4953_Open(const SYS_MODULE_INDEX iDriver, const DRV_IO_INTENT ioIntent);