TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
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  */
73 #ifndef ti_drivers_i2c_I2CUSCIB__include
74 #define ti_drivers_i2c_I2CUSCIB__include
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 #include <stdint.h>
81 #include <stdbool.h>
82 #include <ti/drivers/I2C.h>
83 
84 #include <ti/sysbios/knl/Semaphore.h>
85 
86 /* I2C function table pointer */
87 extern const I2C_FxnTable I2CUSCIB_fxnTable;
88 
95 typedef enum I2CUSCIB_Mode {
96  I2CUSCIB_IDLE_MODE = 0, /* I2C is not performing a transaction */
97  I2CUSCIB_WRITE_MODE, /* I2C is currently performing write operations */
98  I2CUSCIB_READ_MODE, /* I2C is currently performing read operations */
99  I2CUSCIB_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
100 } I2CUSCIB_Mode;
101 
124 typedef struct I2CUSCIB_HWAttrs {
126  uint32_t baseAddr;
128  uint8_t clockSource;
130 
136 typedef struct I2CUSCIB_Object {
137  bool isOpen; /* To determine if the SPI is open */
138 
139  Semaphore_Struct mutex; /* Grants exclusive access to I2C */
140  Semaphore_Struct transferComplete; /* Notify finished I2C transfer */
141 
142  I2C_TransferMode transferMode; /* Blocking or Callback mode */
143  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
144 
145  volatile I2CUSCIB_Mode mode; /* Stores the I2C state */
146 
147  I2C_Transaction *currentTransaction; /* Pointer to current I2C transaction */
148 
149  uint8_t *writeBufIdx; /* Internal inc. writeBuf index */
150  size_t writeCountIdx; /* Internal dec. writeCounter */
151 
152  uint8_t *readBufIdx; /* Internal inc. readBuf index */
153  size_t readCountIdx; /* Internal dec. readCounter */
154 
155  /* I2C transaction pointers for I2C_MODE_CALLBACK */
156  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
157  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
158 
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #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:248
size_t readCountIdx
Definition: I2CUSCIB.h:153
Definition: I2CUSCIB.h:97
Definition: I2CUSCIB.h:96
Semaphore_Struct transferComplete
Definition: I2CUSCIB.h:140
Definition: I2CUSCIB.h:98
struct I2CUSCIB_Object I2CUSCIB_Object
I2CUSCIB Object.
I2C_TransferMode transferMode
Definition: I2CUSCIB.h:142
size_t writeCountIdx
Definition: I2CUSCIB.h:150
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:230
The definition of a I2C function table that contains the required set of functions to control a speci...
Definition: I2C.h:328
I2CUSCIB Object.
Definition: I2CUSCIB.h:136
Definition: I2CUSCIB.h:99
I2C_CallbackFxn transferCallbackFxn
Definition: I2CUSCIB.h:143
Semaphore_Struct mutex
Definition: I2CUSCIB.h:139
uint8_t * writeBufIdx
Definition: I2CUSCIB.h:149
uint8_t clockSource
Definition: I2CUSCIB.h:128
uint32_t baseAddr
Definition: I2CUSCIB.h:126
I2C_Transaction * currentTransaction
Definition: I2CUSCIB.h:147
struct I2CUSCIB_HWAttrs I2CUSCIB_HWAttrs
I2CUSCIB Hardware attributes.
I2CUSCIB_Mode
I2CUSCIB mode.
Definition: I2CUSCIB.h:95
I2C_Transaction * tailPtr
Definition: I2CUSCIB.h:157
bool isOpen
Definition: I2CUSCIB.h:137
I2C transaction.
Definition: I2C.h:210
uint8_t * readBufIdx
Definition: I2CUSCIB.h:152
I2C_Transaction * headPtr
Definition: I2CUSCIB.h:156
I2C driver interface.
I2CUSCIB Hardware attributes.
Definition: I2CUSCIB.h:124
volatile I2CUSCIB_Mode mode
Definition: I2CUSCIB.h:145
Copyright 2015, Texas Instruments Incorporated