MSPM0L11XX_L13XX TI-Driver Library  2.01.00.03
I2CTargetMSPM0.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2024, 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 I2CTargetMSPM0.h
34  *
35  * @brief I2CTarget driver implementation for a MSPM0 device I2C
36  * target.
37  *
38  * @defgroup I2CTargetMSPM0 I2C driver APIs
39  *
40  * @note All calls should go through the generic I2CTarget API.
41  *
42  * # Driver Include #
43  * The I2CTarget header file should be included in an application as follows:
44  * @code
45  * #include <ti/drivers/I2CTarget.h>
46  * #include <ti/drivers/i2c/I2CTargetMSPM0.h>
47  * @endcode
48  *
49  * Refer to @ref I2CTarget.h for a complete description of APIs.
50  *
51  * # Overview
52  * The generic I2CTarget API is normally used in application code,
53  * for example, @ref I2CTarget_open(). Do not use APIs in this header file
54  * directly. The board file will define the device specific config, and casting
55  * in the general API will ensure that the correct device specific functions
56  * are called.
57  *
58  * ## General Behavior
59  * Before using the I2C in MSPM0:
60  * - The I2CTarget driver is initialized by calling I2CTarget_init().
61  * - The I2C HW is configured and system dependencies are declared (e.g. IOs,
62  * power, etc.) by calling I2CTarget_open().
63  * - The I2CTarget driver starts acting on I2C bus activities after calling
64  * @ref I2CTarget_start().
65  *
66  * ## Power Management
67  * The Power drivers are yet to implement but the behavior should follow like the information given here.
68  * The I2CTargetMSPM0 driver sets a power constraint when @ref I2CTarget_start()
69  * is called to keep the device out of standby; so when all tasks are blocked, the device will
70  * enter idle mode instead of standby. When the application calls @ref I2CTarget_stop(), the
71  * the power constraint to prohibit standby is released.
72  * The following statements are valid:
73  * - After I2CTarget_open() call: I2C peripheral is enabled in target mode, but the device can
74  * enter standby. The device will need to be woken up (for example on GPIO or timer events)
75  * before I2C bus activity can be processed.
76  * - After I2CTarget_start() call: I2C events will trigger the user callback function. The device
77  * might enter idle, but not standby.
78  * - After I2C_stop() call: Same as after I2CTarget_open() call.
79  * - After I2C_close() call: I2C peripheral is disabled.
80  *
81  * ## Supported Functions
82  * @note All calls should go through the generic API.
83  *
84  * @anchor ti_drivers_I2CTARGETMSPM0_USE_CASES
85  * # Use Cases
86  * See generic API for examples.
87  *
88  ******************************************************************************
89  */
94 /* clang-format off */
95 
96 #ifndef ti_drivers_I2CTargetMSPM0__include
97 #define ti_drivers_I2CTargetMSPM0__include
98 
99 #include <stdint.h>
100 #include <stdbool.h>
101 
102 #include <ti/driverlib/dl_i2c.h>
103 #include <ti/drivers/I2CTarget.h>
104 
105 #ifdef POWER_MANAGEMENT_MSPM0
106 #include <ti/drivers/Power.h>
107 #endif
108 
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112 
158 typedef struct
159 {
160  I2CTARGET_BASE_HWATTRS
162  /* SDA pin PINCM index and mux */
163  uint8_t sdaPincm;
164  uint8_t sdaPinIndex;
165  uint32_t sdaPinMux;
166  /* SCL pin PINCM index and mux */
167  uint8_t sclPincm;
168  uint8_t sclPinIndex;
169  uint32_t sclPinMux;
170 #ifdef POWER_MANAGEMENT_MSPM0
171  /* I2C peripheral's Power driver ID */
172  PowerMSPM0_Resource powerMngrId;
173 #endif
174  DL_I2C_CLOCK clockSource;
175  DL_I2C_CLOCK_DIVIDE clockDivider;
176  DL_I2C_RX_FIFO_LEVEL rxIntFifoThr;
177  DL_I2C_TX_FIFO_LEVEL txIntFifoThr;
180  uint16_t i2cClk;
182 
188 typedef struct
189 {
190  I2CTARGET_BASE_OBJECT
191 #ifdef POWER_MANAGEMENT_MSPM0
192  /* I2C power notification */
193  void *i2cPostFxn;
194  Power_NotifyObj i2cPostObj;
195 #endif
197 
208 static bool I2CBaseValid(I2C_Regs *i2c)
209 {
210  return ((i2c == (I2C_Regs *) I2C0_BASE)||(i2c == (I2C_Regs *) I2C1_BASE));
211 }
212 
217 #define I2CTARGET_INT_FLAGS ( DL_I2C_INTERRUPT_TARGET_TXFIFO_EMPTY | \
218  DL_I2C_INTERRUPT_TARGET_RX_DONE | \
219  DL_I2C_INTERRUPT_TARGET_TXFIFO_TRIGGER | \
220  DL_I2C_INTERRUPT_TARGET_RXFIFO_TRIGGER | \
221  DL_I2C_INTERRUPT_TARGET_START | \
222  DL_I2C_INTERRUPT_TARGET_STOP)
223 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif /* ti_drivers_I2CTargetMSPM0__include */
230 /* clang-format on */
bool isAnalogGlitchFilterEnabled
Definition: I2CTargetMSPM0.h:179
uint16_t i2cClk
Definition: I2CTargetMSPM0.h:180
bool isClockStretchingEnabled
Definition: I2CTargetMSPM0.h:178
uint32_t sclPinMux
Definition: I2CTargetMSPM0.h:169
DL_I2C_TX_FIFO_LEVEL txIntFifoThr
Definition: I2CTargetMSPM0.h:177
uint8_t sdaPinIndex
Definition: I2CTargetMSPM0.h:164
DL_I2C_CLOCK_DIVIDE clockDivider
Definition: I2CTargetMSPM0.h:175
I2CTargetMSPM0 Hardware attributes.
Definition: I2CTargetMSPM0.h:158
static bool I2CBaseValid(I2C_Regs *i2c)
Checks an I2C base address. This function determines if a I2C port base address is valid...
Definition: I2CTargetMSPM0.h:208
DL_I2C_CLOCK clockSource
Definition: I2CTargetMSPM0.h:174
uint8_t sclPincm
Definition: I2CTargetMSPM0.h:167
I2CTargetMSPM0 Object.
Definition: I2CTargetMSPM0.h:188
I2CTARGET_BASE_HWATTRS uint8_t sdaPincm
Definition: I2CTargetMSPM0.h:163
uint8_t sclPinIndex
Definition: I2CTargetMSPM0.h:168
DL_I2C_RX_FIFO_LEVEL rxIntFifoThr
Definition: I2CTargetMSPM0.h:176
I2CTarget driver interface.
uint32_t sdaPinMux
Definition: I2CTargetMSPM0.h:165
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale