added prescaler for 16 bit pwm in LPC1347 target

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Sep 02 15:07:44 2016 +0100
Revision:
144:ef7eb2e8f9f7
This updates the lib to the mbed lib v125

Who changed what in which revision?

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