TI-RTOS Drivers  tidrivers_full_2_20_00_08
I2CSlave.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, 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  */
118 #ifndef ti_drivers_I2CSLAVE__include
119 #define ti_drivers_I2CSLAVE__include
120 
121 #ifdef __cplusplus
122 extern "C" {
123 #endif
124 
125 #include <stdint.h>
126 #include <stdbool.h>
127 #include <stddef.h>
128 
140 #define I2CSLAVE_CMD_RESERVED 32
141 
154 #define I2CSLAVE_STATUS_RESERVED -32
155 
162 #define I2CSLAVE_STATUS_SUCCESS 0
163 
170 #define I2CSLAVE_STATUS_ERROR -1
171 
179 #define I2CSLAVE_STATUS_UNDEFINEDCMD -2
180 
185 
192 typedef enum I2CSlave_Mode {
193  I2CSLAVE_IDLE_MODE = 0, /* I2CSlave is not performing a transaction */
194  I2CSLAVE_WRITE_MODE, /* I2CSlave is currently performing write */
195  I2CSLAVE_READ_MODE, /* I2CSlave is currently performing read */
196  I2CSLAVE_START_MODE, /* I2CSlave received a START from a master */
197  I2CSLAVE_ERROR = 0xFF /* I2CSlave error has occurred, exit gracefully */
198 } I2CSlave_Mode;
199 
207 typedef enum I2CSlave_TransferMode {
212 
224 typedef void (*I2CSlave_CallbackFxn)(I2CSlave_Handle, bool);
225 
245 typedef struct I2CSlave_Params {
251  uint_fast16_t slaveAddress;
253  uintptr_t custom;
255 
260 typedef void (*I2CSlave_CloseFxn) (I2CSlave_Handle handle);
261 
266 typedef int (*I2CSlave_ControlFxn) (I2CSlave_Handle handle,
267  unsigned int cmd,
268  void *arg);
269 
274 typedef void (*I2CSlave_InitFxn) (I2CSlave_Handle handle);
275 
280 typedef I2CSlave_Handle (*I2CSlave_OpenFxn) (I2CSlave_Handle handle,
281  I2CSlave_Params *params);
282 
287 typedef bool (*I2CSlave_WriteFxn) (I2CSlave_Handle handle,
288  const void *buffer, size_t size);
289 
290 
295 typedef bool (*I2CSlave_ReadFxn) (I2CSlave_Handle handle, void *buffer,
296  size_t size);
297 
298 
304 typedef struct I2CSlave_FxnTable {
307 
310 
313 
316 
319 
323 
335 typedef struct I2CSlave_Config {
338 
340  void *object;
341 
343  void const *hwAttrs;
345 
346 
356 extern void I2CSlave_close(I2CSlave_Handle handle);
357 
377 extern int I2CSlave_control(I2CSlave_Handle handle, unsigned int cmd,
378  void *arg);
379 
388 extern void I2CSlave_init(void);
389 
410 extern I2CSlave_Handle I2CSlave_open(unsigned int index,
411  I2CSlave_Params *params);
412 
423 extern void I2CSlave_Params_init(I2CSlave_Params *params);
424 
457 extern bool I2CSlave_read(I2CSlave_Handle handle, void *buffer,
458  size_t size);
494 extern bool I2CSlave_write(I2CSlave_Handle handle, const void *buffer,
495  size_t size);
496 
497 #ifdef __cplusplus
498 }
499 #endif
500 
501 #endif /* ti_drivers_I2CSLAVE__include */
Definition: I2CSlave.h:195
struct I2CSlave_Config * I2CSlave_Handle
A handle that is returned from a I2CSlave_open() call.
Definition: I2CSlave.h:184
struct I2CSlave_Config I2CSlave_Config
I2CSlave Global configuration.
Definition: I2CSlave.h:194
uint_fast16_t slaveAddress
Definition: I2CSlave.h:251
I2CSlave_TransferMode
I2CSlave transfer mode.
Definition: I2CSlave.h:207
void I2CSlave_close(I2CSlave_Handle handle)
Function to close a I2CSlave peripheral specified by the I2CSlave handle.
bool I2CSlave_write(I2CSlave_Handle handle, const void *buffer, size_t size)
Function that handles the I2CSlave write for SYS/BIOS.
Definition: I2CSlave.h:197
void const * hwAttrs
Definition: I2CSlave.h:343
void(* I2CSlave_CloseFxn)(I2CSlave_Handle handle)
A function pointer to a driver specific implementation of I2CSlave_close().
Definition: I2CSlave.h:260
I2CSlave_Handle(* I2CSlave_OpenFxn)(I2CSlave_Handle handle, I2CSlave_Params *params)
A function pointer to a driver specific implementation of I2CSlave_open().
Definition: I2CSlave.h:280
void(* I2CSlave_CallbackFxn)(I2CSlave_Handle, bool)
I2CSlave callback function.
Definition: I2CSlave.h:224
Definition: I2CSlave.h:196
uintptr_t custom
Definition: I2CSlave.h:253
Definition: I2CSlave.h:193
I2CSlave_CallbackFxn transferCallbackFxn
Definition: I2CSlave.h:249
struct I2CSlave_Params I2CSlave_Params
I2CSlave Parameters.
I2CSlave_CloseFxn closeFxn
Definition: I2CSlave.h:306
I2CSlave_Mode
I2CSlave mode.
Definition: I2CSlave.h:192
I2CSlave_Handle I2CSlave_open(unsigned int index, I2CSlave_Params *params)
Function to initialize a given I2CSlave peripheral specified by the particular index value...
I2CSlave_FxnTable const * fxnTablePtr
Definition: I2CSlave.h:337
I2CSlave_OpenFxn openFxn
Definition: I2CSlave.h:315
bool I2CSlave_read(I2CSlave_Handle handle, void *buffer, size_t size)
Function that handles the I2CSlave read for SYS/BIOS.
void * object
Definition: I2CSlave.h:340
int I2CSlave_control(I2CSlave_Handle handle, unsigned int cmd, void *arg)
Function performs implementation specific features on a given I2CSlave_Handle.
bool(* I2CSlave_ReadFxn)(I2CSlave_Handle handle, void *buffer, size_t size)
A function pointer to a driver specific implementation of I2CSlave_ReadFxn().
Definition: I2CSlave.h:295
struct I2CSlave_FxnTable I2CSlave_FxnTable
The definition of a I2CSlave function table that contains the required set of functions to control a ...
I2CSlave_InitFxn initFxn
Definition: I2CSlave.h:312
bool(* I2CSlave_WriteFxn)(I2CSlave_Handle handle, const void *buffer, size_t size)
A function pointer to a driver specific implementation of I2CSlave_WriteTransaction().
Definition: I2CSlave.h:287
I2CSlave_WriteFxn writeFxn
Definition: I2CSlave.h:321
I2CSlave Global configuration.
Definition: I2CSlave.h:335
I2CSlave_ReadFxn readFxn
Definition: I2CSlave.h:318
int(* I2CSlave_ControlFxn)(I2CSlave_Handle handle, unsigned int cmd, void *arg)
A function pointer to a driver specific implementation of I2CSlave_control().
Definition: I2CSlave.h:266
void I2CSlave_Params_init(I2CSlave_Params *params)
Function to initialize the I2CSlave_Params struct to its defaults.
I2CSlave_ControlFxn controlFxn
Definition: I2CSlave.h:309
I2CSlave Parameters.
Definition: I2CSlave.h:245
The definition of a I2CSlave function table that contains the required set of functions to control a ...
Definition: I2CSlave.h:304
I2CSlave_TransferMode transferMode
Definition: I2CSlave.h:247
Definition: I2CSlave.h:209
Definition: I2CSlave.h:208
void I2CSlave_init(void)
Function to initializes the I2CSlave module.
void(* I2CSlave_InitFxn)(I2CSlave_Handle handle)
A function pointer to a driver specific implementation of I2CSlave_init().
Definition: I2CSlave.h:274
Copyright 2016, Texas Instruments Incorporated