1.1.9.4.3 DRV_SPI_Open Function
1.1.9.4.3 C
DRV_HANDLE DRV_SPI_Open
(
const SYS_MODULE_INDEX index,
const DRV_IO_INTENT ioIntent
)1.1.9.4.3 Summary
Opens the specified SPI driver instance and returns a handle to it.
1.1.9.4.3 Description
This routine opens the specified SPI 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.
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.
1.1.9.4.3 Precondition
Function DRV_SPI_Initialize must have been called before calling this function.
1.1.9.4.3 Parameters
| Parameters | Description |
|---|---|
| index | Identifier for the object instance to be opened |
| intent | Zero 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 |
1.1.9.4.3 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_SPI_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 peripheral instance being opened is not initialized or is invalid
- if the client is trying to open the driver exclusively, but has already been opened in a non exclusive mode by another client
- if the driver is not ready to be opened, typically when the initialize routine has not completed execution
1.1.9.4.3 Example
DRV_HANDLE handle;
handle = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_EXCLUSIVE);
if (handle == DRV_HANDLE_INVALID)
{
// Unable to open the driver
// May be the driver is not initialized or the initialization
// is not complete.
}1.1.9.4.3 Remarks
- The handle returned is valid until the DRV_SPI_Close routine is called
- This routine will never block waiting for hardware
