| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Typedefs | Enumerations | Functions
isf_i2c_master_adapter.h File Reference

isf_i2c_master_adapter.h defines the API definitions and types for the i2c master protocol adapter. More...

`#include "isf_i2c_master_types.h"`
`#include "fsl_i2c_master_driver.h"`
`#include "fsl_i2c_hal.h"`
`#include "isf_comm.h"`
`#include "isf_protocol_adapter.h"`
Include dependency graph for isf_i2c_master_adapter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | i2c_deviceEndpoint_struct
| This structure defines a device endpoint encapsulation for i2c handler. More...

## Typedefs
typedef struct i2c_deviceEndpoint_struct | i2c_Endpoint_t
| This structure defines a device endpoint encapsulation for i2c handler. More...
typedef comm_Flags_t | i2c_writeFlags_t
typedef comm_Flags_t | i2c_readFlags_t

## Enumerations
enum | i2c_comm_flag { I2C_SEND_NO_STOP = 1 <<0, I2C_SEND_STOP = 1 <<1 }

## Functions
isf_status_t | i2c_master_adapter_init (comm_Id_t aBusId, busHandle_t *apBusHandle)
| This function initializes a i2c bus. More...
isf_status_t | i2c_master_adapter_configure (busHandle_t *apBusHandle, void *apBusConfig)
| This function reconfigures an already initialized bus. More...
comm_State_t | i2c_master_adapter_get_state (busHandle_t *apBusHandle)
| This function returns the current bus state. More...
isf_status_t | i2c_master_adapter_get_config (busHandle_t *apBusHandle, void *apBusConfig)
| This function returns the current bus configuration. More...
isf_status_t | i2c_master_adapter_acquire_lock (busHandle_t *apBusHandle, isf_duration_t aTimeout)
| This function locks the bus for exclusive access. More...
isf_status_t | i2c_master_adapter_release_lock (busHandle_t *apBusHandle)
| This function releases exclusive bus access. More...
isf_status_t | i2c_master_adapter_start (busHandle_t *apBusHandle)
| This function starts a bus. More...
isf_status_t | i2c_master_adapter_stop (busHandle_t *apBusHandle)
| This function stops the given i2c bus. More...
isf_status_t | i2c_master_adapter_get_endpoint (busHandle_t *apBusHandle, void *apDevice, void **apEndpointHandle)
| This function creates a endpoint for a device at a specified bus address. More...
isf_status_t | i2c_master_adapter_release_endpoint (i2c_Endpoint_t *apEndpoint)
| This function closes a particular endpoint. More...
isf_status_t | i2c_master_adapter_write (void *apEndpointHandle, int32 offset, void *apWriteBuffer, uint32 aBuffsize, uint32 aNbyteWrite, i2c_writeFlags_t aFlags)
| This function writes to a i2c device. More...
isf_status_t | i2c_master_adapter_read (void *apEndpointHandle, int32 offset, void *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead, i2c_readFlags_t aFlags)
| This function reads from a i2c device. More...

## Detailed Description

isf_i2c_master_adapter.h defines the API definitions and types for the i2c master protocol adapter.

File: isf_i2c_master_adapter.h

Copyright (c) 2014, Freescale Semiconductor, Inc.

Definition in file isf_i2c_master_adapter.h.

## Typedef Documentation

typedef struct i2c_deviceEndpoint_struct i2c_Endpoint_t

This structure defines a device endpoint encapsulation for i2c handler.

typedef comm_Flags_t i2c_readFlags_t

Definition at line 33 of file isf_i2c_master_adapter.h.

typedef comm_Flags_t i2c_writeFlags_t

Definition at line 32 of file isf_i2c_master_adapter.h.

## Enumeration Type Documentation

enum i2c_comm_flag

Type specifying generate the stop condition

Enumerator
I2C_SEND_NO_STOP | Do not send stop signal.
I2C_SEND_STOP | Send stop signal.

Definition at line 26 of file isf_i2c_master_adapter.h.

## Function Documentation

isf_status_t i2c_master_adapter_acquire_lock | ( | busHandle_t * | apBusHandle,
|  | isf_duration_t | aTimeout
| ) |  |

This function locks the bus for exclusive access.

i2c_master_adapter_acquire_lock() serializes multi-client access. While holding the bus lock, no other clients may perform any bus operations. Therefore, it is important to release the lock with i2c_master_adapter_release_lock() as soon as practical.

Parameters

  [in] | apBusHandle | The handle of the bus to be started.
  [in] | aTimeout | The time to wait for the lock before returning without the lock. The timeout parameter may be set to zero to wait for calls that fail to return without acquiring the lock, or wait as long as necessary for the lock to be acquired.

Returns
  dm_channel_acquire_lock() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the bus lock is acquired.
  COMM_ERROR_INIT | is returned when the bus handle refers to a non-initialized channel.
  COMM_ERROR_TIME_OUT | is returned when the request could not be fulfilled in the specified timeout period.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handle is created when the i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  None

Definition at line 145 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busConfig, COMM_ERROR_NULL_PTR, ISF_SUCCESS, busHandle_struct::pHandle, and i2c_Master_BusConfig_struct::timeout.

isf_status_t i2c_master_adapter_configure | ( | busHandle_t * | apBusHandle,
|  | void * | apBusConfig
| ) |  |

This function reconfigures an already initialized bus.

A bus may be reconfigured after initialization. Calls to i2c_master_adapter_configure() after initialization will override any previous configuration values and must be made while the bus state is COMM_STATE_STOPPED. The typical usage involves retrieving the current configuration using i2c_master_adapter_get_config(), making modifications to the returned configuration, and then calling i2c_master_adapter_configure() with the updated configuration. The bus is implicitly locked during the configuration.

Parameters

  [in] | apBusHandle | The handle of the bus to be configured.
  [in] | apBusConfig | The configuration value for the bus to be configured.

Returns
  i2c_master_adapter_configure() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the bus was reconfigured successfully.
  COMM_ERROR_STOP | is returned when the bus was not STOPPED.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.
  COMM_ERROR_TIME_OUT | is returned when the request could not be fulfilled in the specified timeout period.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handler is created when the i2c_master_adapter_init() function call is successfully returned.

Reentrant: Yes

Link Libraries:
  None

Definition at line 84 of file isf_i2c_master_adapter.c.

References I2CDeviceInfo::baudRate_kbps, i2c_Master_BusHandle_struct::busConfig, i2c_Master_BusHandle_struct::busState, COMM_ERROR_NULL_PTR, COMM_ERROR_STOP, COMM_STATE_INIT, COMM_STATE_STOPPED, i2c_Master_BusConfig_struct::defaultSpeed, i2c_master_configure_bus(), ISF_SUCCESS, I2CMasterState::lastBaudRate_kbps, i2c_Master_BusHandle_struct::master, busHandle_struct::pHandle, and i2c_Master_BusConfig_struct::timeout.

Here is the call graph for this function:

isf_status_t i2c_master_adapter_get_config | ( | busHandle_t * | apBusHandle,
|  | void * | apBusConfig
| ) |  |

This function returns the current bus configuration.

A bus may be queried for the current configuration.

Parameters

  [in] | apBusHandle | The handle of the bus to be queried.
  [out] | apBusConfig | The address of a bus configuration to be filled.

Returns
  i2c_master_adapter_get_config() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the bus configuration is retrieved successfully.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.
  COMM_ERROR_INIT | is returned when the bus handle refers to a non-initialized bus.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handle is created when the i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  None

Definition at line 127 of file isf_i2c_master_adapter.c.

References COMM_ERROR_NULL_PTR, ISF_SUCCESS, and busHandle_struct::pHandle.

isf_status_t i2c_master_adapter_get_endpoint | ( | busHandle_t * | apBusHandle,
|  | void * | apDevice,
|  | void ** | apEndpointHandle
| ) |  |

This function creates a endpoint for a device at a specified bus address.

The i2c_master_adapter_get_endpoint() function may be used to get a handle to a device at a known bus address.

Parameters

  [in] | apBusHandle | The handle of the bus to be opened.
  [in] | apDevice | The known information of the device to be opened.
  [out] | apEndpointHandle | The address of a apEndpointHandle to be filled.

Returns
  i2c_master_adapter_get_endpoint() returns a value of type isf_status_t indicating the success or failure of the function call.

Return values

  ISF_SUCCESS | is returned when the device is located and a valid handle is returned.
  COMM_ERROR_NOEXIST | is returned when a device does not exist at the specified bus.
  COMM_ERROR_INIT | is returned when the channel handle refers to a non-initialized channel.
  COMM_ERROR_STOP | is returned when the channel has not been started.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.
  COMM_ERROR_TIME_OUT | is returned when the request could not be fulfilled in the specified timeout period.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handle is created when the i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  isf_core.lib

Definition at line 220 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busConfig, i2c_Master_BusHandle_struct::busState, COMM_ERROR_NOEXIST, COMM_ERROR_NULL_PTR, COMM_ERROR_STOP, COMM_STATE_OK, i2c_deviceEndpoint_struct::device, i2c_master_transfer(), ISF_SUCCESS, kI2CRead, i2c_Master_BusHandle_struct::master, i2c_deviceEndpoint_struct::pBusHandle, busHandle_struct::pHandle, and i2c_Master_BusConfig_struct::timeout.

Here is the call graph for this function:

comm_State_t i2c_master_adapter_get_state | ( | busHandle_t * | apBusHandle | ) |

This function returns the current bus state.

A bus may be queried for its current state.

Parameters

  [in] | apBusHandle | The handle of the bus to be queried.

Returns
  i2c_master_adapter_get_state() returns a value of type comm_State_t indicating the current state of the bus.

Return values

  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handle is created when i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  None.

Definition at line 113 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busState, COMM_ERROR_NULL_PTR, and busHandle_struct::pHandle.

isf_status_t i2c_master_adapter_init | ( | comm_Id_t | aBusId,
|  | busHandle_t * | apBusHandle
| ) |  |

This function initializes a i2c bus.

A bus must be initialized prior to use. Initialization creates the bus and initializes the data structures required to manage the bus.

Parameters

  [in] | aBusId | The ID of the bus to initialize. This is an index into the array of known i2c buses that can be used.
  [out] | apBusHandle | The handle to the bus to be initialized.

Returns
  i2c_master_adapter_init() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the bus is initialized successfully and the apBusHandle structure reference has been populated with initialized i2c bus data.
  COMM_ERROR_NOEXIST | is returned when the supplied bus identifier does not exist.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.
  COMM_ERROR_INIT | is returned when the bus could not be initialized.

Constraints:
  None

Reentrant: Yes

Link Libraries:
  None

Definition at line 43 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busState, COMM_ERROR_INIT, COMM_ERROR_NOEXIST, COMM_STATE_INIT, COMM_STATE_NO_INIT, gSys_NumI2cBuses, I2C_MASTER_ADAPTER_LOCK_DEFAULT, i2c_master_init(), i2c_Master_mutexHandler, ISF_SUCCESS, i2c_Master_BusHandle_struct::master, busHandle_struct::nLock, busHandle_struct::pHandle, and busHandle_struct::pLock.

Here is the call graph for this function:

isf_status_t i2c_master_adapter_read | ( | void * | apEndpointHandle,
|  | int32 | offset,
|  | void * | apReadBuffer,
|  | uint32 | aBuffsize,
|  | uint32 | aNbyteRead,
|  | i2c_readFlags_t | aFlags
| ) |  |

This function reads from a i2c device.

i2c_master_adapter_read() reads data from the specified device. The supplied command is sent to the device triggering the device to return some data. Any data returned by the device is read and placed in the provided read buffer. The device is implicitly locked during the read.

Parameters

  [in] | apEndpointHandle | The handle to the device endpoint for.
  [in] | offset | The read offset/sub address from which the data to be read.
  [in] | apReadBuffer | The buffer address where any returned data is placed.
  [in] | aBuffsize | The size of the buffer passed.
  [in] | aNbyteRead | The number of bytes to read from the device.
  [in] | aFlags | The read flag that change the mode of read of operation.

Returns
  i2c_master_adapter_read() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when data from the device was read successfully.
  COMM_ERROR_BUF_SIZE | is returned when the provided buffer is too small to hold all the data or the number of bytes read is zero.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.
  COMM_ERROR_TIME_OUT | is returned when the request could not be fulfilled in the specified timeout period.
  COMM_ERROR_LOCK | is returned when a lock could not be acquired properly.

Constraints:
  The following constraints must be observed when using this function:
  - apEndpointHandle must be valid. A valid device endpoint handle is created when the i2c_master_adapter_get_endpoint() function returns successfully.

Reentrant: Yes

Link Libraries:
  None

Definition at line 312 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busConfig, i2c_Master_BusHandle_struct::busState, COMM_ERROR_BUF_SIZE, COMM_ERROR_INIT, COMM_ERROR_NULL_PTR, COMM_STATE_OK, i2c_deviceEndpoint_struct::device, i2c_master_transfer(), INVALID_OFFSET, ISF_SUCCESS, kI2CRead, i2c_Master_BusHandle_struct::master, i2c_deviceEndpoint_struct::pBusHandle, busHandle_struct::pHandle, and i2c_Master_BusConfig_struct::timeout.

Here is the call graph for this function:

isf_status_t i2c_master_adapter_release_endpoint | ( | i2c_Endpoint_t * | apEndpoint | ) |

This function closes a particular endpoint.

The i2c_master_adapter_release_endpoint() function is used when no further communication with the device is needed. A closed device should not be passed to i2c_master_adapter_write() or i2c_master_adapter_write().

Parameters

  [in] | apEndpoint | The address of the end point where the endpoint is established.

Returns
  i2c_master_adapter_release_endpoint() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the device changes to closed.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.

Constraints:
  The following constraints must be observed when using this function:
  - pBusHandle must be valid. A valid i2c bus handle is created when the i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  None

Definition at line 262 of file isf_i2c_master_adapter.c.

References COMM_ERROR_NULL_PTR, and ISF_SUCCESS.

isf_status_t i2c_master_adapter_release_lock | ( | busHandle_t * | apBusHandle | ) |

This function releases exclusive bus access.

i2c_master_adapter_release_lock() is used to relinquish exclusive access on a particular bus. It is the inverse of i2c_master_adapter_acquire_lock().

Parameters

  [in] | apBusHandle | The handle of the bus to unlock.

Returns
  i2c_master_adapter_release_lock() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the bus released successfully.
  COMM_ERROR_INIT | is returned when the bus handle refers to a non-initialized channel.
  COMM_ERROR_LOCK | is returned when no lock was held on the specified bus.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handle is created when the i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  None

Definition at line 162 of file isf_i2c_master_adapter.c.

References COMM_ERROR_NULL_PTR, and ISF_SUCCESS.

isf_status_t i2c_master_adapter_start | ( | busHandle_t * | apBusHandle | ) |

This function starts a bus.

i2c_master_adapter_start() enables communications with an initialized bus.

Parameters

  [in] | apBusHandle | The handle of the bus to be started.

Returns
  i2c_master_adapter_start() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the bus was started successfully.
  COMM_ERROR_INIT | is returned when the bus handle refers to a non-initialized channel.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.
  COMM_ERROR_TIME_OUT | is returned when the request could not be fulfilled in the specified timeout period.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handle is created when the i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  None

Definition at line 178 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busConfig, i2c_Master_BusHandle_struct::busState, COMM_ERROR_NULL_PTR, COMM_STATE_OK, i2c_hal_enable(), I2CMasterState::instance, i2c_Master_BusHandle_struct::master, busHandle_struct::pHandle, and i2c_Master_BusConfig_struct::timeout.

Here is the call graph for this function:

isf_status_t i2c_master_adapter_stop | ( | busHandle_t * | apBusHandle | ) |

This function stops the given i2c bus.

i2c_master_adapter_stop() disables an initialized bus and stops communications with the channel.

Parameters

  [in] | apBusHandle | The handle of the bus to be stopped.

Returns
  i2c_master_adapter_stop() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the bus is successfully stopped.
  COMM_ERROR_INIT | is returned when the bus handle refers to a non-initialized channel.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.

Constraints:
  The following constraints must be observed when using this function:
  - apBusHandle must be valid. A valid i2c bus handle is created when the i2c_master_adapter_init() function call returns successfully.

Reentrant: Yes

Link Libraries:
  None

Definition at line 199 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busConfig, i2c_Master_BusHandle_struct::busState, COMM_ERROR_NULL_PTR, COMM_STATE_STOPPED, i2c_hal_disable(), I2CMasterState::instance, i2c_Master_BusHandle_struct::master, busHandle_struct::pHandle, and i2c_Master_BusConfig_struct::timeout.

Here is the call graph for this function:

isf_status_t i2c_master_adapter_write | ( | void * | apEndpointHandle,
|  | int32 | offset,
|  | void * | apWriteBuffer,
|  | uint32 | aBuffsize,
|  | uint32 | aNbyteWrite,
|  | i2c_writeFlags_t | aFlags
| ) |  |

This function writes to a i2c device.

i2c_master_adapter_write () writes data to the specified device. The device is implicitly locked during the write.

Parameters

  [in] | apEndpointHandle | The handle to the device endpoint to which to write is performed.
  [in] | offset | The read offset/sub address from which the data to be write.
  [in] | apWriteBuffer | The buffer address where write data is placed.
  [in] | aBuffsize | The size of the buffer passed.
  [in] | aNbyteWrite | The number of bytes to write to the device.
  [in] | aFlags | The write flag that change the mode of read of operation.

Returns
  i2c_master_adapter_write() returns a value of type isf_status_t indicating whether the operation was successful or unsuccessful.

Return values

  ISF_SUCCESS | is returned when the device was written successfully.
  COMM_ERROR_STOP | is returned when the write is invoked on a stopped channel.
  COMM_ERROR_NULL_PTR | is returned when a NULL pointer argument was passed into the function.
  COMM_ERROR_TIME_OUT | is returned when the request could not be fulfilled in the specified timeout period.
  COMM_ERROR_LOCK | is returned when a lock could not be acquired properly.

Constraints:
  The following constraints must be observed when using this function:
  - apEndpointHandle must be valid. A valid device endpoint handle is created when the i2c_master_adapter_get_endpoint() function returns successfully.

Reentrant: Yes

Link Libraries:
  isf_core.lib

Definition at line 277 of file isf_i2c_master_adapter.c.

References i2c_Master_BusHandle_struct::busConfig, i2c_Master_BusHandle_struct::busState, COMM_ERROR_BUF_SIZE, COMM_ERROR_INIT, COMM_ERROR_NULL_PTR, COMM_STATE_OK, i2c_deviceEndpoint_struct::device, i2c_master_transfer(), INVALID_OFFSET, ISF_SUCCESS, kI2CWrite, i2c_Master_BusHandle_struct::master, i2c_deviceEndpoint_struct::pBusHandle, busHandle_struct::pHandle, and i2c_Master_BusConfig_struct::timeout.

Here is the call graph for this function:
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.