TI-RTOS Drivers  tidrivers_msp43x_2_16_01_13
I2CMSP432.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  */
50 #ifndef ti_drivers_i2c_I2CMSP432__include
51 #define ti_drivers_i2c_I2CMSP432__include
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #include <stdint.h>
58 #include <stdbool.h>
59 
60 #include <ti/drivers/I2C.h>
61 #include <ti/drivers/ports/HwiP.h>
63 #include <ti/drivers/Power.h>
64 
75 /* Add I2CMSP432_STATUS_* macros here */
76 
89 /* Add I2CMSP432_CMD_* macros here */
90 
93 /* I2C function table pointer */
94 extern const I2C_FxnTable I2CMSP432_fxnTable;
95 
102 typedef enum I2CMSP432_Mode {
103  I2CMSP432_IDLE_MODE = 0, /* I2C is not performing a transaction */
104  I2CMSP432_WRITE_MODE, /* I2C is currently performing write operations */
105  I2CMSP432_READ_MODE, /* I2C is currently performing read operations */
106  I2CMSP432_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
108 
138 typedef struct I2CMSP432_HWAttrs {
139  uint32_t baseAddr;
140  uint32_t intNum;
141  uint32_t intPriority;
142  uint8_t clockSource;
144 
150 typedef struct I2CMSP432_Object {
151  SemaphoreP_Handle mutex; /* Grants exclusive access to I2C */
152  SemaphoreP_Handle transferComplete; /* Notify finished I2C transfer */
153 
155 
156  I2C_Transaction *currentTransaction; /* Ptr to current I2C transaction */
157  I2C_CallbackFxn transferCallbackFxn; /* Callback function pointer */
158 
159  /* I2C transaction pointers for I2C_MODE_CALLBACK */
160  I2C_Transaction *headPtr; /* Head ptr for queued transactions */
161  I2C_Transaction *tailPtr; /* Tail ptr for queued transactions */
162 
163  uint8_t *writeBufIdx; /* Internal inc. writeBuf index */
164  size_t writeCountIdx; /* Internal dec. writeCounter */
165 
166  uint8_t *readBufIdx; /* Internal inc. readBuf index */
167  size_t readCountIdx; /* Internal dec. readCounter */
168 
171 
172  volatile I2CMSP432_Mode mode; /* Stores the I2C state */
173  I2C_TransferMode transferMode; /* Blocking or Callback mode */
174  I2C_BitRate bitRate; /* SPI bit rate in Hz */
175  bool isOpen; /* To determine if the SPI is open */
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 #endif /* ti_drivers_i2c_I2CMSP432__include */
I2C_Transaction * currentTransaction
Definition: I2CMSP432.h:156
Definition: I2CMSP432.h:104
I2CMSP432 Object.
Definition: I2CMSP432.h:150
uint32_t baseAddr
Definition: I2CMSP432.h:139
volatile I2CMSP432_Mode mode
Definition: I2CMSP432.h:172
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:268
I2CMSP432 Hardware attributes These fields, with the exception of intPriority, are used by driverlib ...
Definition: I2CMSP432.h:138
I2CMSP432_Mode
I2CMSP432 mode.
Definition: I2CMSP432.h:102
SemaphoreP_Handle transferComplete
Definition: I2CMSP432.h:152
I2C_BitRate
I2C bitRate.
Definition: I2C.h:276
Power manager interface.
Definition: I2CMSP432.h:106
const I2C_FxnTable I2CMSP432_fxnTable
I2C_CallbackFxn transferCallbackFxn
Definition: I2CMSP432.h:157
uint8_t * readBufIdx
Definition: I2CMSP432.h:166
struct I2CMSP432_Object I2CMSP432_Object
I2CMSP432 Object.
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:250
uint32_t intPriority
Definition: I2CMSP432.h:141
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 a I2C function table that contains the required set of functions to control a speci...
Definition: I2C.h:348
I2C_Transaction * tailPtr
Definition: I2CMSP432.h:161
Definition: I2CMSP432.h:105
SemaphoreP_Handle mutex
Definition: I2CMSP432.h:151
struct I2CMSP432_HWAttrs I2CMSP432_HWAttrs
I2CMSP432 Hardware attributes These fields, with the exception of intPriority, are used by driverlib ...
size_t readCountIdx
Definition: I2CMSP432.h:167
I2C_BitRate bitRate
Definition: I2CMSP432.h:174
Power notify object structure.
Definition: Power.h:112
uint32_t intNum
Definition: I2CMSP432.h:140
I2C_Transaction * headPtr
Definition: I2CMSP432.h:160
Power_NotifyObj perfChangeNotify
Definition: I2CMSP432.h:169
uint8_t * writeBufIdx
Definition: I2CMSP432.h:163
size_t writeCountIdx
Definition: I2CMSP432.h:164
uint32_t perfConstraintMask
Definition: I2CMSP432.h:170
I2C_TransferMode transferMode
Definition: I2CMSP432.h:173
bool isOpen
Definition: I2CMSP432.h:175
void * HwiP_Handle
Opaque client reference to an instance of a HwiP.
Definition: HwiP.h:66
uint8_t clockSource
Definition: I2CMSP432.h:142
I2C transaction.
Definition: I2C.h:230
Hardware Interrupt module for the RTOS Porting Interface.
Definition: I2CMSP432.h:103
I2C driver interface.
HwiP_Handle hwiHandle
Definition: I2CMSP432.h:154
Copyright 2016, Texas Instruments Incorporated