TI-RTOS Drivers  tidrivers_msp43x_2_16_01_13
I2CUSCIB.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 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  */
75 #ifndef ti_drivers_i2c_I2CUSCIB__include
76 #define ti_drivers_i2c_I2CUSCIB__include
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 #include <stdint.h>
83 #include <stdbool.h>
84 #include <ti/drivers/I2C.h>
85 
86 #include <ti/sysbios/knl/Semaphore.h>
87 
98 /* Add I2CUSCIB_STATUS_* macros here */
99 
112 /* Add I2CUSCIB_CMD_* macros here */
113 
116 /* I2C function table pointer */
117 extern const I2C_FxnTable I2CUSCIB_fxnTable;
118 
125 typedef enum I2CUSCIB_Mode {
126  I2CUSCIB_IDLE_MODE = 0, /* I2C is not performing a transaction */
127  I2CUSCIB_WRITE_MODE, /* I2C is currently performing write operations */
128  I2CUSCIB_READ_MODE, /* I2C is currently performing read operations */
129  I2CUSCIB_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
130 } I2CUSCIB_Mode;
131 
154 typedef struct I2CUSCIB_HWAttrs {
156  uint32_t baseAddr;
158  uint8_t clockSource;
160 
166 typedef struct I2CUSCIB_Object {
167  bool isOpen; /* To determine if the SPI is open */
168 
169  Semaphore_Struct mutex; /* Grants exclusive access to I2C */
170  Semaphore_Struct transferComplete; /* Notify finished I2C transfer */
171 
172  I2C_TransferMode transferMode; /* Blocking or Callback mode */
173  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
174 
175  volatile I2CUSCIB_Mode mode; /* Stores the I2C state */
176 
177  I2C_Transaction *currentTransaction; /* Pointer to current I2C transaction */
178 
179  uint8_t *writeBufIdx; /* Internal inc. writeBuf index */
180  size_t writeCountIdx; /* Internal dec. writeCounter */
181 
182  uint8_t *readBufIdx; /* Internal inc. readBuf index */
183  size_t readCountIdx; /* Internal dec. readCounter */
184 
185  /* I2C transaction pointers for I2C_MODE_CALLBACK */
186  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
187  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
188 
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif /* ti_drivers_i2c_I2CUSCIB__include */
const I2C_FxnTable I2CUSCIB_fxnTable
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:268
size_t readCountIdx
Definition: I2CUSCIB.h:183
Definition: I2CUSCIB.h:127
Definition: I2CUSCIB.h:126
Semaphore_Struct transferComplete
Definition: I2CUSCIB.h:170
Definition: I2CUSCIB.h:128
struct I2CUSCIB_Object I2CUSCIB_Object
I2CUSCIB Object.
I2C_TransferMode transferMode
Definition: I2CUSCIB.h:172
size_t writeCountIdx
Definition: I2CUSCIB.h:180
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:250
The definition of a I2C function table that contains the required set of functions to control a speci...
Definition: I2C.h:348
I2CUSCIB Object.
Definition: I2CUSCIB.h:166
Definition: I2CUSCIB.h:129
I2C_CallbackFxn transferCallbackFxn
Definition: I2CUSCIB.h:173
Semaphore_Struct mutex
Definition: I2CUSCIB.h:169
uint8_t * writeBufIdx
Definition: I2CUSCIB.h:179
uint8_t clockSource
Definition: I2CUSCIB.h:158
uint32_t baseAddr
Definition: I2CUSCIB.h:156
I2C_Transaction * currentTransaction
Definition: I2CUSCIB.h:177
struct I2CUSCIB_HWAttrs I2CUSCIB_HWAttrs
I2CUSCIB Hardware attributes.
I2CUSCIB_Mode
I2CUSCIB mode.
Definition: I2CUSCIB.h:125
I2C_Transaction * tailPtr
Definition: I2CUSCIB.h:187
bool isOpen
Definition: I2CUSCIB.h:167
I2C transaction.
Definition: I2C.h:230
uint8_t * readBufIdx
Definition: I2CUSCIB.h:182
I2C_Transaction * headPtr
Definition: I2CUSCIB.h:186
I2C driver interface.
I2CUSCIB Hardware attributes.
Definition: I2CUSCIB.h:154
volatile I2CUSCIB_Mode mode
Definition: I2CUSCIB.h:175
Copyright 2016, Texas Instruments Incorporated