TI-RTOS Drivers  tidrivers_full_2_20_00_08
I2CCC3200.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_I2CCC3200__include
49 #define ti_drivers_i2c_I2CCC3200__include
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 #include <stdint.h>
56 #include <stdbool.h>
57 
58 #include <ti/drivers/I2C.h>
59 #include <ti/drivers/ports/HwiP.h>
61 #include <ti/drivers/Power.h>
62 
73 /* Add I2CCC3200_STATUS_* macros here */
74 
87 /* Add I2CCC3200_CMD_* macros here */
88 
91 /* I2C function table pointer */
92 extern const I2C_FxnTable I2CCC3200_fxnTable;
93 
100 typedef enum I2CCC3200_Mode {
101  I2CCC3200_IDLE_MODE = 0, /* I2C is not performing a transaction */
102  I2CCC3200_WRITE_MODE, /* I2C is currently performing write operations */
103  I2CCC3200_READ_MODE, /* I2C is currently performing read operations */
104  I2CCC3200_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
106 
132 typedef struct I2CCC3200_HWAttrs {
134  unsigned int baseAddr;
136  unsigned int intNum;
138  unsigned int intPriority;
140 
146 typedef struct I2CCC3200_Object {
147  SemaphoreP_Handle mutex; /* Grants exclusive access to I2C */
148  SemaphoreP_Handle transferComplete; /* Signals I2C transfer completion */
149 
151 
152  I2C_TransferMode transferMode; /* Blocking or Callback mode */
153  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
154 
155  volatile I2CCC3200_Mode mode; /* Stores the I2C state */
156 
157  I2C_Transaction *currentTransaction; /* Pointer to current transaction */
158 
159  uint8_t *writeBufIdx; /* Internal inc. writeBuf index */
160  size_t writeCountIdx; /* Internal dec. writeCounter */
161 
162  uint8_t *readBufIdx; /* Internal inc. readBuf index */
163  size_t readCountIdx; /* Internal dec. readCounter */
164 
165  /* I2C transaction pointers for I2C_MODE_CALLBACK */
166  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
167  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
168 
169  bool isOpen; /* Flag to indicate module is open */
170 
171  Power_NotifyObj notifyObj; /* For notification of wake from LPDS */
172  I2C_BitRate bitRate; /* I2C bus bit rate */
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* ti_drivers_i2c_I2CCC3200__include */
unsigned int intPriority
Definition: I2CCC3200.h:138
uint8_t * writeBufIdx
Definition: I2CCC3200.h:159
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:268
I2C_TransferMode transferMode
Definition: I2CCC3200.h:152
I2C_Transaction * currentTransaction
Definition: I2CCC3200.h:157
I2C_BitRate
I2C bitRate.
Definition: I2C.h:276
SemaphoreP_Handle transferComplete
Definition: I2CCC3200.h:148
I2CCC3200_Mode
I2CCC3200 mode.
Definition: I2CCC3200.h:100
Power manager interface.
I2C_BitRate bitRate
Definition: I2CCC3200.h:172
size_t readCountIdx
Definition: I2CCC3200.h:163
I2CCC3200 Object.
Definition: I2CCC3200.h:146
Definition: I2CCC3200.h:101
Definition: I2CCC3200.h:104
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:250
void * SemaphoreP_Handle
Opaque client reference to an instance of a SemaphoreP.
Definition: SemaphoreP.h:96
Semaphore module for the RTOS Porting Interface.
The definition of an I2C function table that contains the required set of functions to control a spec...
Definition: I2C.h:354
Definition: I2CCC3200.h:102
I2C_Transaction * tailPtr
Definition: I2CCC3200.h:167
const I2C_FxnTable I2CCC3200_fxnTable
SemaphoreP_Handle mutex
Definition: I2CCC3200.h:147
volatile I2CCC3200_Mode mode
Definition: I2CCC3200.h:155
bool isOpen
Definition: I2CCC3200.h:169
unsigned int intNum
Definition: I2CCC3200.h:136
I2CCC3200 Hardware attributes.
Definition: I2CCC3200.h:132
Power notify object structure.
Definition: Power.h:112
struct I2CCC3200_Object I2CCC3200_Object
I2CCC3200 Object.
uint8_t * readBufIdx
Definition: I2CCC3200.h:162
struct I2CCC3200_HWAttrs I2CCC3200_HWAttrs
I2CCC3200 Hardware attributes.
unsigned int baseAddr
Definition: I2CCC3200.h:134
I2C_Transaction * headPtr
Definition: I2CCC3200.h:166
void * HwiP_Handle
Opaque client reference to an instance of a HwiP.
Definition: HwiP.h:66
I2C transaction.
Definition: I2C.h:230
I2C_CallbackFxn transferCallbackFxn
Definition: I2CCC3200.h:153
Definition: I2CCC3200.h:103
Hardware Interrupt module for the RTOS Porting Interface.
size_t writeCountIdx
Definition: I2CCC3200.h:160
HwiP_Handle hwiHandle
Definition: I2CCC3200.h:150
Power_NotifyObj notifyObj
Definition: I2CCC3200.h:171
I2C driver interface.
Copyright 2016, Texas Instruments Incorporated