TI-RTOS Drivers  tidrivers_full_2_20_00_08
I2CEUSCIB.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
76 #ifndef ti_drivers_i2c_I2CEUSCIB__include
77 #define ti_drivers_i2c_I2CEUSCIB__include
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 #include <stdint.h>
84 #include <stdbool.h>
85 #include <ti/drivers/I2C.h>
86 
87 #include <ti/sysbios/knl/Semaphore.h>
88 
99 /* Add I2CEUSCIB_STATUS_* macros here */
100 
113 /* Add I2CEUSCIB_CMD_* macros here */
114 
117 /* I2C function table pointer */
118 extern const I2C_FxnTable I2CEUSCIB_fxnTable;
119 
126 typedef enum I2CEUSCIB_Mode {
127  I2CEUSCIB_IDLE_MODE = 0, /* I2C is not performing a transaction */
128  I2CEUSCIB_WRITE_MODE, /* I2C is currently performing write operations */
129  I2CEUSCIB_READ_MODE, /* I2C is currently performing read operations */
130  I2CEUSCIB_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
132 
155 typedef struct I2CEUSCIB_HWAttrs {
157  uint32_t baseAddr;
159  uint8_t clockSource;
161 
167 typedef struct I2CEUSCIB_Object {
168  bool isOpen; /* Indicates if the I2C is open */
169 
170  Semaphore_Struct mutex; /* Grants exclusive access to I2C */
171  Semaphore_Struct transferComplete; /* Signal I2C transfer complete */
172 
173  I2C_TransferMode transferMode; /* Blocking or Callback mode */
174  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
175 
176  volatile I2CEUSCIB_Mode mode; /* Stores the I2C state */
177 
178  I2C_Transaction *currentTransaction; /* Ptr to current I2C transaction */
179 
180  uint8_t *writeBufIdx; /* Internal writeBuf index (inc.) */
181  size_t writeCountIdx; /* Internal writeCounter (dec.) */
182 
183  uint8_t *readBufIdx; /* Internal readBuf index (inc.) */
184  size_t readCountIdx; /* Internal readCounter (dec.) */
185 
186  /* I2C transaction pointers for I2C_MODE_CALLBACK */
187  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
188  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
189 
190  uint32_t bitRate; /* Data transfer rate */
191 
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /* ti_drivers_i2c_I2CEUSCIB__include */
uint32_t baseAddr
Definition: I2CEUSCIB.h:157
I2CEUSCIB Hardware attributes.
Definition: I2CEUSCIB.h:155
Semaphore_Struct transferComplete
Definition: I2CEUSCIB.h:171
uint8_t * writeBufIdx
Definition: I2CEUSCIB.h:180
I2C_CallbackFxn transferCallbackFxn
Definition: I2CEUSCIB.h:174
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:268
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:250
struct I2CEUSCIB_HWAttrs I2CEUSCIB_HWAttrs
I2CEUSCIB Hardware attributes.
The definition of an I2C function table that contains the required set of functions to control a spec...
Definition: I2C.h:354
I2CEUSCIB_Mode
I2CEUSCIB mode.
Definition: I2CEUSCIB.h:126
Semaphore_Struct mutex
Definition: I2CEUSCIB.h:170
struct I2CEUSCIB_Object I2CEUSCIB_Object
I2CEUSCIB Object.
I2CEUSCIB Object.
Definition: I2CEUSCIB.h:167
uint8_t * readBufIdx
Definition: I2CEUSCIB.h:183
I2C_Transaction * headPtr
Definition: I2CEUSCIB.h:187
uint32_t bitRate
Definition: I2CEUSCIB.h:190
Definition: I2CEUSCIB.h:127
Definition: I2CEUSCIB.h:128
I2C_TransferMode transferMode
Definition: I2CEUSCIB.h:173
size_t writeCountIdx
Definition: I2CEUSCIB.h:181
uint8_t clockSource
Definition: I2CEUSCIB.h:159
const I2C_FxnTable I2CEUSCIB_fxnTable
I2C_Transaction * tailPtr
Definition: I2CEUSCIB.h:188
I2C transaction.
Definition: I2C.h:230
volatile I2CEUSCIB_Mode mode
Definition: I2CEUSCIB.h:176
I2C_Transaction * currentTransaction
Definition: I2CEUSCIB.h:178
Definition: I2CEUSCIB.h:129
Definition: I2CEUSCIB.h:130
I2C driver interface.
bool isOpen
Definition: I2CEUSCIB.h:168
size_t readCountIdx
Definition: I2CEUSCIB.h:184
Copyright 2016, Texas Instruments Incorporated