I2CSlave.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018, 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  */
119 #ifndef ti_drivers_I2CSLAVE__include
120 #define ti_drivers_I2CSLAVE__include
121 
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125 
126 #include <stdbool.h>
127 #include <stddef.h>
128 #include <stdint.h>
129 
146 #define I2CSLAVE_CMD_RESERVED (32)
147 
160 #define I2CSLAVE_STATUS_RESERVED (-32)
161 
174 #define I2CSLAVE_STATUS_SUCCESS (0)
175 
182 #define I2CSLAVE_STATUS_ERROR (-1)
183 
191 #define I2CSLAVE_STATUS_UNDEFINEDCMD (-2)
192 
202 /* Add I2CSLAVE_CMD_<commands> here */
203 
212 
219 typedef enum I2CSlave_Mode_ {
225 } I2CSlave_Mode;
226 
239 
251 typedef void (*I2CSlave_CallbackFxn)(I2CSlave_Handle handle, bool status);
252 
272 typedef struct I2CSlave_Params_ {
274  I2CSlave_TransferMode transferMode;
278  void *custom;
280 
285 typedef void (*I2CSlave_CloseFxn) (I2CSlave_Handle handle);
286 
291 typedef int_fast16_t (*I2CSlave_ControlFxn) (I2CSlave_Handle handle,
292  uint_fast16_t cmd,
293  void *arg);
294 
299 typedef void (*I2CSlave_InitFxn) (I2CSlave_Handle handle);
300 
305 typedef I2CSlave_Handle (*I2CSlave_OpenFxn) (I2CSlave_Handle handle,
306  I2CSlave_Params *params);
307 
312 typedef bool (*I2CSlave_WriteFxn) (I2CSlave_Handle handle,
313  const void *buffer, size_t size);
314 
315 
320 typedef bool (*I2CSlave_ReadFxn) (I2CSlave_Handle handle, void *buffer,
321  size_t size);
322 
323 
329 typedef struct I2CSlave_FxnTable_ {
332 
335 
338 
341 
344 
348 
360 typedef struct I2CSlave_Config_ {
363 
365  void *object;
366 
368  void const *hwAttrs;
370 
371 
381 extern void I2CSlave_close(I2CSlave_Handle handle);
382 
421 extern int_fast16_t I2CSlave_control(I2CSlave_Handle handle, uint_fast16_t cmd,
422  void *arg);
423 
432 extern void I2CSlave_init(void);
433 
454 extern I2CSlave_Handle I2CSlave_open(uint_least8_t index,
455  I2CSlave_Params *params);
456 
467 extern void I2CSlave_Params_init(I2CSlave_Params *params);
468 
501 extern bool I2CSlave_read(I2CSlave_Handle handle, void *buffer,
502  size_t size);
538 extern bool I2CSlave_write(I2CSlave_Handle handle, const void *buffer,
539  size_t size);
540 
541 #ifdef __cplusplus
542 }
543 #endif
544 
545 #endif /* ti_drivers_I2CSLAVE__include */
Definition: I2CSlave.h:223
struct I2CSlave_Config_ * I2CSlave_Handle
A handle that is returned from a I2CSlave_open() call.
Definition: I2CSlave.h:211
struct I2CSlave_Config_ I2CSlave_Config
I2CSlave Global configuration.
enum I2CSlave_Mode_ I2CSlave_Mode
I2CSlave mode.
struct I2CSlave_Params_ I2CSlave_Params
I2CSlave Parameters.
I2CSlave_ReadFxn readFxn
Definition: I2CSlave.h:343
void * object
Definition: I2CSlave.h:365
void I2CSlave_close(I2CSlave_Handle handle)
Function to close a I2CSlave peripheral specified by the I2CSlave handle.
I2CSlave_CallbackFxn transferCallbackFxn
Definition: I2CSlave.h:276
bool I2CSlave_write(I2CSlave_Handle handle, const void *buffer, size_t size)
Function that handles the I2CSlave write for SYS/BIOS.
I2CSlave Global configuration.
Definition: I2CSlave.h:360
I2CSlave Parameters.
Definition: I2CSlave.h:272
Definition: I2CSlave.h:235
void(* I2CSlave_CloseFxn)(I2CSlave_Handle handle)
A function pointer to a driver specific implementation of I2CSlave_close().
Definition: I2CSlave.h:285
I2CSlave_Handle(* I2CSlave_OpenFxn)(I2CSlave_Handle handle, I2CSlave_Params *params)
A function pointer to a driver specific implementation of I2CSlave_open().
Definition: I2CSlave.h:305
Definition: I2CSlave.h:220
I2CSlave_InitFxn initFxn
Definition: I2CSlave.h:337
I2CSlave_ControlFxn controlFxn
Definition: I2CSlave.h:334
I2CSlave_CloseFxn closeFxn
Definition: I2CSlave.h:331
struct I2CSlave_FxnTable_ I2CSlave_FxnTable
The definition of a I2CSlave function table that contains the required set of functions to control a ...
I2CSlave_TransferMode_
I2CSlave transfer mode.
Definition: I2CSlave.h:234
Definition: I2CSlave.h:236
Definition: I2CSlave.h:224
void const * hwAttrs
Definition: I2CSlave.h:368
int_fast16_t I2CSlave_control(I2CSlave_Handle handle, uint_fast16_t cmd, void *arg)
Function performs implementation specific features on a given I2CSlave_Handle.
Definition: I2CSlave.h:221
bool I2CSlave_read(I2CSlave_Handle handle, void *buffer, size_t size)
Function that handles the I2CSlave read for SYS/BIOS.
I2CSlave_OpenFxn openFxn
Definition: I2CSlave.h:340
I2CSlave_WriteFxn writeFxn
Definition: I2CSlave.h:346
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:320
void * custom
Definition: I2CSlave.h:278
void(* I2CSlave_CallbackFxn)(I2CSlave_Handle handle, bool status)
I2CSlave callback function.
Definition: I2CSlave.h:251
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:312
enum I2CSlave_TransferMode_ I2CSlave_TransferMode
I2CSlave transfer mode.
I2CSlave_TransferMode transferMode
Definition: I2CSlave.h:274
int_fast16_t(* I2CSlave_ControlFxn)(I2CSlave_Handle handle, uint_fast16_t cmd, void *arg)
A function pointer to a driver specific implementation of I2CSlave_control().
Definition: I2CSlave.h:291
Definition: I2CSlave.h:222
I2CSlave_FxnTable const * fxnTablePtr
Definition: I2CSlave.h:362
I2CSlave_Mode_
I2CSlave mode.
Definition: I2CSlave.h:219
void I2CSlave_Params_init(I2CSlave_Params *params)
Function to initialize the I2CSlave_Params struct to its defaults.
The definition of a I2CSlave function table that contains the required set of functions to control a ...
Definition: I2CSlave.h:329
void I2CSlave_init(void)
Function to initializes the I2CSlave module.
I2CSlave_Handle I2CSlave_open(uint_least8_t index, I2CSlave_Params *params)
Function to initialize a given I2CSlave peripheral specified by the particular index value...
void(* I2CSlave_InitFxn)(I2CSlave_Handle handle)
A function pointer to a driver specific implementation of I2CSlave_init().
Definition: I2CSlave.h:299
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale