TI-RTOS Drivers  tidrivers_full_2_20_00_08
I2CTiva.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  */
48 #ifndef ti_drivers_i2c_I2CTiva__include
49 #define ti_drivers_i2c_I2CTiva__include
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 #include <stdint.h>
56 #include <stdbool.h>
57 #include <ti/drivers/I2C.h>
58 
59 #include <ti/sysbios/knl/Semaphore.h>
60 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
61 #include <ti/sysbios/family/arm/m3/Hwi.h>
62 
73 /* Add I2CTiva_STATUS_* macros here */
74 
87 /* Add I2CTiva_CMD_* macros here */
88 
91 /* I2C function table pointer */
92 extern const I2C_FxnTable I2CTiva_fxnTable;
93 
100 typedef enum I2CTiva_Mode {
101  I2CTiva_IDLE_MODE = 0, /* I2C is not performing a transaction */
102  I2CTiva_WRITE_MODE, /* I2C is currently performing write operations */
103  I2CTiva_READ_MODE, /* I2C is currently performing read operations */
104  I2CTiva_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
105 } I2CTiva_Mode;
106 
136 typedef struct I2CTiva_HWAttrs {
138  unsigned int baseAddr;
140  unsigned int intNum;
142  unsigned int intPriority;
144 
150 typedef struct I2CTiva_Object {
151  Semaphore_Struct mutex; /* Grants exclusive access to I2C */
152  Semaphore_Struct transferComplete; /* Signal I2C transfer complete */
153 
154  I2C_TransferMode transferMode; /* Blocking or Callback mode */
155  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
156 
157  ti_sysbios_family_arm_m3_Hwi_Struct hwi; /* Hwi object handle */
158 
159  volatile I2CTiva_Mode mode; /* Stores the I2C state */
160 
161  I2C_Transaction *currentTransaction; /* Pointer to current I2C transaction */
162 
163  uint8_t *writeBufIdx; /* Internal writeBuf index (inc) */
164  size_t writeCountIdx; /* Internal writeCounter (dec) */
165 
166  uint8_t *readBufIdx; /* Internal readBuf index (inc) */
167  size_t readCountIdx; /* Internal readCounter (dec) */
168 
169  /* I2C transaction pointers for I2C_MODE_CALLBACK */
170  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
171  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
172 
173  bool bitRate; /* Bit rate (false=slow, true=fast) */
174  bool isOpen; /* flag to indicate module is open */
176 
177 /* Do not interfere with the app if they include the family Hwi module */
178 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* ti_drivers_i2c_I2CTiva__include */
bool isOpen
Definition: I2CTiva.h:174
Definition: I2CTiva.h:103
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:268
struct I2CTiva_HWAttrs I2CTiva_HWAttrs
I2CTiva Hardware attributes.
Semaphore_Struct transferComplete
Definition: I2CTiva.h:152
I2CTiva_Mode
I2CTiva mode.
Definition: I2CTiva.h:100
unsigned int intNum
Definition: I2CTiva.h:140
I2C_CallbackFxn transferCallbackFxn
Definition: I2CTiva.h:155
I2C_Transaction * currentTransaction
Definition: I2CTiva.h:161
const I2C_FxnTable I2CTiva_fxnTable
I2CTiva Object.
Definition: I2CTiva.h:150
I2C_Transaction * headPtr
Definition: I2CTiva.h:170
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:250
I2C_Transaction * tailPtr
Definition: I2CTiva.h:171
The definition of an I2C function table that contains the required set of functions to control a spec...
Definition: I2C.h:354
Definition: I2CTiva.h:104
I2C_TransferMode transferMode
Definition: I2CTiva.h:154
I2CTiva Hardware attributes.
Definition: I2CTiva.h:136
unsigned int baseAddr
Definition: I2CTiva.h:138
struct I2CTiva_Object I2CTiva_Object
I2CTiva Object.
bool bitRate
Definition: I2CTiva.h:173
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: I2CTiva.h:157
size_t writeCountIdx
Definition: I2CTiva.h:164
uint8_t * writeBufIdx
Definition: I2CTiva.h:163
Definition: I2CTiva.h:101
size_t readCountIdx
Definition: I2CTiva.h:167
I2C transaction.
Definition: I2C.h:230
Definition: I2CTiva.h:102
volatile I2CTiva_Mode mode
Definition: I2CTiva.h:159
unsigned int intPriority
Definition: I2CTiva.h:142
I2C driver interface.
uint8_t * readBufIdx
Definition: I2CTiva.h:166
Semaphore_Struct mutex
Definition: I2CTiva.h:151
Copyright 2016, Texas Instruments Incorporated