cc y / mbed

Fork of mbed by mbed official

Committer:
kaoshen
Date:
Tue Jan 17 23:27:32 2017 +0000
Revision:
135:fce8a9387ed1
Parent:
133:99b5ccf27215
333 ADS1115 ADC1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 132:9baf128c2fab 1 /*
<> 132:9baf128c2fab 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
<> 132:9baf128c2fab 3 * All rights reserved.
<> 132:9baf128c2fab 4 *
<> 132:9baf128c2fab 5 * Redistribution and use in source and binary forms, with or without modification,
<> 132:9baf128c2fab 6 * are permitted provided that the following conditions are met:
<> 132:9baf128c2fab 7 *
<> 132:9baf128c2fab 8 * o Redistributions of source code must retain the above copyright notice, this list
<> 132:9baf128c2fab 9 * of conditions and the following disclaimer.
<> 132:9baf128c2fab 10 *
<> 132:9baf128c2fab 11 * o Redistributions in binary form must reproduce the above copyright notice, this
<> 132:9baf128c2fab 12 * list of conditions and the following disclaimer in the documentation and/or
<> 132:9baf128c2fab 13 * other materials provided with the distribution.
<> 132:9baf128c2fab 14 *
<> 132:9baf128c2fab 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
<> 132:9baf128c2fab 16 * contributors may be used to endorse or promote products derived from this
<> 132:9baf128c2fab 17 * software without specific prior written permission.
<> 132:9baf128c2fab 18 *
<> 132:9baf128c2fab 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<> 132:9baf128c2fab 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
<> 132:9baf128c2fab 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 132:9baf128c2fab 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
<> 132:9baf128c2fab 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
<> 132:9baf128c2fab 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
<> 132:9baf128c2fab 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
<> 132:9baf128c2fab 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<> 132:9baf128c2fab 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
<> 132:9baf128c2fab 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 132:9baf128c2fab 29 */
<> 132:9baf128c2fab 30 #ifndef _FSL_TSI_V4_H_
<> 132:9baf128c2fab 31 #define _FSL_TSI_V4_H_
<> 132:9baf128c2fab 32
<> 132:9baf128c2fab 33 #include "fsl_common.h"
<> 132:9baf128c2fab 34
<> 132:9baf128c2fab 35 /*!
<> 132:9baf128c2fab 36 * @addtogroup tsi_v4_driver
<> 132:9baf128c2fab 37 * @{
<> 132:9baf128c2fab 38 */
<> 132:9baf128c2fab 39
<> 132:9baf128c2fab 40
<> 132:9baf128c2fab 41 /*******************************************************************************
<> 132:9baf128c2fab 42 * Definitions
<> 132:9baf128c2fab 43 ******************************************************************************/
<> 132:9baf128c2fab 44
<> 132:9baf128c2fab 45 /*! @name Driver version */
<> 132:9baf128c2fab 46 /*@{*/
<> 132:9baf128c2fab 47 /*! @brief TSI driver version */
<> 132:9baf128c2fab 48 #define FSL_TSI_DRIVER_VERSION (MAKE_VERSION(2, 1, 2))
<> 132:9baf128c2fab 49 /*@}*/
<> 132:9baf128c2fab 50
<> 132:9baf128c2fab 51 /*! @brief TSI status flags macro collection */
<> 132:9baf128c2fab 52 #define ALL_FLAGS_MASK (TSI_GENCS_EOSF_MASK | TSI_GENCS_OUTRGF_MASK)
<> 132:9baf128c2fab 53
<> 132:9baf128c2fab 54 /*! @brief resistor bit shift in EXTCHRG bit-field */
<> 132:9baf128c2fab 55 #define TSI_V4_EXTCHRG_RESISTOR_BIT_SHIFT TSI_GENCS_EXTCHRG_SHIFT
<> 132:9baf128c2fab 56
<> 132:9baf128c2fab 57 /*! @brief filter bits shift in EXTCHRG bit-field */
<> 132:9baf128c2fab 58 #define TSI_V4_EXTCHRG_FILTER_BITS_SHIFT (1U + TSI_GENCS_EXTCHRG_SHIFT)
<> 132:9baf128c2fab 59
<> 132:9baf128c2fab 60 /*! @brief macro of clearing the resistor bit in EXTCHRG bit-field */
<> 132:9baf128c2fab 61 #define TSI_V4_EXTCHRG_RESISTOR_BIT_CLEAR \
<> 132:9baf128c2fab 62 ((uint32_t)((~(ALL_FLAGS_MASK | TSI_GENCS_EXTCHRG_MASK)) | (3U << TSI_V4_EXTCHRG_FILTER_BITS_SHIFT)))
<> 132:9baf128c2fab 63
<> 132:9baf128c2fab 64 /*! @brief macro of clearing the filter bits in EXTCHRG bit-field */
<> 132:9baf128c2fab 65 #define TSI_V4_EXTCHRG_FILTER_BITS_CLEAR \
<> 132:9baf128c2fab 66 ((uint32_t)((~(ALL_FLAGS_MASK | TSI_GENCS_EXTCHRG_MASK)) | (1U << TSI_V4_EXTCHRG_RESISTOR_BIT_SHIFT)))
<> 132:9baf128c2fab 67
<> 132:9baf128c2fab 68 /*!
<> 132:9baf128c2fab 69 * @brief TSI number of scan intervals for each electrode.
<> 132:9baf128c2fab 70 *
<> 132:9baf128c2fab 71 * These constants define the tsi number of consecutive scans in a TSI instance for each electrode.
<> 132:9baf128c2fab 72 */
<> 132:9baf128c2fab 73 typedef enum _tsi_n_consecutive_scans
<> 132:9baf128c2fab 74 {
<> 132:9baf128c2fab 75 kTSI_ConsecutiveScansNumber_1time = 0U, /*!< Once per electrode */
<> 132:9baf128c2fab 76 kTSI_ConsecutiveScansNumber_2time = 1U, /*!< Twice per electrode */
<> 132:9baf128c2fab 77 kTSI_ConsecutiveScansNumber_3time = 2U, /*!< 3 times consecutive scan */
<> 132:9baf128c2fab 78 kTSI_ConsecutiveScansNumber_4time = 3U, /*!< 4 times consecutive scan */
<> 132:9baf128c2fab 79 kTSI_ConsecutiveScansNumber_5time = 4U, /*!< 5 times consecutive scan */
<> 132:9baf128c2fab 80 kTSI_ConsecutiveScansNumber_6time = 5U, /*!< 6 times consecutive scan */
<> 132:9baf128c2fab 81 kTSI_ConsecutiveScansNumber_7time = 6U, /*!< 7 times consecutive scan */
<> 132:9baf128c2fab 82 kTSI_ConsecutiveScansNumber_8time = 7U, /*!< 8 times consecutive scan */
<> 132:9baf128c2fab 83 kTSI_ConsecutiveScansNumber_9time = 8U, /*!< 9 times consecutive scan */
<> 132:9baf128c2fab 84 kTSI_ConsecutiveScansNumber_10time = 9U, /*!< 10 times consecutive scan */
<> 132:9baf128c2fab 85 kTSI_ConsecutiveScansNumber_11time = 10U, /*!< 11 times consecutive scan */
<> 132:9baf128c2fab 86 kTSI_ConsecutiveScansNumber_12time = 11U, /*!< 12 times consecutive scan */
<> 132:9baf128c2fab 87 kTSI_ConsecutiveScansNumber_13time = 12U, /*!< 13 times consecutive scan */
<> 132:9baf128c2fab 88 kTSI_ConsecutiveScansNumber_14time = 13U, /*!< 14 times consecutive scan */
<> 132:9baf128c2fab 89 kTSI_ConsecutiveScansNumber_15time = 14U, /*!< 15 times consecutive scan */
<> 132:9baf128c2fab 90 kTSI_ConsecutiveScansNumber_16time = 15U, /*!< 16 times consecutive scan */
<> 132:9baf128c2fab 91 kTSI_ConsecutiveScansNumber_17time = 16U, /*!< 17 times consecutive scan */
<> 132:9baf128c2fab 92 kTSI_ConsecutiveScansNumber_18time = 17U, /*!< 18 times consecutive scan */
<> 132:9baf128c2fab 93 kTSI_ConsecutiveScansNumber_19time = 18U, /*!< 19 times consecutive scan */
<> 132:9baf128c2fab 94 kTSI_ConsecutiveScansNumber_20time = 19U, /*!< 20 times consecutive scan */
<> 132:9baf128c2fab 95 kTSI_ConsecutiveScansNumber_21time = 20U, /*!< 21 times consecutive scan */
<> 132:9baf128c2fab 96 kTSI_ConsecutiveScansNumber_22time = 21U, /*!< 22 times consecutive scan */
<> 132:9baf128c2fab 97 kTSI_ConsecutiveScansNumber_23time = 22U, /*!< 23 times consecutive scan */
<> 132:9baf128c2fab 98 kTSI_ConsecutiveScansNumber_24time = 23U, /*!< 24 times consecutive scan */
<> 132:9baf128c2fab 99 kTSI_ConsecutiveScansNumber_25time = 24U, /*!< 25 times consecutive scan */
<> 132:9baf128c2fab 100 kTSI_ConsecutiveScansNumber_26time = 25U, /*!< 26 times consecutive scan */
<> 132:9baf128c2fab 101 kTSI_ConsecutiveScansNumber_27time = 26U, /*!< 27 times consecutive scan */
<> 132:9baf128c2fab 102 kTSI_ConsecutiveScansNumber_28time = 27U, /*!< 28 times consecutive scan */
<> 132:9baf128c2fab 103 kTSI_ConsecutiveScansNumber_29time = 28U, /*!< 29 times consecutive scan */
<> 132:9baf128c2fab 104 kTSI_ConsecutiveScansNumber_30time = 29U, /*!< 30 times consecutive scan */
<> 132:9baf128c2fab 105 kTSI_ConsecutiveScansNumber_31time = 30U, /*!< 31 times consecutive scan */
<> 132:9baf128c2fab 106 kTSI_ConsecutiveScansNumber_32time = 31U /*!< 32 times consecutive scan */
<> 132:9baf128c2fab 107 } tsi_n_consecutive_scans_t;
<> 132:9baf128c2fab 108
<> 132:9baf128c2fab 109 /*!
<> 132:9baf128c2fab 110 * @brief TSI electrode oscillator prescaler.
<> 132:9baf128c2fab 111 *
<> 132:9baf128c2fab 112 * These constants define the TSI electrode oscillator prescaler in a TSI instance.
<> 132:9baf128c2fab 113 */
<> 132:9baf128c2fab 114 typedef enum _tsi_electrode_osc_prescaler
<> 132:9baf128c2fab 115 {
<> 132:9baf128c2fab 116 kTSI_ElecOscPrescaler_1div = 0U, /*!< Electrode oscillator frequency divided by 1 */
<> 132:9baf128c2fab 117 kTSI_ElecOscPrescaler_2div = 1U, /*!< Electrode oscillator frequency divided by 2 */
<> 132:9baf128c2fab 118 kTSI_ElecOscPrescaler_4div = 2U, /*!< Electrode oscillator frequency divided by 4 */
<> 132:9baf128c2fab 119 kTSI_ElecOscPrescaler_8div = 3U, /*!< Electrode oscillator frequency divided by 8 */
<> 132:9baf128c2fab 120 kTSI_ElecOscPrescaler_16div = 4U, /*!< Electrode oscillator frequency divided by 16 */
<> 132:9baf128c2fab 121 kTSI_ElecOscPrescaler_32div = 5U, /*!< Electrode oscillator frequency divided by 32 */
<> 132:9baf128c2fab 122 kTSI_ElecOscPrescaler_64div = 6U, /*!< Electrode oscillator frequency divided by 64 */
<> 132:9baf128c2fab 123 kTSI_ElecOscPrescaler_128div = 7U /*!< Electrode oscillator frequency divided by 128 */
<> 132:9baf128c2fab 124 } tsi_electrode_osc_prescaler_t;
<> 132:9baf128c2fab 125
<> 132:9baf128c2fab 126 /*!
<> 132:9baf128c2fab 127 * @brief TSI analog mode select.
<> 132:9baf128c2fab 128 *
<> 132:9baf128c2fab 129 * Set up TSI analog modes in a TSI instance.
<> 132:9baf128c2fab 130 */
<> 132:9baf128c2fab 131 typedef enum _tsi_analog_mode
<> 132:9baf128c2fab 132 {
<> 132:9baf128c2fab 133 kTSI_AnalogModeSel_Capacitive = 0U, /*!< Active TSI capacitive sensing mode */
<> 132:9baf128c2fab 134 kTSI_AnalogModeSel_NoiseNoFreqLim = 4U, /*!< Single threshold noise detection mode with no freq. limitation. */
<> 132:9baf128c2fab 135 kTSI_AnalogModeSel_NoiseFreqLim = 8U, /*!< Single threshold noise detection mode with freq. limitation. */
<> 132:9baf128c2fab 136 kTSI_AnalogModeSel_AutoNoise = 12U /*!< Active TSI analog in automatic noise detection mode */
<> 132:9baf128c2fab 137 } tsi_analog_mode_t;
<> 132:9baf128c2fab 138
<> 132:9baf128c2fab 139 /*!
<> 132:9baf128c2fab 140 * @brief TSI Reference oscillator charge and discharge current select.
<> 132:9baf128c2fab 141 *
<> 132:9baf128c2fab 142 * These constants define the TSI Reference oscillator charge current select in a TSI (REFCHRG) instance.
<> 132:9baf128c2fab 143 */
<> 132:9baf128c2fab 144 typedef enum _tsi_reference_osc_charge_current
<> 132:9baf128c2fab 145 {
<> 132:9baf128c2fab 146 kTSI_RefOscChargeCurrent_500nA = 0U, /*!< Reference oscillator charge current is 500 µA */
<> 132:9baf128c2fab 147 kTSI_RefOscChargeCurrent_1uA = 1U, /*!< Reference oscillator charge current is 1 µA */
<> 132:9baf128c2fab 148 kTSI_RefOscChargeCurrent_2uA = 2U, /*!< Reference oscillator charge current is 2 µA */
<> 132:9baf128c2fab 149 kTSI_RefOscChargeCurrent_4uA = 3U, /*!< Reference oscillator charge current is 4 µA */
<> 132:9baf128c2fab 150 kTSI_RefOscChargeCurrent_8uA = 4U, /*!< Reference oscillator charge current is 8 µA */
<> 132:9baf128c2fab 151 kTSI_RefOscChargeCurrent_16uA = 5U, /*!< Reference oscillator charge current is 16 µA */
<> 132:9baf128c2fab 152 kTSI_RefOscChargeCurrent_32uA = 6U, /*!< Reference oscillator charge current is 32 µA */
<> 132:9baf128c2fab 153 kTSI_RefOscChargeCurrent_64uA = 7U /*!< Reference oscillator charge current is 64 µA */
<> 132:9baf128c2fab 154 } tsi_reference_osc_charge_current_t;
<> 132:9baf128c2fab 155
<> 132:9baf128c2fab 156 /*!
<> 132:9baf128c2fab 157 * @brief TSI oscilator's voltage rails.
<> 132:9baf128c2fab 158 *
<> 132:9baf128c2fab 159 * These bits indicate the oscillator's voltage rails.
<> 132:9baf128c2fab 160 */
<> 132:9baf128c2fab 161 typedef enum _tsi_osc_voltage_rails
<> 132:9baf128c2fab 162 {
<> 132:9baf128c2fab 163 kTSI_OscVolRailsOption_0 = 0U, /*!< DVOLT value option 0, the value may differ on different platforms */
<> 132:9baf128c2fab 164 kTSI_OscVolRailsOption_1 = 1U, /*!< DVOLT value option 1, the value may differ on different platforms */
<> 132:9baf128c2fab 165 kTSI_OscVolRailsOption_2 = 2U, /*!< DVOLT value option 2, the value may differ on different platforms */
<> 132:9baf128c2fab 166 kTSI_OscVolRailsOption_3 = 3U /*!< DVOLT value option 3, the value may differ on different platforms */
<> 132:9baf128c2fab 167 } tsi_osc_voltage_rails_t;
<> 132:9baf128c2fab 168
<> 132:9baf128c2fab 169 /*!
<> 132:9baf128c2fab 170 * @brief TSI External oscillator charge and discharge current select.
<> 132:9baf128c2fab 171 *
<> 132:9baf128c2fab 172 * These bits indicate the electrode oscillator charge and discharge current value
<> 132:9baf128c2fab 173 * in TSI (EXTCHRG) instance.
<> 132:9baf128c2fab 174 */
<> 132:9baf128c2fab 175 typedef enum _tsi_external_osc_charge_current
<> 132:9baf128c2fab 176 {
<> 132:9baf128c2fab 177 kTSI_ExtOscChargeCurrent_500nA = 0U, /*!< External oscillator charge current is 500 µA */
<> 132:9baf128c2fab 178 kTSI_ExtOscChargeCurrent_1uA = 1U, /*!< External oscillator charge current is 1 µA */
<> 132:9baf128c2fab 179 kTSI_ExtOscChargeCurrent_2uA = 2U, /*!< External oscillator charge current is 2 µA */
<> 132:9baf128c2fab 180 kTSI_ExtOscChargeCurrent_4uA = 3U, /*!< External oscillator charge current is 4 µA */
<> 132:9baf128c2fab 181 kTSI_ExtOscChargeCurrent_8uA = 4U, /*!< External oscillator charge current is 8 µA */
<> 132:9baf128c2fab 182 kTSI_ExtOscChargeCurrent_16uA = 5U, /*!< External oscillator charge current is 16 µA */
<> 132:9baf128c2fab 183 kTSI_ExtOscChargeCurrent_32uA = 6U, /*!< External oscillator charge current is 32 µA */
<> 132:9baf128c2fab 184 kTSI_ExtOscChargeCurrent_64uA = 7U /*!< External oscillator charge current is 64 µA */
<> 132:9baf128c2fab 185 } tsi_external_osc_charge_current_t;
<> 132:9baf128c2fab 186
<> 132:9baf128c2fab 187 /*!
<> 132:9baf128c2fab 188 * @brief TSI series resistance RS value select.
<> 132:9baf128c2fab 189 *
<> 132:9baf128c2fab 190 * These bits indicate the electrode RS series resistance for the noise mode
<> 132:9baf128c2fab 191 * in TSI (EXTCHRG) instance.
<> 132:9baf128c2fab 192 */
<> 132:9baf128c2fab 193 typedef enum _tsi_series_resistance
<> 132:9baf128c2fab 194 {
<> 132:9baf128c2fab 195 kTSI_SeriesResistance_32k = 0U, /*!< Series Resistance is 32 kilo ohms */
<> 132:9baf128c2fab 196 kTSI_SeriesResistance_187k = 1U /*!< Series Resistance is 18 7 kilo ohms */
<> 132:9baf128c2fab 197 } tsi_series_resistor_t;
<> 132:9baf128c2fab 198
<> 132:9baf128c2fab 199 /*!
<> 132:9baf128c2fab 200 * @brief TSI series filter bits select.
<> 132:9baf128c2fab 201 *
<> 132:9baf128c2fab 202 * These bits indicate the count of the filter bits
<> 132:9baf128c2fab 203 * in TSI noise mode EXTCHRG[2:1] bits
<> 132:9baf128c2fab 204 */
<> 132:9baf128c2fab 205 typedef enum _tsi_filter_bits
<> 132:9baf128c2fab 206 {
<> 132:9baf128c2fab 207 kTSI_FilterBits_3 = 0U, /*!< 3 filter bits, 8 peaks increments the cnt+1 */
<> 132:9baf128c2fab 208 kTSI_FilterBits_2 = 1U, /*!< 2 filter bits, 4 peaks increments the cnt+1 */
<> 132:9baf128c2fab 209 kTSI_FilterBits_1 = 2U, /*!< 1 filter bits, 2 peaks increments the cnt+1 */
<> 132:9baf128c2fab 210 kTSI_FilterBits_0 = 3U /*!< no filter bits,1 peak increments the cnt+1 */
<> 132:9baf128c2fab 211 } tsi_filter_bits_t;
<> 132:9baf128c2fab 212
<> 132:9baf128c2fab 213 /*! @brief TSI status flags. */
<> 132:9baf128c2fab 214 typedef enum _tsi_status_flags
<> 132:9baf128c2fab 215 {
<> 132:9baf128c2fab 216 kTSI_EndOfScanFlag = TSI_GENCS_EOSF_MASK, /*!< End-Of-Scan flag */
<> 132:9baf128c2fab 217 kTSI_OutOfRangeFlag = TSI_GENCS_OUTRGF_MASK /*!< Out-Of-Range flag */
<> 132:9baf128c2fab 218 } tsi_status_flags_t;
<> 132:9baf128c2fab 219
<> 132:9baf128c2fab 220 /*! @brief TSI feature interrupt source.*/
<> 132:9baf128c2fab 221 typedef enum _tsi_interrupt_enable
<> 132:9baf128c2fab 222 {
<> 132:9baf128c2fab 223 kTSI_GlobalInterruptEnable = 1U, /*!< TSI module global interrupt */
<> 132:9baf128c2fab 224 kTSI_OutOfRangeInterruptEnable = 2U, /*!< Out-Of-Range interrupt */
<> 132:9baf128c2fab 225 kTSI_EndOfScanInterruptEnable = 4U /*!< End-Of-Scan interrupt */
<> 132:9baf128c2fab 226 } tsi_interrupt_enable_t;
<> 132:9baf128c2fab 227
<> 132:9baf128c2fab 228 /*! @brief TSI calibration data storage. */
<> 132:9baf128c2fab 229 typedef struct _tsi_calibration_data
<> 132:9baf128c2fab 230 {
<> 132:9baf128c2fab 231 uint16_t calibratedData[FSL_FEATURE_TSI_CHANNEL_COUNT]; /*!< TSI calibration data storage buffer */
<> 132:9baf128c2fab 232 } tsi_calibration_data_t;
<> 132:9baf128c2fab 233
<> 132:9baf128c2fab 234 /*!
<> 132:9baf128c2fab 235 * @brief TSI configuration structure.
<> 132:9baf128c2fab 236 *
<> 132:9baf128c2fab 237 * This structure contains the settings for the most common TSI configurations including
<> 132:9baf128c2fab 238 * the TSI module charge currents, number of scans, thresholds, and so on.
<> 132:9baf128c2fab 239 */
<> 132:9baf128c2fab 240 typedef struct _tsi_config
<> 132:9baf128c2fab 241 {
<> 132:9baf128c2fab 242 uint16_t thresh; /*!< High threshold. */
<> 132:9baf128c2fab 243 uint16_t thresl; /*!< Low threshold. */
<> 132:9baf128c2fab 244 tsi_electrode_osc_prescaler_t prescaler; /*!< Prescaler */
<> 132:9baf128c2fab 245 tsi_external_osc_charge_current_t extchrg; /*!< Electrode charge current */
<> 132:9baf128c2fab 246 tsi_reference_osc_charge_current_t refchrg; /*!< Reference charge current */
<> 132:9baf128c2fab 247 tsi_n_consecutive_scans_t nscn; /*!< Number of scans. */
<> 132:9baf128c2fab 248 tsi_analog_mode_t mode; /*!< TSI mode of operation. */
<> 132:9baf128c2fab 249 tsi_osc_voltage_rails_t dvolt; /*!< Oscillator's voltage rails. */
<> 132:9baf128c2fab 250 tsi_series_resistor_t resistor; /*!< Series resistance value */
<> 132:9baf128c2fab 251 tsi_filter_bits_t filter; /*!< Noise mode filter bits */
<> 132:9baf128c2fab 252 } tsi_config_t;
<> 132:9baf128c2fab 253
<> 132:9baf128c2fab 254 /*******************************************************************************
<> 132:9baf128c2fab 255 * API
<> 132:9baf128c2fab 256 ******************************************************************************/
<> 132:9baf128c2fab 257
<> 132:9baf128c2fab 258 #ifdef __cplusplus
<> 132:9baf128c2fab 259 extern "C" {
<> 132:9baf128c2fab 260 #endif
<> 132:9baf128c2fab 261
<> 132:9baf128c2fab 262 /*!
<> 132:9baf128c2fab 263 * @brief Initializes hardware.
<> 132:9baf128c2fab 264 *
<> 132:9baf128c2fab 265 * @details Initializes the peripheral to the targeted state specified by parameter configuration,
<> 132:9baf128c2fab 266 * such as sets prescalers, number of scans, clocks, delta voltage
<> 132:9baf128c2fab 267 * series resistor, filter bits, reference, and electrode charge current and threshold.
<> 132:9baf128c2fab 268 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 269 * @param config Pointer to TSI module configuration structure.
<> 132:9baf128c2fab 270 * @return none
<> 132:9baf128c2fab 271 */
<> 132:9baf128c2fab 272 void TSI_Init(TSI_Type *base, const tsi_config_t *config);
<> 132:9baf128c2fab 273
<> 132:9baf128c2fab 274 /*!
<> 132:9baf128c2fab 275 * @brief De-initializes hardware.
<> 132:9baf128c2fab 276 *
<> 132:9baf128c2fab 277 * @details De-initializes the peripheral to default state.
<> 132:9baf128c2fab 278 *
<> 132:9baf128c2fab 279 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 280 * @return none
<> 132:9baf128c2fab 281 */
<> 132:9baf128c2fab 282 void TSI_Deinit(TSI_Type *base);
<> 132:9baf128c2fab 283
<> 132:9baf128c2fab 284 /*!
<> 132:9baf128c2fab 285 * @brief Gets the TSI normal mode user configuration structure.
<> 132:9baf128c2fab 286 * This interface sets userConfig structure to a default value. The configuration structure only
<> 132:9baf128c2fab 287 * includes the settings for the whole TSI.
<> 132:9baf128c2fab 288 * The user configure is set to these values:
<> 132:9baf128c2fab 289 * @code
<> 132:9baf128c2fab 290 userConfig->prescaler = kTSI_ElecOscPrescaler_2div;
<> 132:9baf128c2fab 291 userConfig->extchrg = kTSI_ExtOscChargeCurrent_4uA;
<> 132:9baf128c2fab 292 userConfig->refchrg = kTSI_RefOscChargeCurrent_4uA;
<> 132:9baf128c2fab 293 userConfig->nscn = kTSI_ConsecutiveScansNumber_10time;
<> 132:9baf128c2fab 294 userConfig->mode = kTSI_AnalogModeSel_Capacitive;
<> 132:9baf128c2fab 295 userConfig->dvolt = kTSI_OscVolRailsOption_0;
<> 132:9baf128c2fab 296 userConfig->resistor = kTSI_SeriesResistance_32k;
<> 132:9baf128c2fab 297 userConfig->filter = kTSI_FilterBits_1;
<> 132:9baf128c2fab 298 userConfig->thresh = 0U;
<> 132:9baf128c2fab 299 userConfig->thresl = 0U;
<> 132:9baf128c2fab 300 @endcode
<> 132:9baf128c2fab 301 *
<> 132:9baf128c2fab 302 * @param userConfig Pointer to the TSI user configuration structure.
<> 132:9baf128c2fab 303 */
<> 132:9baf128c2fab 304 void TSI_GetNormalModeDefaultConfig(tsi_config_t *userConfig);
<> 132:9baf128c2fab 305
<> 132:9baf128c2fab 306 /*!
<> 132:9baf128c2fab 307 * @brief Gets the TSI low power mode default user configuration structure.
<> 132:9baf128c2fab 308 * This interface sets userConfig structure to a default value. The configuration structure only
<> 132:9baf128c2fab 309 * includes the settings for the whole TSI.
<> 132:9baf128c2fab 310 * The user configure is set to these values:
<> 132:9baf128c2fab 311 * @code
<> 132:9baf128c2fab 312 userConfig->prescaler = kTSI_ElecOscPrescaler_2div;
<> 132:9baf128c2fab 313 userConfig->extchrg = kTSI_ExtOscChargeCurrent_4uA;
<> 132:9baf128c2fab 314 userConfig->refchrg = kTSI_RefOscChargeCurrent_4uA;
<> 132:9baf128c2fab 315 userConfig->nscn = kTSI_ConsecutiveScansNumber_10time;
<> 132:9baf128c2fab 316 userConfig->mode = kTSI_AnalogModeSel_Capacitive;
<> 132:9baf128c2fab 317 userConfig->dvolt = kTSI_OscVolRailsOption_0;
<> 132:9baf128c2fab 318 userConfig->resistor = kTSI_SeriesResistance_32k;
<> 132:9baf128c2fab 319 userConfig->filter = kTSI_FilterBits_1;
<> 132:9baf128c2fab 320 userConfig->thresh = 400U;
<> 132:9baf128c2fab 321 userConfig->thresl = 0U;
<> 132:9baf128c2fab 322 @endcode
<> 132:9baf128c2fab 323 *
<> 132:9baf128c2fab 324 * @param userConfig Pointer to the TSI user configuration structure.
<> 132:9baf128c2fab 325 */
<> 132:9baf128c2fab 326 void TSI_GetLowPowerModeDefaultConfig(tsi_config_t *userConfig);
<> 132:9baf128c2fab 327
<> 132:9baf128c2fab 328 /*!
<> 132:9baf128c2fab 329 * @brief Hardware calibration.
<> 132:9baf128c2fab 330 *
<> 132:9baf128c2fab 331 * @details Calibrates the peripheral to fetch the initial counter value of
<> 132:9baf128c2fab 332 * the enabled electrodes.
<> 132:9baf128c2fab 333 * This API is mostly used at initial application setup. Call
<> 132:9baf128c2fab 334 * this function after the \ref TSI_Init API and use the calibrated
<> 132:9baf128c2fab 335 * counter values to set up applications (such as to determine
<> 132:9baf128c2fab 336 * under which counter value we can confirm a touch event occurs).
<> 132:9baf128c2fab 337 *
<> 132:9baf128c2fab 338 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 339 * @param calBuff Data buffer that store the calibrated counter value.
<> 132:9baf128c2fab 340 * @return none
<> 132:9baf128c2fab 341 *
<> 132:9baf128c2fab 342 */
<> 132:9baf128c2fab 343 void TSI_Calibrate(TSI_Type *base, tsi_calibration_data_t *calBuff);
<> 132:9baf128c2fab 344
<> 132:9baf128c2fab 345 /*!
<> 132:9baf128c2fab 346 * @brief Enables the TSI interrupt requests.
<> 132:9baf128c2fab 347 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 348 * @param mask interrupt source
<> 132:9baf128c2fab 349 * The parameter can be combination of the following source if defined:
<> 132:9baf128c2fab 350 * @arg kTSI_GlobalInterruptEnable
<> 132:9baf128c2fab 351 * @arg kTSI_EndOfScanInterruptEnable
<> 132:9baf128c2fab 352 * @arg kTSI_OutOfRangeInterruptEnable
<> 132:9baf128c2fab 353 */
<> 132:9baf128c2fab 354 void TSI_EnableInterrupts(TSI_Type *base, uint32_t mask);
<> 132:9baf128c2fab 355
<> 132:9baf128c2fab 356 /*!
<> 132:9baf128c2fab 357 * @brief Disables the TSI interrupt requests.
<> 132:9baf128c2fab 358 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 359 * @param mask interrupt source
<> 132:9baf128c2fab 360 * The parameter can be combination of the following source if defined:
<> 132:9baf128c2fab 361 * @arg kTSI_GlobalInterruptEnable
<> 132:9baf128c2fab 362 * @arg kTSI_EndOfScanInterruptEnable
<> 132:9baf128c2fab 363 * @arg kTSI_OutOfRangeInterruptEnable
<> 132:9baf128c2fab 364 */
<> 132:9baf128c2fab 365 void TSI_DisableInterrupts(TSI_Type *base, uint32_t mask);
<> 132:9baf128c2fab 366
<> 132:9baf128c2fab 367 /*!
<> 132:9baf128c2fab 368 * @brief Gets an interrupt flag.
<> 132:9baf128c2fab 369 * This function gets the TSI interrupt flags.
<> 132:9baf128c2fab 370 *
<> 132:9baf128c2fab 371 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 372 * @return The mask of these status flags combination.
<> 132:9baf128c2fab 373 */
<> 132:9baf128c2fab 374 static inline uint32_t TSI_GetStatusFlags(TSI_Type *base)
<> 132:9baf128c2fab 375 {
<> 132:9baf128c2fab 376 return (base->GENCS & (kTSI_EndOfScanFlag | kTSI_OutOfRangeFlag));
<> 132:9baf128c2fab 377 }
<> 132:9baf128c2fab 378
<> 132:9baf128c2fab 379 /*!
<> 132:9baf128c2fab 380 * @brief Clears the interrupt flag.
<> 132:9baf128c2fab 381 *
<> 132:9baf128c2fab 382 * This function clears the TSI interrupt flag,
<> 132:9baf128c2fab 383 * automatically cleared flags can't be cleared by this function.
<> 132:9baf128c2fab 384 *
<> 132:9baf128c2fab 385 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 386 * @param mask The status flags to clear.
<> 132:9baf128c2fab 387 */
<> 132:9baf128c2fab 388 void TSI_ClearStatusFlags(TSI_Type *base, uint32_t mask);
<> 132:9baf128c2fab 389
<> 132:9baf128c2fab 390 /*!
<> 132:9baf128c2fab 391 * @brief Gets the TSI scan trigger mode.
<> 132:9baf128c2fab 392 *
<> 132:9baf128c2fab 393 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 394 * @return Scan trigger mode.
<> 132:9baf128c2fab 395 */
<> 132:9baf128c2fab 396 static inline uint32_t TSI_GetScanTriggerMode(TSI_Type *base)
<> 132:9baf128c2fab 397 {
<> 132:9baf128c2fab 398 return (base->GENCS & TSI_GENCS_STM_MASK);
<> 132:9baf128c2fab 399 }
<> 132:9baf128c2fab 400
<> 132:9baf128c2fab 401 /*!
<> 132:9baf128c2fab 402 * @brief Gets the scan in progress flag.
<> 132:9baf128c2fab 403 *
<> 132:9baf128c2fab 404 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 405 * @return True - scan is in progress.
<> 132:9baf128c2fab 406 * False - scan is not in progress.
<> 132:9baf128c2fab 407 */
<> 132:9baf128c2fab 408 static inline bool TSI_IsScanInProgress(TSI_Type *base)
<> 132:9baf128c2fab 409 {
<> 132:9baf128c2fab 410 return (base->GENCS & TSI_GENCS_SCNIP_MASK);
<> 132:9baf128c2fab 411 }
<> 132:9baf128c2fab 412
<> 132:9baf128c2fab 413 /*!
<> 132:9baf128c2fab 414 * @brief Sets the prescaler.
<> 132:9baf128c2fab 415 *
<> 132:9baf128c2fab 416 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 417 * @param prescaler Prescaler value.
<> 132:9baf128c2fab 418 * @return none.
<> 132:9baf128c2fab 419 */
<> 132:9baf128c2fab 420 static inline void TSI_SetElectrodeOSCPrescaler(TSI_Type *base, tsi_electrode_osc_prescaler_t prescaler)
<> 132:9baf128c2fab 421 {
<> 132:9baf128c2fab 422 base->GENCS = (base->GENCS & ~(TSI_GENCS_PS_MASK | ALL_FLAGS_MASK)) | (TSI_GENCS_PS(prescaler));
<> 132:9baf128c2fab 423 }
<> 132:9baf128c2fab 424
<> 132:9baf128c2fab 425 /*!
<> 132:9baf128c2fab 426 * @brief Sets the number of scans (NSCN).
<> 132:9baf128c2fab 427 *
<> 132:9baf128c2fab 428 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 429 * @param number Number of scans.
<> 132:9baf128c2fab 430 * @return none.
<> 132:9baf128c2fab 431 */
<> 132:9baf128c2fab 432 static inline void TSI_SetNumberOfScans(TSI_Type *base, tsi_n_consecutive_scans_t number)
<> 132:9baf128c2fab 433 {
<> 132:9baf128c2fab 434 base->GENCS = (base->GENCS & ~(TSI_GENCS_NSCN_MASK | ALL_FLAGS_MASK)) | (TSI_GENCS_NSCN(number));
<> 132:9baf128c2fab 435 }
<> 132:9baf128c2fab 436
<> 132:9baf128c2fab 437 /*!
<> 132:9baf128c2fab 438 * @brief Enables/disables the TSI module.
<> 132:9baf128c2fab 439 *
<> 132:9baf128c2fab 440 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 441 * @param enable Choose whether to enable or disable module;
<> 132:9baf128c2fab 442 * - true Enable TSI module;
<> 132:9baf128c2fab 443 * - false Disable TSI module;
<> 132:9baf128c2fab 444 * @return none.
<> 132:9baf128c2fab 445 */
<> 132:9baf128c2fab 446 static inline void TSI_EnableModule(TSI_Type *base, bool enable)
<> 132:9baf128c2fab 447 {
<> 132:9baf128c2fab 448 if (enable)
<> 132:9baf128c2fab 449 {
<> 132:9baf128c2fab 450 base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) | TSI_GENCS_TSIEN_MASK; /* Enable module */
<> 132:9baf128c2fab 451 }
<> 132:9baf128c2fab 452 else
<> 132:9baf128c2fab 453 {
<> 132:9baf128c2fab 454 base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) & (~TSI_GENCS_TSIEN_MASK); /* Disable module */
<> 132:9baf128c2fab 455 }
<> 132:9baf128c2fab 456 }
<> 132:9baf128c2fab 457
<> 132:9baf128c2fab 458 /*!
<> 132:9baf128c2fab 459 * @brief Sets the TSI low power STOP mode as enabled or disabled.
<> 132:9baf128c2fab 460 * This enables the TSI module function in low power modes.
<> 132:9baf128c2fab 461 *
<> 132:9baf128c2fab 462 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 463 * @param enable Choose to enable or disable STOP mode.
<> 132:9baf128c2fab 464 * - true Enable module in STOP mode;
<> 132:9baf128c2fab 465 * - false Disable module in STOP mode;
<> 132:9baf128c2fab 466 * @return none.
<> 132:9baf128c2fab 467 */
<> 132:9baf128c2fab 468 static inline void TSI_EnableLowPower(TSI_Type *base, bool enable)
<> 132:9baf128c2fab 469 {
<> 132:9baf128c2fab 470 if (enable)
<> 132:9baf128c2fab 471 {
<> 132:9baf128c2fab 472 base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) | TSI_GENCS_STPE_MASK; /* Module enabled in low power stop modes */
<> 132:9baf128c2fab 473 }
<> 132:9baf128c2fab 474 else
<> 132:9baf128c2fab 475 {
<> 132:9baf128c2fab 476 base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) & (~TSI_GENCS_STPE_MASK); /* Module disabled in low power stop modes */
<> 132:9baf128c2fab 477 }
<> 132:9baf128c2fab 478 }
<> 132:9baf128c2fab 479
<> 132:9baf128c2fab 480 /*!
<> 132:9baf128c2fab 481 * @brief Enables/disables the hardware trigger scan.
<> 132:9baf128c2fab 482 *
<> 132:9baf128c2fab 483 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 484 * @param enable Choose to enable hardware trigger or software trigger scan.
<> 132:9baf128c2fab 485 * - true Enable hardware trigger scan;
<> 132:9baf128c2fab 486 * - false Enable software trigger scan;
<> 132:9baf128c2fab 487 * @return none.
<> 132:9baf128c2fab 488 */
<> 132:9baf128c2fab 489 static inline void TSI_EnableHardwareTriggerScan(TSI_Type *base, bool enable)
<> 132:9baf128c2fab 490 {
<> 132:9baf128c2fab 491 if (enable)
<> 132:9baf128c2fab 492 {
<> 132:9baf128c2fab 493 base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) | TSI_GENCS_STM_MASK; /* Enable hardware trigger scan */
<> 132:9baf128c2fab 494 }
<> 132:9baf128c2fab 495 else
<> 132:9baf128c2fab 496 {
<> 132:9baf128c2fab 497 base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) & (~TSI_GENCS_STM_MASK); /* Enable software trigger scan */
<> 132:9baf128c2fab 498 }
<> 132:9baf128c2fab 499 }
<> 132:9baf128c2fab 500
<> 132:9baf128c2fab 501 /*!
<> 132:9baf128c2fab 502 * @brief Starts a software trigger measurement (triggers a new measurement).
<> 132:9baf128c2fab 503 *
<> 132:9baf128c2fab 504 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 505 * @return none.
<> 132:9baf128c2fab 506 */
<> 132:9baf128c2fab 507 static inline void TSI_StartSoftwareTrigger(TSI_Type *base)
<> 132:9baf128c2fab 508 {
<> 132:9baf128c2fab 509 base->DATA |= TSI_DATA_SWTS_MASK;
<> 132:9baf128c2fab 510 }
<> 132:9baf128c2fab 511
<> 132:9baf128c2fab 512 /*!
<> 132:9baf128c2fab 513 * @brief Sets the the measured channel number.
<> 132:9baf128c2fab 514 *
<> 132:9baf128c2fab 515 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 516 * @param channel Channel number 0 ... 15.
<> 132:9baf128c2fab 517 * @return none.
<> 132:9baf128c2fab 518 */
<> 132:9baf128c2fab 519 static inline void TSI_SetMeasuredChannelNumber(TSI_Type *base, uint8_t channel)
<> 132:9baf128c2fab 520 {
<> 132:9baf128c2fab 521 assert(channel < FSL_FEATURE_TSI_CHANNEL_COUNT);
<> 132:9baf128c2fab 522
<> 132:9baf128c2fab 523 base->DATA = ((base->DATA) & ~TSI_DATA_TSICH_MASK) | (TSI_DATA_TSICH(channel));
<> 132:9baf128c2fab 524 }
<> 132:9baf128c2fab 525
<> 132:9baf128c2fab 526 /*!
<> 132:9baf128c2fab 527 * @brief Gets the current measured channel number.
<> 132:9baf128c2fab 528 *
<> 132:9baf128c2fab 529 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 530 * @return uint8_t Channel number 0 ... 15.
<> 132:9baf128c2fab 531 */
<> 132:9baf128c2fab 532 static inline uint8_t TSI_GetMeasuredChannelNumber(TSI_Type *base)
<> 132:9baf128c2fab 533 {
<> 132:9baf128c2fab 534 return (uint8_t)((base->DATA & TSI_DATA_TSICH_MASK) >> TSI_DATA_TSICH_SHIFT);
<> 132:9baf128c2fab 535 }
<> 132:9baf128c2fab 536
<> 132:9baf128c2fab 537 /*!
<> 132:9baf128c2fab 538 * @brief Enables/disables the DMA transfer.
<> 132:9baf128c2fab 539 *
<> 132:9baf128c2fab 540 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 541 * @param enable Choose to enable DMA transfer or not.
<> 132:9baf128c2fab 542 * - true Enable DMA transfer;
<> 132:9baf128c2fab 543 * - false Disable DMA transfer;
<> 132:9baf128c2fab 544 * @return none.
<> 132:9baf128c2fab 545 */
<> 132:9baf128c2fab 546 static inline void TSI_EnableDmaTransfer(TSI_Type *base, bool enable)
<> 132:9baf128c2fab 547 {
<> 132:9baf128c2fab 548 if (enable)
<> 132:9baf128c2fab 549 {
<> 132:9baf128c2fab 550 base->DATA |= TSI_DATA_DMAEN_MASK; /* Enable DMA transfer */
<> 132:9baf128c2fab 551 }
<> 132:9baf128c2fab 552 else
<> 132:9baf128c2fab 553 {
<> 132:9baf128c2fab 554 base->DATA &= ~TSI_DATA_DMAEN_MASK; /* Disable DMA transfer */
<> 132:9baf128c2fab 555 }
<> 132:9baf128c2fab 556 }
<> 132:9baf128c2fab 557
<> 132:9baf128c2fab 558 #if defined(FSL_FEATURE_TSI_HAS_END_OF_SCAN_DMA_ENABLE) && (FSL_FEATURE_TSI_HAS_END_OF_SCAN_DMA_ENABLE == 1)
<> 132:9baf128c2fab 559 /*!
<> 132:9baf128c2fab 560 * @brief Decides whether to enable end of scan DMA transfer request only.
<> 132:9baf128c2fab 561 *
<> 132:9baf128c2fab 562 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 563 * @param enable Choose whether to enable End of Scan DMA transfer request only.
<> 132:9baf128c2fab 564 * - true Enable End of Scan DMA transfer request only;
<> 132:9baf128c2fab 565 * - false Both End-of-Scan and Out-of-Range can generate DMA transfer request.
<> 132:9baf128c2fab 566 * @return none.
<> 132:9baf128c2fab 567 */
<> 132:9baf128c2fab 568 static inline void TSI_EnableEndOfScanDmaTransferOnly(TSI_Type *base, bool enable)
<> 132:9baf128c2fab 569 {
<> 132:9baf128c2fab 570 if (enable)
<> 132:9baf128c2fab 571 {
<> 132:9baf128c2fab 572 base->GENCS = (base->GENCS & ~ALL_FLAGS_MASK) | TSI_GENCS_EOSDMEO_MASK; /* Enable End of Scan DMA transfer request only; */
<> 132:9baf128c2fab 573 }
<> 132:9baf128c2fab 574 else
<> 132:9baf128c2fab 575 {
<> 132:9baf128c2fab 576 base->GENCS =
<> 132:9baf128c2fab 577 (base->GENCS & ~ALL_FLAGS_MASK) & (~TSI_GENCS_EOSDMEO_MASK); /* Both End-of-Scan and Out-of-Range can generate DMA transfer request. */
<> 132:9baf128c2fab 578 }
<> 132:9baf128c2fab 579 }
<> 132:9baf128c2fab 580 #endif /* End of (FSL_FEATURE_TSI_HAS_END_OF_SCAN_DMA_ENABLE == 1)*/
<> 132:9baf128c2fab 581
<> 132:9baf128c2fab 582 /*!
<> 132:9baf128c2fab 583 * @brief Gets the conversion counter value.
<> 132:9baf128c2fab 584 *
<> 132:9baf128c2fab 585 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 586 * @return Accumulated scan counter value ticked by the reference clock.
<> 132:9baf128c2fab 587 */
<> 132:9baf128c2fab 588 static inline uint16_t TSI_GetCounter(TSI_Type *base)
<> 132:9baf128c2fab 589 {
<> 132:9baf128c2fab 590 return (uint16_t)(base->DATA & TSI_DATA_TSICNT_MASK);
<> 132:9baf128c2fab 591 }
<> 132:9baf128c2fab 592
<> 132:9baf128c2fab 593 /*!
<> 132:9baf128c2fab 594 * @brief Sets the TSI wake-up channel low threshold.
<> 132:9baf128c2fab 595 *
<> 132:9baf128c2fab 596 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 597 * @param low_threshold Low counter threshold.
<> 132:9baf128c2fab 598 * @return none.
<> 132:9baf128c2fab 599 */
<> 132:9baf128c2fab 600 static inline void TSI_SetLowThreshold(TSI_Type *base, uint16_t low_threshold)
<> 132:9baf128c2fab 601 {
<> 132:9baf128c2fab 602 assert(low_threshold < 0xFFFFU);
<> 132:9baf128c2fab 603
<> 132:9baf128c2fab 604 base->TSHD = ((base->TSHD) & ~TSI_TSHD_THRESL_MASK) | (TSI_TSHD_THRESL(low_threshold));
<> 132:9baf128c2fab 605 }
<> 132:9baf128c2fab 606
<> 132:9baf128c2fab 607 /*!
<> 132:9baf128c2fab 608 * @brief Sets the TSI wake-up channel high threshold.
<> 132:9baf128c2fab 609 *
<> 132:9baf128c2fab 610 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 611 * @param high_threshold High counter threshold.
<> 132:9baf128c2fab 612 * @return none.
<> 132:9baf128c2fab 613 */
<> 132:9baf128c2fab 614 static inline void TSI_SetHighThreshold(TSI_Type *base, uint16_t high_threshold)
<> 132:9baf128c2fab 615 {
<> 132:9baf128c2fab 616 assert(high_threshold < 0xFFFFU);
<> 132:9baf128c2fab 617
<> 132:9baf128c2fab 618 base->TSHD = ((base->TSHD) & ~TSI_TSHD_THRESH_MASK) | (TSI_TSHD_THRESH(high_threshold));
<> 132:9baf128c2fab 619 }
<> 132:9baf128c2fab 620
<> 132:9baf128c2fab 621 /*!
<> 132:9baf128c2fab 622 * @brief Sets the analog mode of the TSI module.
<> 132:9baf128c2fab 623 *
<> 132:9baf128c2fab 624 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 625 * @param mode Mode value.
<> 132:9baf128c2fab 626 * @return none.
<> 132:9baf128c2fab 627 */
<> 132:9baf128c2fab 628 static inline void TSI_SetAnalogMode(TSI_Type *base, tsi_analog_mode_t mode)
<> 132:9baf128c2fab 629 {
<> 132:9baf128c2fab 630 base->GENCS = (base->GENCS & ~(TSI_GENCS_MODE_MASK | ALL_FLAGS_MASK)) | (TSI_GENCS_MODE(mode));
<> 132:9baf128c2fab 631 }
<> 132:9baf128c2fab 632
<> 132:9baf128c2fab 633 /*!
<> 132:9baf128c2fab 634 * @brief Gets the noise mode result of the TSI module.
<> 132:9baf128c2fab 635 *
<> 132:9baf128c2fab 636 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 637 * @return Value of the GENCS[MODE] bit-fields.
<> 132:9baf128c2fab 638 */
<> 132:9baf128c2fab 639 static inline uint8_t TSI_GetNoiseModeResult(TSI_Type *base)
<> 132:9baf128c2fab 640 {
<> 132:9baf128c2fab 641 return (base->GENCS & TSI_GENCS_MODE_MASK) >> TSI_GENCS_MODE_SHIFT;
<> 132:9baf128c2fab 642 }
<> 132:9baf128c2fab 643
<> 132:9baf128c2fab 644 /*!
<> 132:9baf128c2fab 645 * @brief Sets the reference oscillator charge current.
<> 132:9baf128c2fab 646 *
<> 132:9baf128c2fab 647 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 648 * @param current The reference oscillator charge current.
<> 132:9baf128c2fab 649 * @return none.
<> 132:9baf128c2fab 650 */
<> 132:9baf128c2fab 651 static inline void TSI_SetReferenceChargeCurrent(TSI_Type *base, tsi_reference_osc_charge_current_t current)
<> 132:9baf128c2fab 652 {
<> 132:9baf128c2fab 653 base->GENCS = (base->GENCS & ~(TSI_GENCS_REFCHRG_MASK | ALL_FLAGS_MASK)) | (TSI_GENCS_REFCHRG(current));
<> 132:9baf128c2fab 654 }
<> 132:9baf128c2fab 655
<> 132:9baf128c2fab 656 /*!
<> 132:9baf128c2fab 657 * @brief Sets the external electrode charge current.
<> 132:9baf128c2fab 658 *
<> 132:9baf128c2fab 659 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 660 * @param current External electrode charge current.
<> 132:9baf128c2fab 661 * @return none.
<> 132:9baf128c2fab 662 */
<> 132:9baf128c2fab 663 static inline void TSI_SetElectrodeChargeCurrent(TSI_Type *base, tsi_external_osc_charge_current_t current)
<> 132:9baf128c2fab 664 {
<> 132:9baf128c2fab 665 base->GENCS = (base->GENCS & ~(TSI_GENCS_EXTCHRG_MASK | ALL_FLAGS_MASK)) | (TSI_GENCS_EXTCHRG(current));
<> 132:9baf128c2fab 666 }
<> 132:9baf128c2fab 667
<> 132:9baf128c2fab 668 /*!
<> 132:9baf128c2fab 669 * @brief Sets the oscillator's voltage rails.
<> 132:9baf128c2fab 670 *
<> 132:9baf128c2fab 671 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 672 * @param dvolt The voltage rails.
<> 132:9baf128c2fab 673 * @return none.
<> 132:9baf128c2fab 674 */
<> 132:9baf128c2fab 675 static inline void TSI_SetOscVoltageRails(TSI_Type *base, tsi_osc_voltage_rails_t dvolt)
<> 132:9baf128c2fab 676 {
<> 132:9baf128c2fab 677 base->GENCS = (base->GENCS & ~(TSI_GENCS_DVOLT_MASK | ALL_FLAGS_MASK)) | (TSI_GENCS_DVOLT(dvolt));
<> 132:9baf128c2fab 678 }
<> 132:9baf128c2fab 679
<> 132:9baf128c2fab 680 /*!
<> 132:9baf128c2fab 681 * @brief Sets the electrode series resistance value in EXTCHRG[0] bit.
<> 132:9baf128c2fab 682 *
<> 132:9baf128c2fab 683 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 684 * @param resistor Series resistance.
<> 132:9baf128c2fab 685 * @return none.
<> 132:9baf128c2fab 686 */
<> 132:9baf128c2fab 687 static inline void TSI_SetElectrodeSeriesResistor(TSI_Type *base, tsi_series_resistor_t resistor)
<> 132:9baf128c2fab 688 {
<> 132:9baf128c2fab 689 base->GENCS = (base->GENCS & TSI_V4_EXTCHRG_RESISTOR_BIT_CLEAR) | TSI_GENCS_EXTCHRG(resistor);
<> 132:9baf128c2fab 690 }
<> 132:9baf128c2fab 691
<> 132:9baf128c2fab 692 /*!
<> 132:9baf128c2fab 693 * @brief Sets the electrode filter bits value in EXTCHRG[2:1] bits.
<> 132:9baf128c2fab 694 *
<> 132:9baf128c2fab 695 * @param base TSI peripheral base address.
<> 132:9baf128c2fab 696 * @param filter Series resistance.
<> 132:9baf128c2fab 697 * @return none.
<> 132:9baf128c2fab 698 */
<> 132:9baf128c2fab 699 static inline void TSI_SetFilterBits(TSI_Type *base, tsi_filter_bits_t filter)
<> 132:9baf128c2fab 700 {
<> 132:9baf128c2fab 701 base->GENCS = (base->GENCS & TSI_V4_EXTCHRG_FILTER_BITS_CLEAR) | (filter << TSI_V4_EXTCHRG_FILTER_BITS_SHIFT);
<> 132:9baf128c2fab 702 }
<> 132:9baf128c2fab 703
<> 132:9baf128c2fab 704 #ifdef __cplusplus
<> 132:9baf128c2fab 705 }
<> 132:9baf128c2fab 706 #endif /* __cplusplus */
<> 132:9baf128c2fab 707
<> 132:9baf128c2fab 708 /*! @}*/
<> 132:9baf128c2fab 709
<> 132:9baf128c2fab 710 #endif /* _FSL_TSI_V4_H_ */