I2CTargetLPF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, 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  */
32 /*!****************************************************************************
33  * @file I2CTargetLPF3.h
34  *
35  * @brief I2CTarget driver implementation for a Low Power F3 device I2C
36  * target.
37  *
38  * @note All calls should go through the generic I2CTarget API.
39  *
40  * # Driver Include #
41  * The I2CTarget header file should be included in an application as follows:
42  * @code
43  * #include <ti/drivers/I2CTarget.h>
44  * #include <ti/drivers/i2c/I2CTargetLPF3.h>
45  * @endcode
46  *
47  * Refer to @ref I2CTarget.h for a complete description of APIs.
48  *
49  * # Overview
50  * The generic I2CTarget API is normally used in application code,
51  * for example, @ref I2CTarget_open(). Do not use APIs in this header file
52  * directly. The board file will define the device specific config, and casting
53  * in the general API will ensure that the correct device specific functions
54  * are called.
55  *
56  * ## General Behavior
57  * Before using the I2C in LPF3:
58  * - The I2CTarget driver is initialized by calling I2CTarget_init().
59  * - The I2C HW is configured and system dependencies are declared (e.g. IOs,
60  * power, etc.) by calling I2CTarget_open().
61  * - The I2CTarget driver starts acting on I2C bus activities after calling
62  * @ref I2CTarget_start().
63  *
64  * ## Power Management
65  * The I2CTargetLPF3 driver sets a power constraint when @ref I2CTarget_start()
66  * is called to keep the device out of standby; so when all tasks are blocked, the device will
67  * enter idle mode instead of standby. When the application calls @ref I2CTarget_stop(), the
68  * the power constraint to prohibit standby is released.
69  * The following statements are valid:
70  * - After I2CTarget_open() call: I2C peripheral is enabled in target mode, but the device can
71  * enter standby. The device will need to be woken up (for example on GPIO or timer events)
72  * before I2C bus activity can be processed.
73  * - After I2CTarget_start() call: I2C events will trigger the user callback function. The device
74  * might enter idle, but not standby.
75  * - After I2C_stop() call: Same as after I2CTarget_open() call.
76  * - After I2C_close() call: I2C peripheral is disabled.
77  *
78  * ## Supported Functions
79  * @note All calls should go through the generic API.
80  *
81  * @anchor ti_drivers_I2CTARGETLPF3_USE_CASES
82  * # Use Cases
83  * See generic API for examples.
84  *
85  ******************************************************************************
86  */
87 
88 #ifndef ti_drivers_i2c_I2CTARGETLPF3__include
89 #define ti_drivers_i2c_I2CTARGETLPF3__include
90 
91 #include <stdint.h>
92 #include <stdbool.h>
93 
94 #include <ti/drivers/I2CTarget.h>
95 #include <ti/drivers/Power.h>
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
141 typedef struct
142 {
143  I2CTARGET_BASE_HWATTRS
144 
145  /* I2C peripheral's Power driver ID */
146  PowerLPF3_Resource powerMngrId;
147 
148  /* SDA pin index and mux */
149  uint8_t sdaPin;
150  uint8_t sdaPinMux;
151  /* SCL pin index and mux */
152  uint8_t sclPin;
153  uint8_t sclPinMux;
155 
161 typedef struct
162 {
163  I2CTARGET_BASE_OBJECT
164 
165  /* I2C power notification */
166  void *i2cPostFxn;
169 
174 #define I2CTARGET_INT_FLAGS (I2C_TARGET_INT_DATA | I2C_TARGET_INT_STOP)
175 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* ti_drivers_i2c_I2CTARGETLPF3__include */
I2CTARGET_BASE_HWATTRS PowerLPF3_Resource powerMngrId
Definition: I2CTargetLPF3.h:146
uint8_t sdaPinMux
Definition: I2CTargetLPF3.h:150
Power Manager.
I2CTargetLPF3 Object.
Definition: I2CTargetLPF3.h:161
I2CTargetLPF3 Hardware attributes.
Definition: I2CTargetLPF3.h:141
Power_NotifyObj i2cPostObj
Definition: I2CTargetLPF3.h:167
Power notify object structure.
Definition: Power.h:441
uint8_t sclPinMux
Definition: I2CTargetLPF3.h:153
uint8_t sclPin
Definition: I2CTargetLPF3.h:152
uint8_t sdaPin
Definition: I2CTargetLPF3.h:149
I2CTarget driver interface.
I2CTARGET_BASE_OBJECT void * i2cPostFxn
Definition: I2CTargetLPF3.h:166
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale