14 #include "fsl_i2c_master_driver.h"
18 #define I2C_MASTER_ADAPTER_LOCK_DEFAULT (0)
45 OSA_EnterCritical(kCriticalDisableInt);
52 OSA_MutexCreate(apBusHandle->
pLock);
57 apBusHandle->
pHandle = pBusHandle;
58 OSA_ExitCritical(kCriticalDisableInt);
73 if((apBusHandle == NULL) || (apBusConfig == NULL)){
82 ret = bus_lock(apBusHandle, pBusConfig->
timeout);
85 I2C_DRV_MasterSetBaudRate(pBusHandle->
busInstance, &device);
89 bus_unlock(apBusHandle);
100 if(apBusHandle == NULL){
115 if((apBusHandle == NULL) || (apBusConfig == NULL)){
132 if(apBusHandle == NULL){
149 if(apBusHandle == NULL){
153 ret = bus_unlock(apBusHandle);
165 if(apBusHandle == NULL){
172 I2C_Type* base = g_i2cBase[pBusHandle->
busInstance];
173 I2C_HAL_Enable(base);
175 bus_unlock(apBusHandle);
187 if(apBusHandle == NULL){
193 I2C_Type* base = g_i2cBase[pBusHandle->
busInstance];
194 I2C_HAL_Disable(base);
196 bus_unlock(apBusHandle);
211 i2c_device_t* pDevice = (i2c_device_t*)apDevice;
212 if((apBusHandle == NULL) || (apEndpointHandle == NULL)){
227 const uint8_t cmdBuff[] = {0};
228 ret = I2C_DRV_MasterReceiveDataBlocking(pBusHandle->
busInstance, pDevice, cmdBuff,
sizeof(cmdBuff),
231 bus_unlock(apBusHandle);
232 OSA_EnterCritical(kCriticalDisableInt);
234 pEndpoint->
device = *pDevice;
236 *apEndpointHandle = pEndpoint;
241 OSA_ExitCritical(kCriticalDisableInt);
254 if(apEndpoint == NULL){
258 OSA_MemFree(apEndpoint);
271 if((NULL == apEndpointHandle) || (NULL == pWriteBuffer)){
274 if(buffsize < nByteWrite){
291 1, (
const uint8_t *)pWriteBuffer, nByteWrite, pBusHandle->
busConfig.
timeout);
308 if((NULL == apEndpointHandle) || (NULL == pReadBuffer)){
311 if(buffsize < nByteRead){
326 ret = I2C_DRV_MasterReceiveDataBlocking(pBusHandle->
busInstance, &pEndpoint->
device,
347 if (NULL == apBusHandle->
pLock){
353 if(kStatus_OSA_Success != OSA_MutexLock((mutex_t*)apBusHandle->
pLock, OSA_WAIT_FOREVER)){
357 apBusHandle->
nLock++;
371 if(NULL == apBusHandle->
pLock){
375 if(0 == apBusHandle->
nLock){
379 OSA_MutexUnlock((mutex_t*)apBusHandle->
pLock);
isf_status_t i2c_master_adapter_read(void *apEndpointHandle, int32 offset, void *pReadBuffer, uint32 buffsize, uint32 nByteRead, i2c_readFlags_t aFlags)
This function reads from a i2c device.
isf_status_t i2c_master_adapter_release_lock(busHandle_t *apBusHandle)
This function releases exclusive bus access.
isf_status_t i2c_master_adapter_init(comm_Id_t aBusId, busHandle_t *apBusHandle)
This function initializes a i2c bus.
This structure defines the data bus handle.
isf_status_t i2c_master_adapter_configure(busHandle_t *apBusHandle, void *apBusConfig)
This function reconfigures an already initialized bus.
isf_status_t i2c_master_adapter_acquire_lock(busHandle_t *apBusHandle, isf_duration_t aTimeout)
This function locks the bus for exclusive access.
uint32 comm_Id_t
This type is for a numeric channel identifier- index into an array of channels in the system...
i2c_Master_BusConfig_t busConfig
This structure defines a device endpoint encapsulation for i2c handler.
isf_status_t i2c_master_adapter_start(busHandle_t *apBusHandle)
This function starts a bus.
#define I2C_MASTER_ADAPTER_LOCK_DEFAULT
isf_protocol_adapter.h defines the general interface definition for the protocol adapter.
isf_status_t i2c_master_adapter_release_endpoint(i2c_Endpoint_t *apEndpoint)
This function closes a particular endpoint.
The isf_util.h file contains the utility method declarations and macros.
isf_i2c_master_adapter.h defines the API definitions and types for the i2c master protocol adapter...
This structure is a declaration of a BusHandle type.
comm_Flags_t i2c_readFlags_t
isf_status_t i2c_master_adapter_write(void *apEndpointHandle, int32 offset, void *pWriteBuffer, uint32 buffsize, uint32 nByteWrite, i2c_writeFlags_t aFlags)
This function writes to a i2c device.
isf_status_t i2c_master_adapter_stop(busHandle_t *apBusHandle)
This function stops the given i2c bus.
comm_State_t i2c_master_adapter_get_state(busHandle_t *apBusHandle)
This function returns the current bus state.
uint32 isf_duration_t
ISF time duration in microseconds.
i2c_Master_busHandle_t i2c_master_busHandle[]
Main ISF header file. Contains code common to all ISF components.
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.
int32 isf_status_t
ISF return status type.
enum comm_State_vals comm_State_t
This enum holds an enumerated value describing the state of a channel.
mutex_t i2c_Master_mutexHandler[]
#define INVALID_OFFSET
This macro defines the invalid offset for the read and write functions.
comm_Flags_t i2c_writeFlags_t
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...
isf_status_t i2c_master_adapter_get_config(busHandle_t *apBusHandle, void *apBusConfig)
This function returns the current bus configuration.
i2c_master_state_t master