TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
I2C.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  */
132 #ifndef ti_drivers_I2C__include
133 #define ti_drivers_I2C__include
134 
135 #ifdef __cplusplus
136 extern "C" {
137 #endif
138 
139 #include <stdint.h>
140 #include <stdbool.h>
141 #include <stddef.h>
142 
154 #define I2C_CMD_RESERVED 32
155 
168 #define I2C_STATUS_RESERVED -32
169 
176 #define I2C_STATUS_SUCCESS 0
177 
184 #define I2C_STATUS_ERROR -1
185 
193 #define I2C_STATUS_UNDEFINEDCMD -2
194 
198 typedef struct I2C_Config *I2C_Handle;
199 
210 typedef struct I2C_Transaction {
211  void *writeBuf;
212  size_t writeCount;
214  void *readBuf;
215  size_t readCount;
217  unsigned char slaveAddress;
219  void *arg;
220  void *nextPtr;
222 
230 typedef enum I2C_TransferMode {
234 
248 typedef void (*I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool);
249 
256 typedef enum I2C_BitRate {
259 } I2C_BitRate;
260 
281 typedef struct I2C_Params {
285  void *custom;
287 } I2C_Params;
288 
293 typedef void (*I2C_CloseFxn) (I2C_Handle handle);
294 
299 typedef int (*I2C_ControlFxn) (I2C_Handle handle,
300  unsigned int cmd,
301  void *arg);
302 
307 typedef void (*I2C_InitFxn) (I2C_Handle handle);
308 
313 typedef I2C_Handle (*I2C_OpenFxn) (I2C_Handle handle,
314  I2C_Params *params);
315 
320 typedef bool (*I2C_TransferFxn) (I2C_Handle handle,
321  I2C_Transaction *transaction);
322 
328 typedef struct I2C_FxnTable {
331 
334 
337 
340 
343 } I2C_FxnTable;
344 
356 typedef struct I2C_Config {
359 
361  void *object;
362 
364  void const *hwAttrs;
365 } I2C_Config;
366 
367 
377 extern void I2C_close(I2C_Handle handle);
378 
398 extern int I2C_control(I2C_Handle handle, unsigned int cmd, void *arg);
399 
408 extern void I2C_init(void);
409 
430 extern I2C_Handle I2C_open(unsigned int index, I2C_Params *params);
431 
443 extern void I2C_Params_init(I2C_Params *params);
444 
485 extern bool I2C_transfer(I2C_Handle handle, I2C_Transaction *transaction);
486 
487 #ifdef __cplusplus
488 }
489 #endif
490 
491 #endif /* ti_drivers_I2C__include */
void * writeBuf
Definition: I2C.h:211
void * arg
Definition: I2C.h:219
struct I2C_Config I2C_Config
I2C Global configuration.
I2C_TransferMode transferMode
Definition: I2C.h:282
void * object
Definition: I2C.h:361
void * readBuf
Definition: I2C.h:214
void * nextPtr
Definition: I2C.h:220
I2C Global configuration.
Definition: I2C.h:356
void I2C_Params_init(I2C_Params *params)
Function to initialize the I2C_Params struct to its defaults.
struct I2C_Config * I2C_Handle
A handle that is returned from a I2C_open() call.
Definition: I2C.h:198
void(* I2C_CloseFxn)(I2C_Handle handle)
A function pointer to a driver specific implementation of I2C_close().
Definition: I2C.h:293
int I2C_control(I2C_Handle handle, unsigned int cmd, void *arg)
Function performs implementation specific features on a given I2C_Handle.
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:248
void(* I2C_InitFxn)(I2C_Handle handle)
A function pointer to a driver specific implementation of I2C_init().
Definition: I2C.h:307
I2C_BitRate
I2C bitRate.
Definition: I2C.h:256
Definition: I2C.h:231
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:230
I2C_CallbackFxn transferCallbackFxn
Definition: I2C.h:283
I2C_CloseFxn closeFxn
Definition: I2C.h:330
I2C_InitFxn initFxn
Definition: I2C.h:336
bool(* I2C_TransferFxn)(I2C_Handle handle, I2C_Transaction *transaction)
A function pointer to a driver specific implementation of I2C_transfer().
Definition: I2C.h:320
The definition of a I2C function table that contains the required set of functions to control a speci...
Definition: I2C.h:328
I2C_FxnTable const * fxnTablePtr
Definition: I2C.h:358
I2C_OpenFxn openFxn
Definition: I2C.h:339
Definition: I2C.h:258
struct I2C_FxnTable I2C_FxnTable
The definition of a I2C function table that contains the required set of functions to control a speci...
I2C_TransferFxn transferFxn
Definition: I2C.h:342
I2C_BitRate bitRate
Definition: I2C.h:284
void I2C_close(I2C_Handle handle)
Function to close a I2C peripheral specified by the I2C handle.
I2C Parameters.
Definition: I2C.h:281
int(* I2C_ControlFxn)(I2C_Handle handle, unsigned int cmd, void *arg)
A function pointer to a driver specific implementation of I2C_control().
Definition: I2C.h:299
I2C_ControlFxn controlFxn
Definition: I2C.h:333
struct I2C_Transaction I2C_Transaction
I2C transaction.
I2C_Handle I2C_open(unsigned int index, I2C_Params *params)
Function to initialize a given I2C peripheral specified by the particular index value. The parameter specifies which mode the I2C will operate.
void * custom
Definition: I2C.h:285
struct I2C_Params I2C_Params
I2C Parameters.
Definition: I2C.h:232
void I2C_init(void)
Function to initializes the I2C module.
unsigned char slaveAddress
Definition: I2C.h:217
void const * hwAttrs
Definition: I2C.h:364
I2C transaction.
Definition: I2C.h:210
bool I2C_transfer(I2C_Handle handle, I2C_Transaction *transaction)
Function to perform an I2C transaction with an I2C slave peripheral.
size_t writeCount
Definition: I2C.h:212
I2C_Handle(* I2C_OpenFxn)(I2C_Handle handle, I2C_Params *params)
A function pointer to a driver specific implementation of I2C_open().
Definition: I2C.h:313
Definition: I2C.h:257
size_t readCount
Definition: I2C.h:215
Copyright 2015, Texas Instruments Incorporated