1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2021 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 #ifndef FSL_TSI_V5_H_
9 #define FSL_TSI_V5_H_
10 
11 #include "fsl_common.h"
12 
13 /*!
14  * @addtogroup tsi_v5_driver
15  * @{
16  */
17 /*******************************************************************************
18  * Variables
19  ******************************************************************************/
20 /* Array of TSI clock name. */
21 extern const clock_ip_name_t s_tsiClock[];
22 /* Array of TSI IRQ name. */
23 extern const IRQn_Type s_TsiIRQ[];
24 /* Array of TSI peripheral base address. */
25 extern TSI_Type *const s_tsiBases[];
26 /*******************************************************************************
27  * Definitions
28  ******************************************************************************/
29 
30 /*! @brief TSI driver version */
31 #define FSL_TSI_DRIVER_VERSION (MAKE_VERSION(2, 6, 0))
32 
33 /*! @brief TSI status flags macro collection */
34 #define ALL_FLAGS_MASK (TSI_GENCS_EOSF_MASK | TSI_GENCS_OUTRGF_MASK)
35 
36 /*!
37  * @brief TSI main clock selection.
38  *
39  * These constants set the tsi main clock.
40  */
41 typedef enum _tsi_main_clock_selection
42 {
43     kTSI_MainClockSlection_0 = 0U, /*!< Set TSI main clock frequency to 20.72MHz */
44     kTSI_MainClockSlection_1 = 1U, /*!< Set TSI main clock frequency to 16.65MHz */
45     kTSI_MainClockSlection_2 = 2U, /*!< Set TSI main clock frequency to 13.87MHz */
46     kTSI_MainClockSlection_3 = 3U, /*!< Set TSI main clock frequency to 11.91MHz */
47 } tsi_main_clock_selection_t;
48 
49 /*!
50  * @brief TSI sensing mode selection.
51  *
52  * These constants set the tsi sensing mode.
53  */
54 typedef enum _tsi_sensing_mode_selection
55 {
56     kTSI_SensingModeSlection_Self   = 0U, /*!< Set TSI sensing mode to self-cap mode */
57     kTSI_SensingModeSlection_Mutual = 1U, /*!< Set TSI sensing mode to mutual-cap mode */
58 } tsi_sensing_mode_selection_t;
59 
60 /*!
61  * @brief TSI DVOLT settings
62  *
63  * These bits indicate the comparator vp, vm and dvolt voltage.
64  */
65 typedef enum _tsi_dvolt_option
66 {
67     kTSI_DvoltOption_0 = 0U, /*!< DVOLT value option 0, the value may differ on different platforms */
68     kTSI_DvoltOption_1 = 1U, /*!< DVOLT value option 1, the value may differ on different platforms */
69     kTSI_DvoltOption_2 = 2U, /*!< DVOLT value option 2, the value may differ on different platforms */
70     kTSI_DvoltOption_3 = 3U  /*!< DVOLT value option 3, the value may differ on different platforms */
71 } tsi_dvolt_option_t;
72 
73 /*!
74  * @brief TSI sensitivity ajustment (XDN option).
75  *
76  * These constants define the tsi sensitivity ajustment in self-cap mode, when TSI_MODE[S_SEN] = 1.
77  */
78 typedef enum _tsi_sensitivity_xdn_option
79 {
80     kTSI_SensitivityXdnOption_0 = 0U, /*!< Adjust sensitivity in self-cap mode, 1/16 */
81     kTSI_SensitivityXdnOption_1 = 1U, /*!< Adjust sensitivity in self-cap mode, 1/8  */
82     kTSI_SensitivityXdnOption_2 = 2U, /*!< Adjust sensitivity in self-cap mode, 1/4  */
83     kTSI_SensitivityXdnOption_3 = 3U, /*!< Adjust sensitivity in self-cap mode, 1/2  */
84 #if defined(FSL_FEATURE_TSI_S_XDN_HAS_THREE_VALID_BITS) && FSL_FEATURE_TSI_S_XDN_HAS_THREE_VALID_BITS
85     kTSI_SensitivityXdnOption_4 = 4U, /*!< Adjust sensitivity in self-cap mode, 1/1  */
86     kTSI_SensitivityXdnOption_5 = 5U, /*!< Adjust sensitivity in self-cap mode, 2/1  */
87     kTSI_SensitivityXdnOption_6 = 6U, /*!< Adjust sensitivity in self-cap mode, 4/1  */
88     kTSI_SensitivityXdnOption_7 = 7U, /*!< Adjust sensitivity in self-cap mode, 8/1  */
89 #endif
90 } tsi_sensitivity_xdn_option_t;
91 
92 #if (defined(FSL_FEATURE_TSI_HAS_SHIELD_REGISTER) && FSL_FEATURE_TSI_HAS_SHIELD_REGISTER)
93 /*!
94  * @brief TSI Shield setting (TSI SHIELD register).
95  *
96  * These constants define the TSI channel used as shiel channel for HW shielding functionality.
97  * One channel can be selected direclty or more channels can be selected using OR logic.
98  * The bitfield is determinde for device KE17Z9 supporting 24 channels for shielding functionality.
99  */
100 typedef enum _tsi_shield
101 {
102     kTSI_shieldAllOff = 0x00000000U, /*!< No shiled channel used */
103     kTSI_ShieldSel0   = 0x00000001U, /*!< TSI channel  0 is configured as shield channel */
104     kTSI_ShieldSel1   = 0x00000002U, /*!< TSI channel  1 is configured as shield channel */
105     kTSI_ShieldSel2   = 0x00000004U, /*!< TSI channel  2 is configured as shield channel */
106     kTSI_ShieldSel3   = 0x00000008U, /*!< TSI channel  3 is configured as shield channel */
107     kTSI_ShieldSel4   = 0x00000010U, /*!< TSI channel  4 is configured as shield channel */
108     kTSI_ShieldSel5   = 0x00000020U, /*!< TSI channel  5 is configured as shield channel */
109     kTSI_ShieldSel6   = 0x00000040U, /*!< TSI channel  6 is configured as shield channel */
110     kTSI_ShieldSel7   = 0x00000080U, /*!< TSI channel  7 is configured as shield channel */
111     kTSI_ShieldSel8   = 0x00000100U, /*!< TSI channel  8 is configured as shield channel */
112     kTSI_ShieldSel9   = 0x00000200U, /*!< TSI channel  9 is configured as shield channel */
113     kTSI_ShieldSel10  = 0x00000400U, /*!< TSI channel 10 is configured as shield channel */
114     kTSI_ShieldSel11  = 0x00000800U, /*!< TSI channel 11 is configured as shield channel */
115     kTSI_ShieldSel12  = 0x00001000U, /*!< TSI channel 12 is configured as shield channel */
116     kTSI_ShieldSel13  = 0x00002000U, /*!< TSI channel 13 is configured as shield channel */
117     kTSI_ShieldSel14  = 0x00004000U, /*!< TSI channel 14 is configured as shield channel */
118     kTSI_ShieldSel15  = 0x00008000U, /*!< TSI channel 15 is configured as shield channel */
119     kTSI_ShieldSel16  = 0x00010000U, /*!< TSI channel 16 is configured as shield channel */
120     kTSI_ShieldSel17  = 0x00020000U, /*!< TSI channel 17 is configured as shield channel */
121     kTSI_ShieldSel18  = 0x00040000U, /*!< TSI channel 18 is configured as shield channel */
122     kTSI_ShieldSel19  = 0x00080000U, /*!< TSI channel 19 is configured as shield channel */
123     kTSI_ShieldSel20  = 0x00100000U, /*!< TSI channel 20 is configured as shield channel */
124     kTSI_ShieldSel21  = 0x00200000U, /*!< TSI channel 21 is configured as shield channel */
125     kTSI_ShieldSel22  = 0x00400000U, /*!< TSI channel 22 is configured as shield channel */
126     kTSI_ShieldSel23  = 0x00800000U, /*!< TSI channel 23 is configured as shield channel */
127     kTSI_ShieldSel24  = 0x01000000U, /*!< TSI channel 24 is configured as shield channel */
128 } tsi_shield_t;
129 #else
130 /*!
131  * @brief TSI Shield setting (S_W_SHIELD option).
132  *
133  * These constants define the shield pin used for HW shielding functionality. One or more shield pin can be selected.
134  * The involved bitfield is not fix can change from device to device (KE16Z7 and KE17Z7 support 3 shield pins, other KE
135  * serials only support 1 shield pin).
136  */
137 typedef enum _tsi_shield
138 {
139     kTSI_shieldAllOff  = 0U, /*!< No pin used */
140     kTSI_shield0On     = 1U, /*!< Shield 0   pin used */
141     kTSI_shield1On     = 2U, /*!< Shield 1   pin used */
142     kTSI_shield1and0On = 3U, /*!< Shield 0,1 pins used */
143     kTSI_shield2On     = 4U, /*!< Shield 2   pin used */
144     kTSI_shield2and0On = 5U, /*!< Shield 2,0 pins used */
145     kTSI_shield2and1On = 6U, /*!< Shield 2,1 pins used */
146     kTSI_shieldAllOn   = 7U, /*!< Shield 2,1,0 pins used */
147 } tsi_shield_t;
148 #endif
149 
150 /*!
151  * @brief TSI sensitivity ajustment (CTRIM option).
152  *
153  * These constants define the tsi sensitivity ajustment in self-cap mode, when TSI_MODE[S_SEN] = 1.
154  */
155 typedef enum _tsi_sensitivity_ctrim_option
156 {
157     kTSI_SensitivityCtrimOption_0 = 0U, /*!< Adjust sensitivity in self-cap mode, 2.5p  */
158     kTSI_SensitivityCtrimOption_1 = 1U, /*!< Adjust sensitivity in self-cap mode, 5.0p  */
159     kTSI_SensitivityCtrimOption_2 = 2U, /*!< Adjust sensitivity in self-cap mode, 7.5p  */
160     kTSI_SensitivityCtrimOption_3 = 3U, /*!< Adjust sensitivity in self-cap mode, 10.0p */
161     kTSI_SensitivityCtrimOption_4 = 4U, /*!< Adjust sensitivity in self-cap mode, 12.5p */
162     kTSI_SensitivityCtrimOption_5 = 5U, /*!< Adjust sensitivity in self-cap mode, 15.0p */
163     kTSI_SensitivityCtrimOption_6 = 6U, /*!< Adjust sensitivity in self-cap mode, 17.5p */
164     kTSI_SensitivityCtrimOption_7 = 7U, /*!< Adjust sensitivity in self-cap mode, 20.0p */
165 } tsi_sensitivity_ctrim_option_t;
166 
167 /*!
168  * @brief TSI current ajustment (Input current multiple).
169  *
170  * These constants set the tsi input current multiple in self-cap mode.
171  */
172 typedef enum _tsi_current_multiple_input
173 {
174     kTSI_CurrentMultipleInputValue_0 = 0U, /*!< Adjust input current multiple in self-cap mode, 1/8 */
175     kTSI_CurrentMultipleInputValue_1 = 1U, /*!< Adjust input current multiple in self-cap mode, 1/4 */
176 } tsi_current_multiple_input_t;
177 
178 /*!
179  * @brief TSI current ajustment (Charge/Discharge current multiple).
180  *
181  * These constants set the tsi charge/discharge current multiple in self-cap mode.
182  */
183 typedef enum _tsi_current_multiple_charge
184 {
185     kTSI_CurrentMultipleChargeValue_0 = 0U, /*!< Adjust charge/discharge current multiple in self-cap mode, 1/16 */
186     kTSI_CurrentMultipleChargeValue_1 = 1U, /*!< Adjust charge/discharge current multiple in self-cap mode, 1/8  */
187     kTSI_CurrentMultipleChargeValue_2 = 2U, /*!< Adjust charge/discharge current multiple in self-cap mode, 1/4  */
188     kTSI_CurrentMultipleChargeValue_3 = 3U, /*!< Adjust charge/discharge current multiple in self-cap mode, 1/2  */
189     kTSI_CurrentMultipleChargeValue_4 = 4U, /*!< Adjust charge/discharge current multiple in self-cap mode, 1/1  */
190     kTSI_CurrentMultipleChargeValue_5 = 5U, /*!< Adjust charge/discharge current multiple in self-cap mode, 2/1  */
191     kTSI_CurrentMultipleChargeValue_6 = 6U, /*!< Adjust charge/discharge current multiple in self-cap mode, 4/1  */
192     kTSI_CurrentMultipleChargeValue_7 = 7U, /*!< Adjust charge/discharge current multiple in self-cap mode, 8/1  */
193 } tsi_current_multiple_charge_t;
194 
195 /*!
196  * @brief TSI current used in vref generator
197  *
198  * These constants Choose the current used in vref generator.
199  */
200 typedef enum _tsi_mutual_pre_current
201 {
202     kTSI_MutualPreCurrent_1uA = 0U, /*!< Vref generator current is 1uA, used in mutual-cap mode */
203     kTSI_MutualPreCurrent_2uA = 1U, /*!< Vref generator current is 2uA, used in mutual-cap mode */
204     kTSI_MutualPreCurrent_3uA = 2U, /*!< Vref generator current is 3uA, used in mutual-cap mode */
205     kTSI_MutualPreCurrent_4uA = 3U, /*!< Vref generator current is 4uA, used in mutual-cap mode */
206     kTSI_MutualPreCurrent_5uA = 4U, /*!< Vref generator current is 5uA, used in mutual-cap mode */
207     kTSI_MutualPreCurrent_6uA = 5U, /*!< Vref generator current is 6uA, used in mutual-cap mode */
208     kTSI_MutualPreCurrent_7uA = 6U, /*!< Vref generator current is 7uA, used in mutual-cap mode */
209     kTSI_MutualPreCurrent_8uA = 7U  /*!< Vref generator current is 8uA, used in mutual-cap mode */
210 } tsi_mutual_pre_current_t;
211 
212 /*!
213  * @brief TSI resistor used in pre-charge
214  *
215  * These constants Choose the resistor used in pre-charge.
216  */
217 typedef enum _tsi_mutual_pre_resistor
218 {
219     kTSI_MutualPreResistor_1k = 0U, /*!< Vref generator resistor is 1k, used in mutual-cap mode */
220     kTSI_MutualPreResistor_2k = 1U, /*!< Vref generator resistor is 2k, used in mutual-cap mode */
221     kTSI_MutualPreResistor_3k = 2U, /*!< Vref generator resistor is 3k, used in mutual-cap mode */
222     kTSI_MutualPreResistor_4k = 3U, /*!< Vref generator resistor is 4k, used in mutual-cap mode */
223     kTSI_MutualPreResistor_5k = 4U, /*!< Vref generator resistor is 5k, used in mutual-cap mode */
224     kTSI_MutualPreResistor_6k = 5U, /*!< Vref generator resistor is 6k, used in mutual-cap mode */
225     kTSI_MutualPreResistor_7k = 6U, /*!< Vref generator resistor is 7k, used in mutual-cap mode */
226     kTSI_MutualPreResistor_8k = 7U  /*!< Vref generator resistor is 8k, used in mutual-cap mode */
227 } tsi_mutual_pre_resistor_t;
228 
229 /*!
230  * @brief TSI resistor used in I-sense generator
231  *
232  * These constants Choose the resistor used in I-sense generator.
233  */
234 typedef enum _tsi_mutual_sense_resistor
235 {
236     kTSI_MutualSenseResistor_2k5  = 0U,  /*!< I-sense resistor is 2.5k , used in mutual-cap mode */
237     kTSI_MutualSenseResistor_5k   = 1U,  /*!< I-sense resistor is 5.0k , used in mutual-cap mode */
238     kTSI_MutualSenseResistor_7k5  = 2U,  /*!< I-sense resistor is 7.5k , used in mutual-cap mode */
239     kTSI_MutualSenseResistor_10k  = 3U,  /*!< I-sense resistor is 10.0k, used in mutual-cap mode */
240     kTSI_MutualSenseResistor_12k5 = 4U,  /*!< I-sense resistor is 12.5k, used in mutual-cap mode */
241     kTSI_MutualSenseResistor_15k  = 5U,  /*!< I-sense resistor is 15.0k, used in mutual-cap mode */
242     kTSI_MutualSenseResistor_17k5 = 6U,  /*!< I-sense resistor is 17.5k, used in mutual-cap mode */
243     kTSI_MutualSenseResistor_20k  = 7U,  /*!< I-sense resistor is 20.0k, used in mutual-cap mode */
244     kTSI_MutualSenseResistor_22k5 = 8U,  /*!< I-sense resistor is 22.5k, used in mutual-cap mode */
245     kTSI_MutualSenseResistor_25k  = 9U,  /*!< I-sense resistor is 25.0k, used in mutual-cap mode */
246     kTSI_MutualSenseResistor_27k5 = 10U, /*!< I-sense resistor is 27.5k, used in mutual-cap mode */
247     kTSI_MutualSenseResistor_30k  = 11U, /*!< I-sense resistor is 30.0k, used in mutual-cap mode */
248     kTSI_MutualSenseResistor_32k5 = 12U, /*!< I-sense resistor is 32.5k, used in mutual-cap mode */
249     kTSI_MutualSenseResistor_35k  = 13U, /*!< I-sense resistor is 35.0k, used in mutual-cap mode */
250     kTSI_MutualSenseResistor_37k5 = 14U, /*!< I-sense resistor is 37.5k, used in mutual-cap mode */
251     kTSI_MutualSenseResistor_40k  = 15U  /*!< I-sense resistor is 40.0k, used in mutual-cap mode */
252 } tsi_mutual_sense_resistor_t;
253 
254 /*!
255  * @brief TSI TX channel selection in mutual-cap mode
256  *
257  * These constants Choose the TX channel used in mutual-cap mode.
258  */
259 typedef enum _tsi_mutual_tx_channel
260 {
261     kTSI_MutualTxChannel_0 = 0U, /*!< Select channel 0 as tx0, used in mutual-cap mode */
262     kTSI_MutualTxChannel_1 = 1U, /*!< Select channel 1 as tx1, used in mutual-cap mode */
263     kTSI_MutualTxChannel_2 = 2U, /*!< Select channel 2 as tx2, used in mutual-cap mode */
264     kTSI_MutualTxChannel_3 = 3U, /*!< Select channel 3 as tx3, used in mutual-cap mode */
265     kTSI_MutualTxChannel_4 = 4U, /*!< Select channel 4 as tx4, used in mutual-cap mode */
266     kTSI_MutualTxChannel_5 = 5U, /*!< Select channel 5 as tx5, used in mutual-cap mode */
267 } tsi_mutual_tx_channel_t;
268 
269 /*!
270  * @brief TSI RX channel selection in mutual-cap mode
271  *
272  * These constants Choose the RX channel used in mutual-cap mode.
273  */
274 typedef enum _tsi_mutual_rx_channel
275 {
276     kTSI_MutualRxChannel_6  = 0U, /*!< Select channel 6  as rx6, used in mutual-cap mode */
277     kTSI_MutualRxChannel_7  = 1U, /*!< Select channel 7  as rx7, used in mutual-cap mode */
278     kTSI_MutualRxChannel_8  = 2U, /*!< Select channel 8  as rx8, used in mutual-cap mode */
279     kTSI_MutualRxChannel_9  = 3U, /*!< Select channel 9  as rx9, used in mutual-cap mode */
280     kTSI_MutualRxChannel_10 = 4U, /*!< Select channel 10 as rx10, used in mutual-cap mode */
281     kTSI_MutualRxChannel_11 = 5U, /*!< Select channel 11 as rx11, used in mutual-cap mode */
282 } tsi_mutual_rx_channel_t;
283 
284 /*!
285  * @brief TSI sensitivity boost current settings
286  *
287  * These constants set the sensitivity boost current.
288  */
289 typedef enum _tsi_mutual_sense_boost_current
290 {
291     kTSI_MutualSenseBoostCurrent_0uA  = 0U,  /*!< Sensitivity boost current is 0uA , used in mutual-cap mode */
292     kTSI_MutualSenseBoostCurrent_2uA  = 1U,  /*!< Sensitivity boost current is 2uA , used in mutual-cap mode */
293     kTSI_MutualSenseBoostCurrent_4uA  = 2U,  /*!< Sensitivity boost current is 4uA , used in mutual-cap mode */
294     kTSI_MutualSenseBoostCurrent_6uA  = 3U,  /*!< Sensitivity boost current is 6uA , used in mutual-cap mode */
295     kTSI_MutualSenseBoostCurrent_8uA  = 4U,  /*!< Sensitivity boost current is 8uA , used in mutual-cap mode */
296     kTSI_MutualSenseBoostCurrent_10uA = 5U,  /*!< Sensitivity boost current is 10uA, used in mutual-cap mode */
297     kTSI_MutualSenseBoostCurrent_12uA = 6U,  /*!< Sensitivity boost current is 12uA, used in mutual-cap mode */
298     kTSI_MutualSenseBoostCurrent_14uA = 7U,  /*!< Sensitivity boost current is 14uA, used in mutual-cap mode */
299     kTSI_MutualSenseBoostCurrent_16uA = 8U,  /*!< Sensitivity boost current is 16uA, used in mutual-cap mode */
300     kTSI_MutualSenseBoostCurrent_18uA = 9U,  /*!< Sensitivity boost current is 18uA, used in mutual-cap mode */
301     kTSI_MutualSenseBoostCurrent_20uA = 10U, /*!< Sensitivity boost current is 20uA, used in mutual-cap mode */
302     kTSI_MutualSenseBoostCurrent_22uA = 11U, /*!< Sensitivity boost current is 22uA, used in mutual-cap mode */
303     kTSI_MutualSenseBoostCurrent_24uA = 12U, /*!< Sensitivity boost current is 24uA, used in mutual-cap mode */
304     kTSI_MutualSenseBoostCurrent_26uA = 13U, /*!< Sensitivity boost current is 26uA, used in mutual-cap mode */
305     kTSI_MutualSenseBoostCurrent_28uA = 14U, /*!< Sensitivity boost current is 28uA, used in mutual-cap mode */
306     kTSI_MutualSenseBoostCurrent_30uA = 15U, /*!< Sensitivity boost current is 30uA, used in mutual-cap mode */
307     kTSI_MutualSenseBoostCurrent_32uA = 16U, /*!< Sensitivity boost current is 32uA, used in mutual-cap mode */
308     kTSI_MutualSenseBoostCurrent_34uA = 17U, /*!< Sensitivity boost current is 34uA, used in mutual-cap mode */
309     kTSI_MutualSenseBoostCurrent_36uA = 18U, /*!< Sensitivity boost current is 36uA, used in mutual-cap mode */
310     kTSI_MutualSenseBoostCurrent_38uA = 19U, /*!< Sensitivity boost current is 38uA, used in mutual-cap mode */
311     kTSI_MutualSenseBoostCurrent_40uA = 20U, /*!< Sensitivity boost current is 40uA, used in mutual-cap mode */
312     kTSI_MutualSenseBoostCurrent_42uA = 21U, /*!< Sensitivity boost current is 42uA, used in mutual-cap mode */
313     kTSI_MutualSenseBoostCurrent_44uA = 22U, /*!< Sensitivity boost current is 44uA, used in mutual-cap mode */
314     kTSI_MutualSenseBoostCurrent_46uA = 23U, /*!< Sensitivity boost current is 46uA, used in mutual-cap mode */
315     kTSI_MutualSenseBoostCurrent_48uA = 24U, /*!< Sensitivity boost current is 48uA, used in mutual-cap mode */
316     kTSI_MutualSenseBoostCurrent_50uA = 25U, /*!< Sensitivity boost current is 50uA, used in mutual-cap mode */
317     kTSI_MutualSenseBoostCurrent_52uA = 26U, /*!< Sensitivity boost current is 52uA, used in mutual-cap mode */
318     kTSI_MutualSenseBoostCurrent_54uA = 27U, /*!< Sensitivity boost current is 54uA, used in mutual-cap mode */
319     kTSI_MutualSenseBoostCurrent_56uA = 28U, /*!< Sensitivity boost current is 56uA, used in mutual-cap mode */
320     kTSI_MutualSenseBoostCurrent_58uA = 29U, /*!< Sensitivity boost current is 58uA, used in mutual-cap mode */
321     kTSI_MutualSenseBoostCurrent_60uA = 30U, /*!< Sensitivity boost current is 60uA, used in mutual-cap mode */
322     kTSI_MutualSenseBoostCurrent_62uA = 31U  /*!< Sensitivity boost current is 62uA, used in mutual-cap mode */
323 } tsi_mutual_sense_boost_current_t;
324 
325 /*!
326  * @brief TSI TX drive mode control
327  *
328  * These constants Choose the TX drive mode control setting.
329  */
330 typedef enum _tsi_mutual_tx_drive_mode
331 {
332     kTSI_MutualTxDriveModeOption_0 = 0U, /*!< TX drive mode is -5v ~ +5v, used in mutual-cap mode */
333     kTSI_MutualTxDriveModeOption_1 = 1U, /*!< TX drive mode is  0v ~ +5v, used in mutual-cap mode */
334 } tsi_mutual_tx_drive_mode_t;
335 
336 /*!
337  * @brief TSI Pmos current mirror selection on the left side
338  *
339  * These constants set the Pmos current mirror on the left side used in mutual-cap mode.
340  */
341 typedef enum _tsi_mutual_pmos_current_left
342 {
343     kTSI_MutualPmosCurrentMirrorLeft_4  = 0U, /*!< Set Pmos current mirror left value as 4,  used in mutual-cap mode */
344     kTSI_MutualPmosCurrentMirrorLeft_8  = 1U, /*!< Set Pmos current mirror left value as 8,  used in mutual-cap mode */
345     kTSI_MutualPmosCurrentMirrorLeft_12 = 2U, /*!< Set Pmos current mirror left value as 12, used in mutual-cap mode */
346     kTSI_MutualPmosCurrentMirrorLeft_16 = 3U, /*!< Set Pmos current mirror left value as 16, used in mutual-cap mode */
347     kTSI_MutualPmosCurrentMirrorLeft_20 = 4U, /*!< Set Pmos current mirror left value as 20, used in mutual-cap mode */
348     kTSI_MutualPmosCurrentMirrorLeft_24 = 5U, /*!< Set Pmos current mirror left value as 24, used in mutual-cap mode */
349     kTSI_MutualPmosCurrentMirrorLeft_28 = 6U, /*!< Set Pmos current mirror left value as 28, used in mutual-cap mode */
350     kTSI_MutualPmosCurrentMirrorLeft_32 = 7U, /*!< Set Pmos current mirror left value as 32, used in mutual-cap mode */
351 } tsi_mutual_pmos_current_left_t;
352 
353 /*!
354  * @brief TSI Pmos current mirror selection on the right side
355  *
356  * These constants set the Pmos current mirror on the right side used in mutual-cap mode.
357  */
358 typedef enum _tsi_mutual_pmos_current_right
359 {
360     kTSI_MutualPmosCurrentMirrorRight_1 = 0U, /*!< Set Pmos current mirror right value as 1, used in mutual-cap mode */
361     kTSI_MutualPmosCurrentMirrorRight_2 = 1U, /*!< Set Pmos current mirror right value as 2, used in mutual-cap mode */
362     kTSI_MutualPmosCurrentMirrorRight_3 = 2U, /*!< Set Pmos current mirror right value as 3, used in mutual-cap mode */
363     kTSI_MutualPmosCurrentMirrorRight_4 = 3U, /*!< Set Pmos current mirror right value as 4, used in mutual-cap mode */
364 } tsi_mutual_pmos_current_right_t;
365 
366 /*!
367  * @brief TSI Nmos current mirror selection
368  *
369  * These constants set the Nmos current mirror used in mutual-cap mode.
370  */
371 typedef enum _tsi_mutual_nmos_current
372 {
373     kTSI_MutualNmosCurrentMirror_1 = 0U, /*!< Set Nmos current mirror value as 1, used in mutual-cap mode */
374     kTSI_MutualNmosCurrentMirror_2 = 1U, /*!< Set Nmos current mirror value as 2, used in mutual-cap mode */
375     kTSI_MutualNmosCurrentMirror_3 = 2U, /*!< Set Nmos current mirror value as 3, used in mutual-cap mode */
376     kTSI_MutualNmosCurrentMirror_4 = 3U, /*!< Set Nmos current mirror value as 4, used in mutual-cap mode */
377 } tsi_mutual_nmos_current_t;
378 
379 /*!
380  * @brief TSI SINC cutoff divider setting
381  *
382  * These bits set the SINC cutoff divider.
383  */
384 typedef enum _tsi_sinc_cutoff_div
385 {
386     kTSI_SincCutoffDiv_1   = 0U, /*!< Set SINC cutoff divider as 1   */
387     kTSI_SincCutoffDiv_2   = 1U, /*!< Set SINC cutoff divider as 2   */
388     kTSI_SincCutoffDiv_4   = 2U, /*!< Set SINC cutoff divider as 4   */
389     kTSI_SincCutoffDiv_8   = 3U, /*!< Set SINC cutoff divider as 8   */
390     kTSI_SincCutoffDiv_16  = 4U, /*!< Set SINC cutoff divider as 16  */
391     kTSI_SincCutoffDiv_32  = 5U, /*!< Set SINC cutoff divider as 32  */
392     kTSI_SincCutoffDiv_64  = 6U, /*!< Set SINC cutoff divider as 64  */
393     kTSI_SincCutoffDiv_128 = 7U  /*!< Set SINC cutoff divider as 128 */
394 } tsi_sinc_cutoff_div_t;
395 
396 /*!
397  * @brief TSI SINC filter order setting
398  *
399  * These bits set the SINC filter order.
400  */
401 typedef enum _tsi_sinc_filter_order
402 {
403     kTSI_SincFilterOrder_1 = 0U, /*!< Use 1 order SINC filter */
404     kTSI_SincFilterOrder_2 = 1U, /*!< Use 1 order SINC filter */
405 } tsi_sinc_filter_order_t;
406 
407 /*!
408  * @brief TSI SINC decimation value setting
409  *
410  * These bits set the SINC decimation value.
411  */
412 typedef enum _tsi_sinc_decimation_value
413 {
414     kTSI_SincDecimationValue_1  = 0U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 1  triger period. */
415     kTSI_SincDecimationValue_2  = 1U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 2  triger period. */
416     kTSI_SincDecimationValue_3  = 2U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 3  triger period. */
417     kTSI_SincDecimationValue_4  = 3U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 4  triger period. */
418     kTSI_SincDecimationValue_5  = 4U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 5  triger period. */
419     kTSI_SincDecimationValue_6  = 5U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 6  triger period. */
420     kTSI_SincDecimationValue_7  = 6U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 7  triger period. */
421     kTSI_SincDecimationValue_8  = 7U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 8  triger period. */
422     kTSI_SincDecimationValue_9  = 8U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 9  triger period. */
423     kTSI_SincDecimationValue_10 = 9U,  /*!< The TSI_DATA[TSICH] bits is the counter value of 10 triger period. */
424     kTSI_SincDecimationValue_11 = 10U, /*!< The TSI_DATA[TSICH] bits is the counter value of 11 triger period. */
425     kTSI_SincDecimationValue_12 = 11U, /*!< The TSI_DATA[TSICH] bits is the counter value of 12 triger period. */
426     kTSI_SincDecimationValue_13 = 12U, /*!< The TSI_DATA[TSICH] bits is the counter value of 13 triger period. */
427     kTSI_SincDecimationValue_14 = 13U, /*!< The TSI_DATA[TSICH] bits is the counter value of 14 triger period. */
428     kTSI_SincDecimationValue_15 = 14U, /*!< The TSI_DATA[TSICH] bits is the counter value of 15 triger period. */
429     kTSI_SincDecimationValue_16 = 15U, /*!< The TSI_DATA[TSICH] bits is the counter value of 16 triger period. */
430     kTSI_SincDecimationValue_17 = 16U, /*!< The TSI_DATA[TSICH] bits is the counter value of 17 triger period. */
431     kTSI_SincDecimationValue_18 = 17U, /*!< The TSI_DATA[TSICH] bits is the counter value of 18 triger period. */
432     kTSI_SincDecimationValue_19 = 18U, /*!< The TSI_DATA[TSICH] bits is the counter value of 19 triger period. */
433     kTSI_SincDecimationValue_20 = 19U, /*!< The TSI_DATA[TSICH] bits is the counter value of 20 triger period. */
434     kTSI_SincDecimationValue_21 = 20U, /*!< The TSI_DATA[TSICH] bits is the counter value of 21 triger period. */
435     kTSI_SincDecimationValue_22 = 21U, /*!< The TSI_DATA[TSICH] bits is the counter value of 22 triger period. */
436     kTSI_SincDecimationValue_23 = 22U, /*!< The TSI_DATA[TSICH] bits is the counter value of 23 triger period. */
437     kTSI_SincDecimationValue_24 = 23U, /*!< The TSI_DATA[TSICH] bits is the counter value of 24 triger period. */
438     kTSI_SincDecimationValue_25 = 24U, /*!< The TSI_DATA[TSICH] bits is the counter value of 25 triger period. */
439     kTSI_SincDecimationValue_26 = 25U, /*!< The TSI_DATA[TSICH] bits is the counter value of 26 triger period. */
440     kTSI_SincDecimationValue_27 = 26U, /*!< The TSI_DATA[TSICH] bits is the counter value of 27 triger period. */
441     kTSI_SincDecimationValue_28 = 27U, /*!< The TSI_DATA[TSICH] bits is the counter value of 28 triger period. */
442     kTSI_SincDecimationValue_29 = 28U, /*!< The TSI_DATA[TSICH] bits is the counter value of 29 triger period. */
443     kTSI_SincDecimationValue_30 = 29U, /*!< The TSI_DATA[TSICH] bits is the counter value of 30 triger period. */
444     kTSI_SincDecimationValue_31 = 30U, /*!< The TSI_DATA[TSICH] bits is the counter value of 31 triger period. */
445     kTSI_SincDecimationValue_32 = 31U  /*!< The TSI_DATA[TSICH] bits is the counter value of 32 triger period. */
446 } tsi_sinc_decimation_value_t;
447 
448 /*!
449  * @brief TSI SSC output bit0's period setting(SSC0[CHARGE_NUM])
450  *
451  * These bits set the SSC output bit0's period setting.
452  */
453 typedef enum _tsi_ssc_charge_num
454 {
455     kTSI_SscChargeNumValue_1  = 0U,  /*!< The SSC output bit 0's period will be 1  clock cycle of system clock. */
456     kTSI_SscChargeNumValue_2  = 1U,  /*!< The SSC output bit 0's period will be 2  clock cycle of system clock. */
457     kTSI_SscChargeNumValue_3  = 2U,  /*!< The SSC output bit 0's period will be 3  clock cycle of system clock. */
458     kTSI_SscChargeNumValue_4  = 3U,  /*!< The SSC output bit 0's period will be 4  clock cycle of system clock. */
459     kTSI_SscChargeNumValue_5  = 4U,  /*!< The SSC output bit 0's period will be 5  clock cycle of system clock. */
460     kTSI_SscChargeNumValue_6  = 5U,  /*!< The SSC output bit 0's period will be 6  clock cycle of system clock. */
461     kTSI_SscChargeNumValue_7  = 6U,  /*!< The SSC output bit 0's period will be 7  clock cycle of system clock. */
462     kTSI_SscChargeNumValue_8  = 7U,  /*!< The SSC output bit 0's period will be 8  clock cycle of system clock. */
463     kTSI_SscChargeNumValue_9  = 8U,  /*!< The SSC output bit 0's period will be 9  clock cycle of system clock. */
464     kTSI_SscChargeNumValue_10 = 9U,  /*!< The SSC output bit 0's period will be 10 clock cycle of system clock. */
465     kTSI_SscChargeNumValue_11 = 10U, /*!< The SSC output bit 0's period will be 11 clock cycle of system clock. */
466     kTSI_SscChargeNumValue_12 = 11U, /*!< The SSC output bit 0's period will be 12 clock cycle of system clock. */
467     kTSI_SscChargeNumValue_13 = 12U, /*!< The SSC output bit 0's period will be 13 clock cycle of system clock. */
468     kTSI_SscChargeNumValue_14 = 13U, /*!< The SSC output bit 0's period will be 14 clock cycle of system clock. */
469     kTSI_SscChargeNumValue_15 = 14U, /*!< The SSC output bit 0's period will be 15 clock cycle of system clock. */
470     kTSI_SscChargeNumValue_16 = 15U, /*!< The SSC output bit 0's period will be 16 clock cycle of system clock. */
471 } tsi_ssc_charge_num_t;
472 
473 /*!
474  * @brief TSI SSC output bit1's period setting(SSC0[BASE_NOCHARGE_NUM])
475  *
476  * These bits set the SSC output bit1's period setting.
477  */
478 typedef enum _tsi_ssc_nocharge_num
479 {
480     kTSI_SscNoChargeNumValue_1 = 0U, /*!< The SSC output bit 1's basic period will be 1  clock cycle of system clock. */
481     kTSI_SscNoChargeNumValue_2 = 1U, /*!< The SSC output bit 1's basic period will be 2  clock cycle of system clock. */
482     kTSI_SscNoChargeNumValue_3 = 2U, /*!< The SSC output bit 1's basic period will be 3  clock cycle of system clock. */
483     kTSI_SscNoChargeNumValue_4 = 3U, /*!< The SSC output bit 1's basic period will be 4  clock cycle of system clock. */
484     kTSI_SscNoChargeNumValue_5 = 4U, /*!< The SSC output bit 1's basic period will be 5  clock cycle of system clock. */
485     kTSI_SscNoChargeNumValue_6 = 5U, /*!< The SSC output bit 1's basic period will be 6  clock cycle of system clock. */
486     kTSI_SscNoChargeNumValue_7 = 6U, /*!< The SSC output bit 1's basic period will be 7  clock cycle of system clock. */
487     kTSI_SscNoChargeNumValue_8 = 7U, /*!< The SSC output bit 1's basic period will be 8  clock cycle of system clock. */
488     kTSI_SscNoChargeNumValue_9 = 8U, /*!< The SSC output bit 1's basic period will be 9  clock cycle of system clock. */
489     kTSI_SscNoChargeNumValue_10 =
490         9U,                          /*!< The SSC output bit 1's basic period will be 10 clock cycle of system clock. */
491     kTSI_SscNoChargeNumValue_11 =
492         10U,                         /*!< The SSC output bit 1's basic period will be 11 clock cycle of system clock. */
493     kTSI_SscNoChargeNumValue_12 =
494         11U,                         /*!< The SSC output bit 1's basic period will be 12 clock cycle of system clock. */
495     kTSI_SscNoChargeNumValue_13 =
496         12U,                         /*!< The SSC output bit 1's basic period will be 13 clock cycle of system clock. */
497     kTSI_SscNoChargeNumValue_14 =
498         13U,                         /*!< The SSC output bit 1's basic period will be 14 clock cycle of system clock. */
499     kTSI_SscNoChargeNumValue_15 =
500         14U,                         /*!< The SSC output bit 1's basic period will be 15 clock cycle of system clock. */
501     kTSI_SscNoChargeNumValue_16 =
502         15U,                         /*!< The SSC output bit 1's basic period will be 16 clock cycle of system clock. */
503 } tsi_ssc_nocharge_num_t;
504 
505 /*!
506  * @brief TSI SSC outsel choosing the length of the PRBS (Pseudo-RandomBinarySequence) method
507  * setting(SSC0[TSI_SSC0_PRBS_OUTSEL])
508  *
509  * These bits set the SSC PRBS length.
510  */
511 typedef enum _tsi_ssc_prbs_outsel
512 {
513     kTSI_SscPrbsOutsel_2  = 2U,  /*!< The length of the PRBS is 2. */
514     kTSI_SscPrbsOutsel_3  = 3U,  /*!< The length of the PRBS is 3. */
515     kTSI_SscPrbsOutsel_4  = 4U,  /*!< The length of the PRBS is 4. */
516     kTSI_SscPrbsOutsel_5  = 5U,  /*!< The length of the PRBS is 5. */
517     kTSI_SscPrbsOutsel_6  = 6U,  /*!< The length of the PRBS is 6. */
518     kTSI_SscPrbsOutsel_7  = 7U,  /*!< The length of the PRBS is 7. */
519     kTSI_SscPrbsOutsel_8  = 8U,  /*!< The length of the PRBS is 8. */
520     kTSI_SscPrbsOutsel_9  = 9U,  /*!< The length of the PRBS is 9. */
521     kTSI_SscPrbsOutsel_10 = 10U, /*!< The length of the PRBS is 10. */
522     kTSI_SscPrbsOutsel_11 = 11U, /*!< The length of the PRBS is 11. */
523     kTSI_SscPrbsOutsel_12 = 12U, /*!< The length of the PRBS is 12. */
524     kTSI_SscPrbsOutsel_13 = 13U, /*!< The length of the PRBS is 13. */
525     kTSI_SscPrbsOutsel_14 = 14U, /*!< The length of the PRBS is 14. */
526     kTSI_SscPrbsOutsel_15 = 15U, /*!< The length of the PRBS is 15. */
527 } tsi_ssc_prbs_outsel_t;
528 
529 /*! @brief TSI status flags. */
530 typedef enum _tsi_status_flags
531 {
532     kTSI_EndOfScanFlag  = TSI_GENCS_EOSF_MASK,       /*!< End-Of-Scan flag */
533     kTSI_OutOfRangeFlag = (int)TSI_GENCS_OUTRGF_MASK /*!< Out-Of-Range flag */
534 } tsi_status_flags_t;
535 
536 /*! @brief TSI feature interrupt source.*/
537 typedef enum _tsi_interrupt_enable
538 {
539     kTSI_GlobalInterruptEnable     = 1U, /*!< TSI module global interrupt */
540     kTSI_OutOfRangeInterruptEnable = 2U, /*!< Out-Of-Range interrupt */
541     kTSI_EndOfScanInterruptEnable  = 4U  /*!< End-Of-Scan interrupt */
542 } tsi_interrupt_enable_t;
543 
544 /*!
545  * @brief TSI SSC mode selection.
546  *
547  * These constants set the SSC mode.
548  */
549 typedef enum _tsi_ssc_mode
550 {
551     kTSI_ssc_prbs_method     = 0U, /*!< Using PRBS method generating SSC output bit. */
552     kTSI_ssc_up_down_counter = 1U, /*!< Using up-down counter generating SSC output bit. */
553     kTSI_ssc_disable         = 2U, /*!< SSC function is disabled. */
554 } tsi_ssc_mode_t;
555 
556 /*!
557  * @brief TSI main clock selection.
558  *
559  * These constants set select the divider ratio for the clock used for generating the SSC output bit.
560  */
561 typedef enum _tsi_ssc_prescaler
562 {
563     kTSI_ssc_div_by_1   = 0x0U,  /*!< Set SSC divider to 00000000 div1(2^0) */
564     kTSI_ssc_div_by_2   = 0x1U,  /*!< Set SSC divider to 00000001 div2(2^1) */
565     kTSI_ssc_div_by_4   = 0x3U,  /*!< Set SSC divider to 00000011 div4(2^2) */
566     kTSI_ssc_div_by_8   = 0x7U,  /*!< Set SSC divider to 00000111 div8(2^3) */
567     kTSI_ssc_div_by_16  = 0xfU,  /*!< Set SSC divider to 00001111 div16(2^4) */
568     kTSI_ssc_div_by_32  = 0x1fU, /*!< Set SSC divider to 00011111 div32(2^5) */
569     kTSI_ssc_div_by_64  = 0x3fU, /*!< Set SSC divider to 00111111 div64(2^6) */
570     kTSI_ssc_div_by_128 = 0x7fU, /*!< Set SSC divider to 01111111 div128(2^7) */
571     kTSI_ssc_div_by_256 = 0xffU, /*!< Set SSC divider to 11111111 div256(2^8) */
572 } tsi_ssc_prescaler_t;
573 
574 /*! @brief TSI calibration data storage. */
575 typedef struct _tsi_calibration_data
576 {
577     uint16_t calibratedData[FSL_FEATURE_TSI_CHANNEL_COUNT]; /*!< TSI calibration data storage buffer */
578 } tsi_calibration_data_t;
579 
580 /*!
581  * @brief TSI common configuration structure
582  *
583  * This structure contains the common settings for TSI self-cap or mutual-cap mode, configurations including
584  * the TSI module main clock, sensing mode, DVOLT options, SINC and SSC configurations.
585  */
586 typedef struct _tsi_common_config
587 {
588     tsi_main_clock_selection_t mainClock;   /*!< Set main clock. */
589     tsi_sensing_mode_selection_t mode;      /*!< Choose sensing mode. */
590     tsi_dvolt_option_t dvolt;               /*!< DVOLT option value.  */
591     tsi_sinc_cutoff_div_t cutoff;           /*!< Cutoff divider.  */
592     tsi_sinc_filter_order_t order;          /*!< SINC filter order. */
593     tsi_sinc_decimation_value_t decimation; /*!< SINC decimation value. */
594     tsi_ssc_charge_num_t chargeNum;         /*!< SSC High Width (t1), SSC output bit0's period setting. */
595     tsi_ssc_prbs_outsel_t prbsOutsel;   /*!< SSC High Random Width (t2), length of PRBS(Pseudo-RandomBinarySequence),SSC
596                                            output bit2's period setting. */
597     tsi_ssc_nocharge_num_t noChargeNum; /*!< SSC Low Width (t3), SSC output bit1's period setting. */
598     tsi_ssc_mode_t ssc_mode;            /*!< Clock mode selection (basic - from main clock by divider,advanced - using
599                                            SSC(Switching Speed Clock) by three configurable intervals. */
600     tsi_ssc_prescaler_t ssc_prescaler;  /*!< Set clock divider for basic mode. */
601 } tsi_common_config_t;
602 
603 /*!
604  * @brief TSI configuration structure for self-cap mode
605  *
606  * This structure contains the settings for the most common TSI self-cap configurations including
607  * the TSI module charge currents, sensitivity configuration and so on.
608  */
609 typedef struct _tsi_selfCap_config
610 {
611     tsi_common_config_t commonConfig;            /*!< Common settings.          */
612     bool enableSensitivity;                      /*!< Enable sensitivity boost of self-cap or not. */
613     tsi_shield_t enableShield;                   /*!< Enable shield of self-cap mode or not. */
614     tsi_sensitivity_xdn_option_t xdn;            /*!< Sensitivity XDN option.   */
615     tsi_sensitivity_ctrim_option_t ctrim;        /*!< Sensitivity CTRIM option. */
616     tsi_current_multiple_input_t inputCurrent;   /*!< Input current multiple.   */
617     tsi_current_multiple_charge_t chargeCurrent; /*!< Charge/Discharge current multiple. */
618 } tsi_selfCap_config_t;
619 
620 /*!
621  * @brief TSI configuration structure for mutual-cap mode
622  *
623  * This structure contains the settings for the most common TSI mutual-cap configurations including
624  * the TSI module generator settings, sensitivity related current settings and so on.
625  */
626 typedef struct _tsi_mutualCap_config
627 {
628     tsi_common_config_t commonConfig;                 /*!< Common settings.          */
629     tsi_mutual_pre_current_t preCurrent;              /*!< Vref generator current.  */
630     tsi_mutual_pre_resistor_t preResistor;            /*!< Vref generator resistor. */
631     tsi_mutual_sense_resistor_t senseResistor;        /*!< I-sense generator resistor. */
632     tsi_mutual_sense_boost_current_t boostCurrent;    /*!< Sensitivity boost current setting. */
633     tsi_mutual_tx_drive_mode_t txDriveMode;           /*!< TX drive mode control setting. */
634     tsi_mutual_pmos_current_left_t pmosLeftCurrent;   /*!< Pmos current mirror on the left side.  */
635     tsi_mutual_pmos_current_right_t pmosRightCurrent; /*!< Pmos current mirror on the right side. */
636     bool enableNmosMirror;                            /*!< Enable Nmos current mirror setting or not. */
637     tsi_mutual_nmos_current_t nmosCurrent;            /*!< Nmos current mirror setting. */
638 } tsi_mutualCap_config_t;
639 
640 /*******************************************************************************
641  * API
642  ******************************************************************************/
643 
644 #ifdef __cplusplus
645 extern "C" {
646 #endif
647 
648 /*!
649  * @brief Get the TSI instance from peripheral base address.
650  *
651  * @param base TSI peripheral base address.
652  * @return TSI instance.
653  */
654 uint32_t TSI_GetInstance(TSI_Type *base);
655 
656 /*!
657  * @brief Initialize hardware to Self-cap mode.
658  *
659  * @details Initialize the peripheral to the targeted state specified by parameter config,
660  *          such as sets sensitivity adjustment, current settings.
661  * @param  base    TSI peripheral base address.
662  * @param  config  Pointer to TSI self-cap configuration structure.
663  * @return none
664  */
665 void TSI_InitSelfCapMode(TSI_Type *base, const tsi_selfCap_config_t *config);
666 
667 /*!
668  * @brief Initialize hardware to Mutual-cap mode.
669  *
670  * @details Initialize the peripheral to the targeted state specified by parameter config,
671  *          such as sets Vref generator setting, sensitivity boost settings, Pmos/Nmos settings.
672  * @param  base    TSI peripheral base address.
673  * @param  config  Pointer to TSI mutual-cap configuration structure.
674  * @return none
675  */
676 void TSI_InitMutualCapMode(TSI_Type *base, const tsi_mutualCap_config_t *config);
677 
678 /*!
679  * @brief De-initialize hardware.
680  *
681  * @details De-initialize the peripheral to default state.
682  *
683  * @param  base  TSI peripheral base address.
684  * @return none
685  */
686 void TSI_Deinit(TSI_Type *base);
687 
688 /*!
689  * @brief Get TSI self-cap mode user configure structure.
690  * This interface sets userConfig structure to a default value. The configuration structure only
691  * includes the settings for the whole TSI.
692  * The user configure is set to a value:
693  * @code
694     userConfig->commonConfig.mainClock     = kTSI_MainClockSlection_0;
695     userConfig->commonConfig.mode          = kTSI_SensingModeSlection_Self;
696     userConfig->commonConfig.dvolt         = kTSI_DvoltOption_2;
697     userConfig->commonConfig.cutoff        = kTSI_SincCutoffDiv_1;
698     userConfig->commonConfig.order         = kTSI_SincFilterOrder_1;
699     userConfig->commonConfig.decimation    = kTSI_SincDecimationValue_8;
700     userConfig->commonConfig.chargeNum     = kTSI_SscChargeNumValue_3;
701     userConfig->commonConfig.prbsOutsel    = kTSI_SscPrbsOutsel_2;
702     userConfig->commonConfig.noChargeNum   = kTSI_SscNoChargeNumValue_2;
703     userConfig->commonConfig.ssc_mode      = kTSI_ssc_prbs_method;
704     userConfig->commonConfig.ssc_prescaler = kTSI_ssc_div_by_1;
705     userConfig->enableSensitivity          = true;
706     userConfig->enableShield               = false;
707     userConfig->xdn                        = kTSI_SensitivityXdnOption_1;
708     userConfig->ctrim                      = kTSI_SensitivityCtrimOption_7;
709     userConfig->inputCurrent               = kTSI_CurrentMultipleInputValue_0;
710     userConfig->chargeCurrent              = kTSI_CurrentMultipleChargeValue_1;
711    @endcode
712  *
713  * @param userConfig Pointer to TSI user configure structure.
714  */
715 void TSI_GetSelfCapModeDefaultConfig(tsi_selfCap_config_t *userConfig);
716 
717 /*!
718  * @brief Get TSI mutual-cap mode default user configure structure.
719  * This interface sets userConfig structure to a default value. The configuration structure only
720  * includes the settings for the whole TSI.
721  * The user configure is set to a value:
722  * @code
723     userConfig->commonConfig.mainClock     = kTSI_MainClockSlection_1;
724     userConfig->commonConfig.mode          = kTSI_SensingModeSlection_Mutual;
725     userConfig->commonConfig.dvolt         = kTSI_DvoltOption_0;
726     userConfig->commonConfig.cutoff        = kTSI_SincCutoffDiv_1;
727     userConfig->commonConfig.order         = kTSI_SincFilterOrder_1;
728     userConfig->commonConfig.decimation    = kTSI_SincDecimationValue_8;
729     userConfig->commonConfig.chargeNum     = kTSI_SscChargeNumValue_4;
730     userConfig->commonConfig.prbsOutsel    = kTSI_SscPrbsOutsel_2;
731     userConfig->commonConfig.noChargeNum   = kTSI_SscNoChargeNumValue_5;
732     userConfig->commonConfig.ssc_mode      = kTSI_ssc_prbs_method;
733     userConfig->commonConfig.ssc_prescaler = kTSI_ssc_div_by_1;
734     userConfig->preCurrent                 = kTSI_MutualPreCurrent_4uA;
735     userConfig->preResistor                = kTSI_MutualPreResistor_4k;
736     userConfig->senseResistor              = kTSI_MutualSenseResistor_10k;
737     userConfig->boostCurrent               = kTSI_MutualSenseBoostCurrent_0uA;
738     userConfig->txDriveMode                = kTSI_MutualTxDriveModeOption_0;
739     userConfig->pmosLeftCurrent            = kTSI_MutualPmosCurrentMirrorLeft_32;
740     userConfig->pmosRightCurrent           = kTSI_MutualPmosCurrentMirrorRight_1;
741     userConfig->enableNmosMirror           = true;
742     userConfig->nmosCurrent                = kTSI_MutualNmosCurrentMirror_1;
743    @endcode
744  *
745  * @param userConfig Pointer to TSI user configure structure.
746  */
747 void TSI_GetMutualCapModeDefaultConfig(tsi_mutualCap_config_t *userConfig);
748 
749 /*!
750  * @brief Hardware base counter value for calibration.
751  *
752  * @details Calibrate the peripheral to fetch the initial counter value of
753  *          the enabled channels.
754  *          This API is mostly used at initial application setup, it shall be called
755  *          after the TSI_Init API, then user can use the calibrated
756  *          counter values to setup applications(such as to determine
757  *          under which counter value we can confirm a touch event occurs).
758  *
759  * @param   base    TSI peripheral base address.
760  * @param   calBuff Data buffer that store the calibrated counter value.
761  * @return  none
762  * @note    This API is mainly used for self-cap mode;
763  * @note    The calibration work in mutual-cap mode shall be done in applications due to different board layout.
764  *
765  */
766 void TSI_SelfCapCalibrate(TSI_Type *base, tsi_calibration_data_t *calBuff);
767 
768 /*!
769  * @brief Enables TSI interrupt requests.
770  * @param base TSI peripheral base address.
771  * @param mask interrupt source
772  *     The parameter can be combination of the following source if defined:
773  *     @arg kTSI_GlobalInterruptEnable
774  *     @arg kTSI_EndOfScanInterruptEnable
775  *     @arg kTSI_OutOfRangeInterruptEnable
776  */
777 void TSI_EnableInterrupts(TSI_Type *base, uint32_t mask);
778 
779 /*!
780  * @brief Disables TSI interrupt requests.
781  * @param base TSI peripheral base address.
782  * @param mask interrupt source
783  *     The parameter can be combination of the following source if defined:
784  *     @arg kTSI_GlobalInterruptEnable
785  *     @arg kTSI_EndOfScanInterruptEnable
786  *     @arg kTSI_OutOfRangeInterruptEnable
787  */
788 void TSI_DisableInterrupts(TSI_Type *base, uint32_t mask);
789 
790 #if defined(FSL_FEATURE_TSI_HAS_SHIELD_REGISTER) && FSL_FEATURE_TSI_HAS_SHIELD_REGISTER
791 /*!
792  * @brief Enable/disable TSI shield channels.
793  * @param base TSI peripheral base address.
794  * @param channelsMask Channels mask, 1 means channel 0, 3 means channel 0 and channel 1.
795  * @param enable True means enable TSI shield channels, false means disable.
796  */
797 void TSI_EnableShieldChannels(TSI_Type *base, uint32_t channelsMask, bool enable);
798 
799 /*!
800  * @brief Set TSI shield channels.
801  * @param base TSI peripheral base address.
802  * @param channelsMask Channels mask, 0 means disable all channels, 3 means enable channel 1 and channel 2, disable other
803  * channels.
804  */
805 void TSI_ShieldChannelConfig(TSI_Type *base, uint32_t channelsMask);
806 #endif
807 
808 /*!
809  * @brief Get interrupt flag.
810  * This function get tsi interrupt flags.
811  *
812  * @param    base  TSI peripheral base address.
813  * @return         The mask of these status flags combination.
814  */
TSI_GetStatusFlags(TSI_Type * base)815 static inline uint32_t TSI_GetStatusFlags(TSI_Type *base)
816 {
817     return (base->GENCS & (uint32_t)((uint32_t)kTSI_EndOfScanFlag | (uint32_t)kTSI_OutOfRangeFlag));
818 }
819 
820 /*!
821  * @brief Clear interrupt flag.
822  *
823  * This function clear tsi interrupt flag,
824  * automatically cleared flags can not be cleared by this function.
825  *
826  * @param base TSI peripheral base address.
827  * @param mask The status flags to clear.
828  */
829 void TSI_ClearStatusFlags(TSI_Type *base, uint32_t mask);
830 
831 /*!
832  * @brief Get TSI scan trigger mode.
833  *
834  * @param  base  TSI peripheral base address.
835  * @return       Scan trigger mode.
836  */
TSI_GetScanTriggerMode(TSI_Type * base)837 static inline uint32_t TSI_GetScanTriggerMode(TSI_Type *base)
838 {
839     return (base->GENCS & TSI_GENCS_STM_MASK);
840 }
841 
842 /*!
843  * @brief Get scan in progress flag.
844  *
845  * @param    base TSI peripheral base address.
846  * @return   True  - scan is in progress.
847  *           False - scan is not in progress.
848  */
TSI_IsScanInProgress(TSI_Type * base)849 static inline bool TSI_IsScanInProgress(TSI_Type *base)
850 {
851     return (bool)(base->GENCS & TSI_GENCS_SCNIP_MASK);
852 }
853 
854 /*!
855  * @brief Enables the TSI Module or not.
856  *
857  * @param   base   TSI peripheral base address.
858  * @param   enable Choose whether to enable or disable module;
859  *                 - true   Enable TSI module;
860  *                 - false  Disable TSI module;
861  * @return  none.
862  */
TSI_EnableModule(TSI_Type * base,bool enable)863 static inline void TSI_EnableModule(TSI_Type *base, bool enable)
864 {
865     if (enable)
866     {
867         base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) | TSI_GENCS_TSIEN_MASK; /* Enable module */
868     }
869     else
870     {
871         base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) & (~TSI_GENCS_TSIEN_MASK); /* Disable module */
872     }
873 }
874 
875 /*!
876  * @brief Sets the TSI low power STOP mode enable or not.
877  *        This enables TSI module function in low power modes.
878  *
879  * @param    base    TSI peripheral base address.
880  * @param    enable  Choose to enable or disable STOP mode.
881  *                   - true   Enable module in STOP mode;
882  *                   - false  Disable module in STOP mode;
883  * @return   none.
884  */
TSI_EnableLowPower(TSI_Type * base,bool enable)885 static inline void TSI_EnableLowPower(TSI_Type *base, bool enable)
886 {
887     if (enable)
888     {
889         base->GENCS =
890             (base->GENCS & ~ALL_FLAGS_MASK) | TSI_GENCS_STPE_MASK; /* Module enabled in low power stop modes */
891     }
892     else
893     {
894         base->GENCS =
895             (base->GENCS & ~ALL_FLAGS_MASK) & (~TSI_GENCS_STPE_MASK); /* Module disabled in low power stop modes */
896     }
897 }
898 
899 /*!
900  * @brief Enable the hardware trigger scan or not.
901  *
902  * @param    base TSI peripheral base address.
903  * @param    enable Choose to enable hardware trigger or software trigger scan.
904  *                  - true    Enable hardware trigger scan;
905  *                  - false   Enable software trigger scan;
906  * @return   none.
907  */
TSI_EnableHardwareTriggerScan(TSI_Type * base,bool enable)908 static inline void TSI_EnableHardwareTriggerScan(TSI_Type *base, bool enable)
909 {
910     if (enable)
911     {
912         base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) | TSI_GENCS_STM_MASK; /* Enable hardware trigger scan */
913     }
914     else
915     {
916         base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) & (~TSI_GENCS_STM_MASK); /* Enable software trigger scan */
917     }
918 }
919 
920 /*!
921  * @brief Start one sotware trigger measurement (trigger a new measurement).
922  *
923  * @param    base TSI peripheral base address.
924  * @return   none.
925  */
TSI_StartSoftwareTrigger(TSI_Type * base)926 static inline void TSI_StartSoftwareTrigger(TSI_Type *base)
927 {
928     base->DATA |= TSI_DATA_SWTS_MASK;
929 }
930 
931 /*!
932  * @brief Set the measured channel number for self-cap mode.
933  *
934  * @param    base    TSI peripheral base address.
935  * @param    channel Channel number 0 ... 24.
936  * @return   none.
937  * @note     This API can only be used in self-cap mode!
938  */
TSI_SetSelfCapMeasuredChannel(TSI_Type * base,uint8_t channel)939 static inline void TSI_SetSelfCapMeasuredChannel(TSI_Type *base, uint8_t channel)
940 {
941     assert(channel < (uint8_t)FSL_FEATURE_TSI_CHANNEL_COUNT);
942 
943     base->DATA = ((base->DATA) & ~TSI_DATA_TSICH_MASK) | (TSI_DATA_TSICH(channel));
944 }
945 
946 /*!
947  * @brief Get the current measured channel number, in self-cap mode.
948  *
949  * @param    base    TSI peripheral base address.
950  * @return   uint8_t    Channel number 0 ... 24.
951  * @note     This API can only be used in self-cap mode!
952  */
TSI_GetSelfCapMeasuredChannel(TSI_Type * base)953 static inline uint8_t TSI_GetSelfCapMeasuredChannel(TSI_Type *base)
954 {
955     return (uint8_t)((base->DATA & TSI_DATA_TSICH_MASK) >> TSI_DATA_TSICH_SHIFT);
956 }
957 
958 /*!
959  * @brief Enable DMA transfer or not.
960  *
961  * @param   base   TSI peripheral base address.
962  * @param   enable Choose to enable DMA transfer or not.
963  *                 - true    Enable DMA transfer;
964  *                 - false   Disable DMA transfer;
965  * @return  none.
966  */
TSI_EnableDmaTransfer(TSI_Type * base,bool enable)967 static inline void TSI_EnableDmaTransfer(TSI_Type *base, bool enable)
968 {
969     if (enable)
970     {
971         base->DATA |= TSI_DATA_DMAEN_MASK; /* Enable DMA transfer */
972     }
973     else
974     {
975         base->DATA &= ~TSI_DATA_DMAEN_MASK; /* Disable DMA transfer */
976     }
977 }
978 
979 #if defined(FSL_FEATURE_TSI_HAS_END_OF_SCAN_DMA_ENABLE) && (FSL_FEATURE_TSI_HAS_END_OF_SCAN_DMA_ENABLE == 1)
980 /*!
981  * @brief Decide whether to enable End of Scan DMA transfer request only.
982  *
983  * @param    base TSI peripheral base address.
984  * @param    enable  Choose whether to enable End of Scan DMA transfer request only.
985  *                   - true  Enable End of Scan DMA transfer request only;
986  *                   - false Both End-of-Scan and Out-of-Range can generate DMA transfer request.
987  * @return   none.
988  */
TSI_EnableEndOfScanDmaTransferOnly(TSI_Type * base,bool enable)989 static inline void TSI_EnableEndOfScanDmaTransferOnly(TSI_Type *base, bool enable)
990 {
991     if (enable)
992     {
993         base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) |
994                       TSI_GENCS_EOSDMEO_MASK; /* Enable End of Scan DMA transfer request only; */
995     }
996     else
997     {
998         base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) &
999                       (~TSI_GENCS_EOSDMEO_MASK); /* Both types of events can generate DMA transfer request. */
1000     }
1001 }
1002 #endif /* End of (FSL_FEATURE_TSI_HAS_END_OF_SCAN_DMA_ENABLE == 1)*/
1003 
1004 /*!
1005  * @brief Gets the conversion counter value.
1006  *
1007  * @param    base TSI peripheral base address.
1008  * @return   Accumulated scan counter value ticked by the reference clock.
1009  */
TSI_GetCounter(TSI_Type * base)1010 static inline uint16_t TSI_GetCounter(TSI_Type *base)
1011 {
1012     return (uint16_t)(base->DATA & TSI_DATA_TSICNT_MASK);
1013 }
1014 
1015 /*!
1016  * @brief Set the TSI wake-up channel low threshold.
1017  *
1018  * @param    base           TSI peripheral base address.
1019  * @param    low_threshold  Low counter threshold.
1020  * @return   none.
1021  */
TSI_SetLowThreshold(TSI_Type * base,uint16_t low_threshold)1022 static inline void TSI_SetLowThreshold(TSI_Type *base, uint16_t low_threshold)
1023 {
1024     base->TSHD = ((base->TSHD) & ~TSI_TSHD_THRESL_MASK) | (TSI_TSHD_THRESL(low_threshold));
1025 }
1026 
1027 /*!
1028  * @brief Set the TSI wake-up channel high threshold.
1029  *
1030  * @param    base            TSI peripheral base address.
1031  * @param    high_threshold  High counter threshold.
1032  * @return   none.
1033  */
TSI_SetHighThreshold(TSI_Type * base,uint16_t high_threshold)1034 static inline void TSI_SetHighThreshold(TSI_Type *base, uint16_t high_threshold)
1035 {
1036     base->TSHD = ((base->TSHD) & ~TSI_TSHD_THRESH_MASK) | (TSI_TSHD_THRESH(high_threshold));
1037 }
1038 
1039 /*!
1040  * @brief Set the main clock of the TSI module.
1041  *
1042  * @param    base   TSI peripheral base address.
1043  * @param    mainClock   clock option value.
1044  * @return   none.
1045  */
TSI_SetMainClock(TSI_Type * base,tsi_main_clock_selection_t mainClock)1046 static inline void TSI_SetMainClock(TSI_Type *base, tsi_main_clock_selection_t mainClock)
1047 {
1048     base->MODE = ((base->MODE) & ~TSI_MODE_SETCLK_MASK) | (TSI_MODE_SETCLK(mainClock));
1049 }
1050 
1051 /*!
1052  * @brief Set the sensing mode of the TSI module.
1053  *
1054  * @param    base   TSI peripheral base address.
1055  * @param    mode   Mode value.
1056  * @return   none.
1057  */
TSI_SetSensingMode(TSI_Type * base,tsi_sensing_mode_selection_t mode)1058 static inline void TSI_SetSensingMode(TSI_Type *base, tsi_sensing_mode_selection_t mode)
1059 {
1060     base->MODE = ((base->MODE) & ~TSI_MODE_MODE_MASK) | (TSI_MODE_MODE(mode));
1061 }
1062 
1063 /*!
1064  * @brief Get the sensing mode of the TSI module.
1065  *
1066  * @param    base   TSI peripheral base address.
1067  * @return   Currently selected sensing mode.
1068  */
TSI_GetSensingMode(TSI_Type * base)1069 static inline tsi_sensing_mode_selection_t TSI_GetSensingMode(TSI_Type *base)
1070 {
1071     return (tsi_sensing_mode_selection_t)(uint32_t)((base->MODE & TSI_MODE_MODE_MASK) >> TSI_MODE_MODE_SHIFT);
1072 }
1073 
1074 /*!
1075  * @brief Set the DVOLT settings.
1076  *
1077  * @param    base    TSI peripheral base address.
1078  * @param    dvolt   The voltage rails.
1079  * @return   none.
1080  */
TSI_SetDvolt(TSI_Type * base,tsi_dvolt_option_t dvolt)1081 static inline void TSI_SetDvolt(TSI_Type *base, tsi_dvolt_option_t dvolt)
1082 {
1083     base->GENCS = (base->GENCS & ~(TSI_GENCS_DVOLT_MASK | ALL_FLAGS_MASK)) | (TSI_GENCS_DVOLT(dvolt));
1084 }
1085 
1086 /*!
1087  * @brief Enable self-cap mode noise cancellation function or not.
1088  *
1089  * @param    base                TSI peripheral base address.
1090  * @param    enableCancellation  Choose whether to enable noise cancellation in self-cap mode
1091  *                               - true  Enable noise cancellation;
1092  *                               - false Disable noise cancellation;
1093  * @return   none.
1094  */
TSI_EnableNoiseCancellation(TSI_Type * base,bool enableCancellation)1095 static inline void TSI_EnableNoiseCancellation(TSI_Type *base, bool enableCancellation)
1096 {
1097     base->MODE = ((base->MODE) & ~TSI_MODE_S_NOISE_MASK) | (TSI_MODE_S_NOISE(enableCancellation));
1098 }
1099 
1100 /*!
1101  * @brief Set the mutual-cap mode TX channel.
1102  *
1103  * @param    base       TSI peripheral base address.
1104  * @param    txChannel  Mutual-cap mode TX channel number
1105  * @return   none.
1106  */
TSI_SetMutualCapTxChannel(TSI_Type * base,tsi_mutual_tx_channel_t txChannel)1107 static inline void TSI_SetMutualCapTxChannel(TSI_Type *base, tsi_mutual_tx_channel_t txChannel)
1108 {
1109     base->MUL0 = ((base->MUL0) & ~TSI_MUL0_M_SEL_TX_MASK) | (TSI_MUL0_M_SEL_TX(txChannel));
1110 }
1111 
1112 /*!
1113  * @brief Get the current measured TX channel number, in mutual-cap mode.
1114  *
1115  * @param    base    TSI peripheral base address;
1116  * @return           Tx Channel number 0 ... 5;
1117  * @note     This API can only be used in mutual-cap mode!
1118  */
TSI_GetTxMutualCapMeasuredChannel(TSI_Type * base)1119 static inline tsi_mutual_tx_channel_t TSI_GetTxMutualCapMeasuredChannel(TSI_Type *base)
1120 {
1121     return (tsi_mutual_tx_channel_t)(uint32_t)((base->MUL0 & TSI_MUL0_M_SEL_TX_MASK) >> TSI_MUL0_M_SEL_TX_SHIFT);
1122 }
1123 
1124 /*!
1125  * @brief Set the mutual-cap mode RX channel.
1126  *
1127  * @param    base       TSI peripheral base address.
1128  * @param    rxChannel  Mutual-cap mode RX channel number
1129  * @return   none.
1130  */
TSI_SetMutualCapRxChannel(TSI_Type * base,tsi_mutual_rx_channel_t rxChannel)1131 static inline void TSI_SetMutualCapRxChannel(TSI_Type *base, tsi_mutual_rx_channel_t rxChannel)
1132 {
1133     base->MUL0 = ((base->MUL0) & ~TSI_MUL0_M_SEL_RX_MASK) | (TSI_MUL0_M_SEL_RX(rxChannel));
1134 }
1135 
1136 /*!
1137  * @brief Get the current measured RX channel number, in mutual-cap mode.
1138  *
1139  * @param    base    TSI peripheral base address;
1140  * @return           Rx Channel number 6 ... 11;
1141  * @note     This API can only be used in mutual-cap mode!
1142  */
TSI_GetRxMutualCapMeasuredChannel(TSI_Type * base)1143 static inline tsi_mutual_rx_channel_t TSI_GetRxMutualCapMeasuredChannel(TSI_Type *base)
1144 {
1145     return (tsi_mutual_rx_channel_t)(uint32_t)((base->MUL0 & TSI_MUL0_M_SEL_RX_MASK) >> TSI_MUL0_M_SEL_RX_SHIFT);
1146 }
1147 
1148 /*!
1149  * @brief Set the SSC clock mode of the TSI module.
1150  *
1151  * @param    base   TSI peripheral base address.
1152  * @param    mode   SSC mode option value.
1153  * @return   none.
1154  */
TSI_SetSscMode(TSI_Type * base,tsi_ssc_mode_t mode)1155 static inline void TSI_SetSscMode(TSI_Type *base, tsi_ssc_mode_t mode)
1156 {
1157     base->SSC0 = ((base->SSC0) & ~TSI_SSC0_SSC_MODE_MASK) | (TSI_SSC0_SSC_MODE(mode));
1158 }
1159 
1160 /*!
1161  * @brief Set the SSC prescaler of the TSI module.
1162  *
1163  * @param    base   TSI peripheral base address.
1164  * @param    prescaler  SSC prescaler option value.
1165  * @return   none.
1166  */
TSI_SetSscPrescaler(TSI_Type * base,tsi_ssc_prescaler_t prescaler)1167 static inline void TSI_SetSscPrescaler(TSI_Type *base, tsi_ssc_prescaler_t prescaler)
1168 {
1169     base->SSC0 = ((base->SSC0) & ~TSI_SSC0_SSC_PRESCALE_NUM_MASK) | (TSI_SSC0_SSC_PRESCALE_NUM(prescaler));
1170 }
1171 
1172 #if (defined(FSL_FEATURE_TSI_HAS_M_TX_USED) && FSL_FEATURE_TSI_HAS_M_TX_USED)
1173 /*!
1174  * @brief Set used mutual-cap TX channel.
1175  *
1176  * @param    base       TSI peripheral base address.
1177  * @param    txChannel  Mutual-cap mode TX channel number
1178  * @return   none.
1179  */
TSI_SetUsedTxChannel(TSI_Type * base,tsi_mutual_tx_channel_t txChannel)1180 static inline void TSI_SetUsedTxChannel(TSI_Type *base, tsi_mutual_tx_channel_t txChannel)
1181 {
1182     base->MUL0 = (base->MUL0) | (TSI_MUL0_M_TX_USED(1UL << (uint8_t)txChannel));
1183 }
1184 
1185 /*!
1186  * @brief Clear used mutual-cap TX channel.
1187  *
1188  * @param    base       TSI peripheral base address.
1189  * @param    txChannel  Mutual-cap mode TX channel number
1190  * @return   none.
1191  */
TSI_ClearUsedTxChannel(TSI_Type * base,tsi_mutual_tx_channel_t txChannel)1192 static inline void TSI_ClearUsedTxChannel(TSI_Type *base, tsi_mutual_tx_channel_t txChannel)
1193 {
1194     base->MUL0 &= ~TSI_MUL0_M_TX_USED(1UL << (uint8_t)txChannel);
1195 }
1196 #endif
1197 
1198 #ifdef __cplusplus
1199 }
1200 #endif /* __cplusplus */
1201 
1202 /*! @}*/
1203 
1204 #endif /* FSL_TSI_V5_H_ */
1205