I2CCC32XX.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_I2CCC32XX__include
49 #define ti_drivers_i2c_I2CCC32XX__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/dpl/HwiP.h>
60 #include <ti/drivers/dpl/SemaphoreP.h>
61 #include <ti/drivers/Power.h>
62 
63 /* macros defining possible I2C signal pin mux options */
64 #define I2CCC32XX_PIN_01_I2C_SCL 0x100
65 #define I2CCC32XX_PIN_02_I2C_SDA 0x101
66 #define I2CCC32XX_PIN_03_I2C_SCL 0x502
67 #define I2CCC32XX_PIN_04_I2C_SDA 0x503
68 #define I2CCC32XX_PIN_05_I2C_SCL 0x504
69 #define I2CCC32XX_PIN_06_I2C_SDA 0x505
70 #define I2CCC32XX_PIN_16_I2C_SCL 0x90F
71 #define I2CCC32XX_PIN_17_I2C_SDA 0x910
83 /* Add I2CCC32XX_STATUS_* macros here */
84 
97 /* Add I2CCC32XX_CMD_* macros here */
98 
101 /* I2C function table pointer */
102 extern const I2C_FxnTable I2CCC32XX_fxnTable;
103 
110 typedef enum I2CCC32XX_Mode {
112  I2CCC32XX_IDLE_MODE = 0,
114  I2CCC32XX_WRITE_MODE,
116  I2CCC32XX_READ_MODE,
118  I2CCC32XX_ERROR = 0xFF
119 } I2CCC32XX_Mode;
158 typedef struct I2CCC32XX_HWAttrsV1 {
160  unsigned int baseAddr;
162  unsigned int intNum;
164  unsigned int intPriority;
166  uint16_t clkPin;
168  uint16_t dataPin;
170 
176 typedef struct I2CCC32XX_Object {
177  SemaphoreP_Handle mutex; /* Grants exclusive access to I2C */
178  SemaphoreP_Handle transferComplete; /* Signals I2C transfer completion */
179 
180  HwiP_Handle hwiHandle;
181 
182  I2C_TransferMode transferMode; /* Blocking or Callback mode */
183  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
184 
185  volatile I2CCC32XX_Mode mode; /* Stores the I2C state */
186 
187  I2C_Transaction *currentTransaction; /* Pointer to current transaction */
188 
189  uint8_t *writeBufIdx; /* Internal inc. writeBuf index */
190  size_t writeCountIdx; /* Internal dec. writeCounter */
191 
192  uint8_t *readBufIdx; /* Internal inc. readBuf index */
193  size_t readCountIdx; /* Internal dec. readCounter */
194 
195  /* I2C transaction pointers for I2C_MODE_CALLBACK */
196  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
197  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
198 
199  bool isOpen; /* Flag to indicate module is open */
200 
201  Power_NotifyObj notifyObj; /* For notification of wake from LPDS */
202  I2C_BitRate bitRate; /* I2C bus bit rate */
203 } I2CCC32XX_Object;
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* ti_drivers_i2c_I2CCC32XX__include */
I2C transaction.
Definition: I2C.h:464
unsigned int intNum
Definition: I2CCC32XX.h:162
uint16_t dataPin
Definition: I2CCC32XX.h:168
Power manager interface.
unsigned int intPriority
Definition: I2CCC32XX.h:164
Power notify object structure.
Definition: Power.h:113
enum I2C_TransferMode_ I2C_TransferMode
I2C transfer mode.
struct I2CCC32XX_HWAttrsV1 I2CCC32XX_HWAttrsV1
I2CCC32XX Hardware attributes.
The definition of an I2C function table that contains the required set of functions to control a spec...
Definition: I2C.h:593
enum I2C_BitRate_ I2C_BitRate
I2C bitRate.
I2CCC32XX Hardware attributes.
Definition: I2CCC32XX.h:158
unsigned int baseAddr
Definition: I2CCC32XX.h:160
uint16_t clkPin
Definition: I2CCC32XX.h:166
const I2C_FxnTable I2CCC32XX_fxnTable
void(* I2C_CallbackFxn)(I2C_Handle handle, I2C_Transaction *transaction, bool transferStatus)
I2C callback function.
Definition: I2C.h:506
I2C driver interface.
Copyright 2017, Texas Instruments Incorporated