TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
I2CTiva.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  */
46 #ifndef ti_drivers_i2c_I2CTiva__include
47 #define ti_drivers_i2c_I2CTiva__include
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 #include <stdint.h>
54 #include <stdbool.h>
55 #include <ti/drivers/I2C.h>
56 
57 #include <ti/sysbios/knl/Semaphore.h>
58 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
59 #include <ti/sysbios/family/arm/m3/Hwi.h>
60 
61 /* I2C function table pointer */
62 extern const I2C_FxnTable I2CTiva_fxnTable;
63 
70 typedef enum I2CTiva_Mode {
71  I2CTiva_IDLE_MODE = 0, /* I2C is not performing a transaction */
72  I2CTiva_WRITE_MODE, /* I2C is currently performing write operations */
73  I2CTiva_READ_MODE, /* I2C is currently performing read operations */
74  I2CTiva_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
75 } I2CTiva_Mode;
76 
112 typedef struct I2CTiva_HWAttrs {
114  unsigned int baseAddr;
116  unsigned int intNum;
118  unsigned int intPriority;
120 
126 typedef struct I2CTiva_Object {
127  Semaphore_Struct mutex; /* Grants exclusive access to I2C */
128  Semaphore_Struct transferComplete; /* Notify finished I2C transfer */
129 
130  I2C_TransferMode transferMode; /* Blocking or Callback mode */
131  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
132 
133  ti_sysbios_family_arm_m3_Hwi_Struct hwi; /* Hwi object handle */
134 
135  volatile I2CTiva_Mode mode; /* Stores the I2C state */
136 
137  I2C_Transaction *currentTransaction; /* Pointer to current I2C transaction */
138 
139  uint8_t *writeBufIdx; /* Internal inc. writeBuf index */
140  size_t writeCountIdx; /* Internal dec. writeCounter */
141 
142  uint8_t *readBufIdx; /* Internal inc. readBuf index */
143  size_t readCountIdx; /* Internal dec. readCounter */
144 
145  /* I2C transaction pointers for I2C_MODE_CALLBACK */
146  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
147  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
148 
149  bool isOpen; /* flag to indicate module is open */
151 
152 /* Do not interfere with the app if they include the family Hwi module */
153 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* ti_drivers_i2c_I2CTiva__include */
bool isOpen
Definition: I2CTiva.h:149
Definition: I2CTiva.h:73
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:248
struct I2CTiva_HWAttrs I2CTiva_HWAttrs
I2CTiva Hardware attributes.
Semaphore_Struct transferComplete
Definition: I2CTiva.h:128
I2CTiva_Mode
I2CTiva mode.
Definition: I2CTiva.h:70
unsigned int intNum
Definition: I2CTiva.h:116
I2C_CallbackFxn transferCallbackFxn
Definition: I2CTiva.h:131
I2C_Transaction * currentTransaction
Definition: I2CTiva.h:137
const I2C_FxnTable I2CTiva_fxnTable
I2CTiva Object.
Definition: I2CTiva.h:126
I2C_Transaction * headPtr
Definition: I2CTiva.h:146
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:230
I2C_Transaction * tailPtr
Definition: I2CTiva.h:147
The definition of a I2C function table that contains the required set of functions to control a speci...
Definition: I2C.h:328
Definition: I2CTiva.h:74
I2C_TransferMode transferMode
Definition: I2CTiva.h:130
I2CTiva Hardware attributes.
Definition: I2CTiva.h:112
unsigned int baseAddr
Definition: I2CTiva.h:114
struct I2CTiva_Object I2CTiva_Object
I2CTiva Object.
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: I2CTiva.h:133
size_t writeCountIdx
Definition: I2CTiva.h:140
uint8_t * writeBufIdx
Definition: I2CTiva.h:139
Definition: I2CTiva.h:71
size_t readCountIdx
Definition: I2CTiva.h:143
I2C transaction.
Definition: I2C.h:210
Definition: I2CTiva.h:72
volatile I2CTiva_Mode mode
Definition: I2CTiva.h:135
unsigned int intPriority
Definition: I2CTiva.h:118
I2C driver interface.
uint8_t * readBufIdx
Definition: I2CTiva.h:142
Semaphore_Struct mutex
Definition: I2CTiva.h:127
Copyright 2015, Texas Instruments Incorporated