| Kinetis SDK v.2.0 API Reference Manual Rev. 0 Freescale Semiconductor, Inc.

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Files | Data Structures | Macros | Enumerations | Functions
TSIv4 Driver
TSI: Touch Sensing Input

## Overview

The KSDK provides driver for the Touch Sensing Input (TSI) module of Kinetis devices.

# Typical use case

TSI_Init(TSI0);
TSI_Configure(TSI0, &user_config);
TSI_SetMeasuredChannelNumber(TSI0, channelMask);
TSI_EnableInterrupts(TSI0, kTSI_GlobalInterruptEnable | kTSI_EndOfScanInterruptEnable);
TSI_EnableSoftwareTriggerScan(TSI0);
TSI_EnableModule(TSI0);
while(1)
{
TSI_StartSoftwareTrigger(TSI0);
TSI_GetCounter(TSI0);
}

## Files
file | fsl_tsi_v4.h

## Data Structures
struct | tsi_calibration_data_t
| TSI calibration data storage. More...
struct | tsi_config_t
| TSI configuration structure. More...

## Macros
#define | TSI_V4_EXTCHRG_RESISTOR_BIT_SHIFT TSI_GENCS_EXTCHRG_SHIFT
| resistor bit shift in EXTCHRG bit-field
#define | TSI_V4_EXTCHRG_FILTER_BITS_SHIFT (1U + TSI_GENCS_EXTCHRG_SHIFT)
| filter bits shift in EXTCHRG bit-field
#define | TSI_V4_EXTCHRG_RESISTOR_BIT_CLEAR ((uint32_t)((~TSI_GENCS_EXTCHRG_MASK) | (3U << TSI_V4_EXTCHRG_FILTER_BITS_SHIFT)))
| macro of clearing the resistor bit in EXTCHRG bit-field
#define | TSI_V4_EXTCHRG_FILTER_BITS_CLEAR ((uint32_t)((~TSI_GENCS_EXTCHRG_MASK) | (1U << TSI_V4_EXTCHRG_RESISTOR_BIT_SHIFT)))
| macro of clearing the filter bits in EXTCHRG bit-field

## Enumerations
enum | tsi_n_consecutive_scans_t { kTSI_ConsecutiveScansNumber_1time = 0U, kTSI_ConsecutiveScansNumber_2time = 1U, kTSI_ConsecutiveScansNumber_3time = 2U, kTSI_ConsecutiveScansNumber_4time = 3U, kTSI_ConsecutiveScansNumber_5time = 4U, kTSI_ConsecutiveScansNumber_6time = 5U, kTSI_ConsecutiveScansNumber_7time = 6U, kTSI_ConsecutiveScansNumber_8time = 7U, kTSI_ConsecutiveScansNumber_9time = 8U, kTSI_ConsecutiveScansNumber_10time = 9U, kTSI_ConsecutiveScansNumber_11time = 10U, kTSI_ConsecutiveScansNumber_12time = 11U, kTSI_ConsecutiveScansNumber_13time = 12U, kTSI_ConsecutiveScansNumber_14time = 13U, kTSI_ConsecutiveScansNumber_15time = 14U, kTSI_ConsecutiveScansNumber_16time = 15U, kTSI_ConsecutiveScansNumber_17time = 16U, kTSI_ConsecutiveScansNumber_18time = 17U, kTSI_ConsecutiveScansNumber_19time = 18U, kTSI_ConsecutiveScansNumber_20time = 19U, kTSI_ConsecutiveScansNumber_21time = 20U, kTSI_ConsecutiveScansNumber_22time = 21U, kTSI_ConsecutiveScansNumber_23time = 22U, kTSI_ConsecutiveScansNumber_24time = 23U, kTSI_ConsecutiveScansNumber_25time = 24U, kTSI_ConsecutiveScansNumber_26time = 25U, kTSI_ConsecutiveScansNumber_27time = 26U, kTSI_ConsecutiveScansNumber_28time = 27U, kTSI_ConsecutiveScansNumber_29time = 28U, kTSI_ConsecutiveScansNumber_30time = 29U, kTSI_ConsecutiveScansNumber_31time = 30U, kTSI_ConsecutiveScansNumber_32time = 31U, kTSI_ConsecutiveScansNumber_1time = 0U, kTSI_ConsecutiveScansNumber_2time = 1U, kTSI_ConsecutiveScansNumber_3time = 2U, kTSI_ConsecutiveScansNumber_4time = 3U, kTSI_ConsecutiveScansNumber_5time = 4U, kTSI_ConsecutiveScansNumber_6time = 5U, kTSI_ConsecutiveScansNumber_7time = 6U, kTSI_ConsecutiveScansNumber_8time = 7U, kTSI_ConsecutiveScansNumber_9time = 8U, kTSI_ConsecutiveScansNumber_10time = 9U, kTSI_ConsecutiveScansNumber_11time = 10U, kTSI_ConsecutiveScansNumber_12time = 11U, kTSI_ConsecutiveScansNumber_13time = 12U, kTSI_ConsecutiveScansNumber_14time = 13U, kTSI_ConsecutiveScansNumber_15time = 14U, kTSI_ConsecutiveScansNumber_16time = 15U, kTSI_ConsecutiveScansNumber_17time = 16U, kTSI_ConsecutiveScansNumber_18time = 17U, kTSI_ConsecutiveScansNumber_19time = 18U, kTSI_ConsecutiveScansNumber_20time = 19U, kTSI_ConsecutiveScansNumber_21time = 20U, kTSI_ConsecutiveScansNumber_22time = 21U, kTSI_ConsecutiveScansNumber_23time = 22U, kTSI_ConsecutiveScansNumber_24time = 23U, kTSI_ConsecutiveScansNumber_25time = 24U, kTSI_ConsecutiveScansNumber_26time = 25U, kTSI_ConsecutiveScansNumber_27time = 26U, kTSI_ConsecutiveScansNumber_28time = 27U, kTSI_ConsecutiveScansNumber_29time = 28U, kTSI_ConsecutiveScansNumber_30time = 29U, kTSI_ConsecutiveScansNumber_31time = 30U, kTSI_ConsecutiveScansNumber_32time = 31U }
| TSI number of scan intervals for each electrode. More...
enum | tsi_electrode_osc_prescaler_t { kTSI_ElecOscPrescaler_1div = 0U, kTSI_ElecOscPrescaler_2div = 1U, kTSI_ElecOscPrescaler_4div = 2U, kTSI_ElecOscPrescaler_8div = 3U, kTSI_ElecOscPrescaler_16div = 4U, kTSI_ElecOscPrescaler_32div = 5U, kTSI_ElecOscPrescaler_64div = 6U, kTSI_ElecOscPrescaler_128div = 7U, kTSI_ElecOscPrescaler_1div = 0U, kTSI_ElecOscPrescaler_2div = 1U, kTSI_ElecOscPrescaler_4div = 2U, kTSI_ElecOscPrescaler_8div = 3U, kTSI_ElecOscPrescaler_16div = 4U, kTSI_ElecOscPrescaler_32div = 5U, kTSI_ElecOscPrescaler_64div = 6U, kTSI_ElecOscPrescaler_128div = 7U }
| TSI electrode oscillator prescaler. More...
enum | tsi_analog_mode_t { kTSI_AnalogModeSel_Capacitive = 0U, kTSI_AnalogModeSel_NoiseNoFreqLim = 4U, kTSI_AnalogModeSel_NoiseFreqLim = 8U, kTSI_AnalogModeSel_AutoNoise = 12U }
| TSI analog mode select. More...
enum | tsi_reference_osc_charge_current_t { kTSI_RefOscChargeCurrent_2uA = 0U, kTSI_RefOscChargeCurrent_4uA = 1U, kTSI_RefOscChargeCurrent_6uA = 2U, kTSI_RefOscChargeCurrent_8uA = 3U, kTSI_RefOscChargeCurrent_10uA = 4U, kTSI_RefOscChargeCurrent_12uA = 5U, kTSI_RefOscChargeCurrent_14uA = 6U, kTSI_RefOscChargeCurrent_16uA = 7U, kTSI_RefOscChargeCurrent_18uA = 8U, kTSI_RefOscChargeCurrent_20uA = 9U, kTSI_RefOscChargeCurrent_22uA = 10U, kTSI_RefOscChargeCurrent_24uA = 11U, kTSI_RefOscChargeCurrent_26uA = 12U, kTSI_RefOscChargeCurrent_28uA = 13U, kTSI_RefOscChargeCurrent_30uA = 14U, kTSI_RefOscChargeCurrent_32uA = 15U, kTSI_RefOscChargeCurrent_500nA = 0U, kTSI_RefOscChargeCurrent_1uA = 1U, kTSI_RefOscChargeCurrent_2uA = 2U, kTSI_RefOscChargeCurrent_4uA = 3U, kTSI_RefOscChargeCurrent_8uA = 4U, kTSI_RefOscChargeCurrent_16uA = 5U, kTSI_RefOscChargeCurrent_32uA = 6U, kTSI_RefOscChargeCurrent_64uA = 7U }
| TSI Reference oscillator charge and discharge current select. More...
enum | tsi_osc_voltage_rails_t { kTSI_OscVolRailsOption_0 = 0U, kTSI_OscVolRailsOption_1 = 1U, kTSI_OscVolRailsOption_2 = 2U, kTSI_OscVolRailsOption_3 = 3U }
| TSI oscilator's voltage rails. More...
enum | tsi_external_osc_charge_current_t { kTSI_ExtOscChargeCurrent_2uA = 0U, kTSI_ExtOscChargeCurrent_4uA = 1U, kTSI_ExtOscChargeCurrent_6uA = 2U, kTSI_ExtOscChargeCurrent_8uA = 3U, kTSI_ExtOscChargeCurrent_10uA = 4U, kTSI_ExtOscChargeCurrent_12uA = 5U, kTSI_ExtOscChargeCurrent_14uA = 6U, kTSI_ExtOscChargeCurrent_16uA = 7U, kTSI_ExtOscChargeCurrent_18uA = 8U, kTSI_ExtOscChargeCurrent_20uA = 9U, kTSI_ExtOscChargeCurrent_22uA = 10U, kTSI_ExtOscChargeCurrent_24uA = 11U, kTSI_ExtOscChargeCurrent_26uA = 12U, kTSI_ExtOscChargeCurrent_28uA = 13U, kTSI_ExtOscChargeCurrent_30uA = 14U, kTSI_ExtOscChargeCurrent_32uA = 15U, kTSI_ExtOscChargeCurrent_500nA = 0U, kTSI_ExtOscChargeCurrent_1uA = 1U, kTSI_ExtOscChargeCurrent_2uA = 2U, kTSI_ExtOscChargeCurrent_4uA = 3U, kTSI_ExtOscChargeCurrent_8uA = 4U, kTSI_ExtOscChargeCurrent_16uA = 5U, kTSI_ExtOscChargeCurrent_32uA = 6U, kTSI_ExtOscChargeCurrent_64uA = 7U }
| TSI External oscillator charge and discharge current select. More...
enum | tsi_series_resistor_t { kTSI_SeriesResistance_32k = 0U, kTSI_SeriesResistance_187k = 1U }
| TSI series resistance RS value select. More...
enum | tsi_filter_bits_t { kTSI_FilterBits_3 = 0U, kTSI_FilterBits_2 = 1U, kTSI_FilterBits_1 = 2U, kTSI_FilterBits_0 = 3U }
| TSI series filter bits select. More...
enum | tsi_status_flags_t { kTSI_EndOfScanFlag = TSI_GENCS_EOSF_MASK, kTSI_OutOfRangeFlag = TSI_GENCS_OUTRGF_MASK, kTSI_ExternalElectrodeErrorFlag = TSI_GENCS_EXTERF_MASK, kTSI_OverrunErrorFlag = TSI_GENCS_OVRF_MASK, kTSI_EndOfScanFlag = TSI_GENCS_EOSF_MASK, kTSI_OutOfRangeFlag = TSI_GENCS_OUTRGF_MASK }
| TSI status flags. More...
enum | tsi_interrupt_enable_t { kTSI_GlobalInterruptEnable = 1U, kTSI_OutOfRangeInterruptEnable = 2U, kTSI_EndOfScanInterruptEnable = 4U, kTSI_ErrorInterrruptEnable = 8U, kTSI_GlobalInterruptEnable = 1U, kTSI_OutOfRangeInterruptEnable = 2U, kTSI_EndOfScanInterruptEnable = 4U }
| TSI feature interrupt source. More...

## Functions
void | TSI_Init (TSI_Type *base, const tsi_config_t *config)
| Initializes hardware. More...
void | TSI_Deinit (TSI_Type *base)
| De-initializes hardware. More...
void | TSI_GetNormalModeDefaultConfig (tsi_config_t *userConfig)
| Gets the TSI normal mode user configuration structure. More...
void | TSI_GetLowPowerModeDefaultConfig (tsi_config_t *userConfig)
| Gets the TSI low power mode default user configuration structure. More...
void | TSI_Calibrate (TSI_Type *base, tsi_calibration_data_t *calBuff)
| Hardware calibration. More...
void | TSI_EnableInterrupts (TSI_Type *base, uint32_t mask)
| Enables the TSI interrupt requests. More...
void | TSI_DisableInterrupts (TSI_Type *base, uint32_t mask)
| Disables the TSI interrupt requests. More...
static uint32_t | TSI_GetStatusFlags (TSI_Type *base)
| Gets an interrupt flag. More...
void | TSI_ClearStatusFlags (TSI_Type *base, uint32_t mask)
| Clears the interrupt flag. More...
static uint32_t | TSI_GetScanTriggerMode (TSI_Type *base)
| Gets the TSI scan trigger mode. More...
static bool | TSI_IsScanInProgress (TSI_Type *base)
| Gets the scan in progress flag. More...
static void | TSI_SetElectrodeOSCPrescaler (TSI_Type *base, tsi_electrode_osc_prescaler_t prescaler)
| Sets the prescaler. More...
static void | TSI_SetNumberOfScans (TSI_Type *base, tsi_n_consecutive_scans_t number)
| Sets the number of scans (NSCN). More...
static void | TSI_EnableModule (TSI_Type *base, bool enable)
| Enables/disables the TSI module. More...
static void | TSI_EnableLowPower (TSI_Type *base, bool enable)
| Sets the TSI low power STOP mode as enabled or disabled. More...
static void | TSI_EnableHardwareTriggerScan (TSI_Type *base, bool enable)
| Enables/disables the hardware trigger scan. More...
static void | TSI_StartSoftwareTrigger (TSI_Type *base)
| Starts a software trigger measurement (triggers a new measurement). More...
static void | TSI_SetMeasuredChannelNumber (TSI_Type *base, uint8_t channel)
| Sets the the measured channel number. More...
static uint8_t | TSI_GetMeasuredChannelNumber (TSI_Type *base)
| Gets the current measured channel number. More...
static void | TSI_EnableDmaTransfer (TSI_Type *base, bool enable)
| Enables/disables the DMA transfer. More...
static uint16_t | TSI_GetCounter (TSI_Type *base)
| Gets the conversion counter value. More...
static void | TSI_SetLowThreshold (TSI_Type *base, uint16_t low_threshold)
| Sets the TSI wake-up channel low threshold. More...
static void | TSI_SetHighThreshold (TSI_Type *base, uint16_t high_threshold)
| Sets the TSI wake-up channel high threshold. More...
static void | TSI_SetAnalogMode (TSI_Type *base, tsi_analog_mode_t mode)
| Sets the analog mode of the TSI module. More...
static uint8_t | TSI_GetNoiseModeResult (TSI_Type *base)
| Gets the noise mode result of the TSI module. More...
static void | TSI_SetReferenceChargeCurrent (TSI_Type *base, tsi_reference_osc_charge_current_t current)
| Sets the reference oscillator charge current. More...
static void | TSI_SetElectrodeChargeCurrent (TSI_Type *base, tsi_external_osc_charge_current_t current)
| Sets the external electrode charge current. More...
static void | TSI_SetOscVoltageRails (TSI_Type *base, tsi_osc_voltage_rails_t dvolt)
| Sets the oscillator's voltage rails. More...
static void | TSI_SetElectrodeSeriesResistor (TSI_Type *base, tsi_series_resistor_t resistor)
| Sets the electrode series resistance value in EXTCHRG[0] bit. More...
static void | TSI_SetFilterBits (TSI_Type *base, tsi_filter_bits_t filter)
| Sets the electrode filter bits value in EXTCHRG[2:1] bits. More...

## Driver version
#define | FSL_TSI_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
| TSI driver version 2.0.0. More...

## Data Structure Documentation

struct tsi_calibration_data_t

### Data Fields
uint16_t | calibratedData [FSL_FEATURE_TSI_CHANNEL_COUNT]
| TSI calibration data storage buffer.

struct tsi_config_t

This structure contains the settings for the most common TSI configurations including the TSI module charge currents, number of scans, thresholds, and so on.

### Data Fields
uint16_t | thresh
| High threshold. More...
uint16_t | thresl
| Low threshold. More...
tsi_low_power_clock_source_t | lpclks
| Low power clock. More...
tsi_low_power_scan_interval_t | lpscnitv
| Low power scan interval. More...
tsi_active_mode_clock_source_t | amclks
| Active mode clock source. More...
tsi_active_mode_prescaler_t | ampsc
| Active mode prescaler. More...
tsi_electrode_osc_prescaler_t | ps
| Electrode Oscillator Prescaler.
tsi_external_osc_charge_current_t | extchrg
| External Oscillator charge current. More...
tsi_reference_osc_charge_current_t | refchrg
| Reference Oscillator charge current. More...
tsi_n_consecutive_scans_t | nscn
| Number of scans. More...
tsi_electrode_osc_prescaler_t | prescaler
| Prescaler.
tsi_analog_mode_t | mode
| TSI mode of operation. More...
tsi_osc_voltage_rails_t | dvolt
| Oscillator's voltage rails. More...
tsi_series_resistor_t | resistor
| Series resistance value.
tsi_filter_bits_t | filter
| Noise mode filter bits.

#### Field Documentation

uint16_t tsi_config_t::thresh

uint16_t tsi_config_t::thresl

tsi_low_power_clock_source_t tsi_config_t::lpclks

tsi_low_power_scan_interval_t tsi_config_t::lpscnitv

tsi_active_mode_clock_source_t tsi_config_t::amclks

tsi_active_mode_prescaler_t tsi_config_t::ampsc

tsi_external_osc_charge_current_t tsi_config_t::extchrg

Electrode charge current.

tsi_reference_osc_charge_current_t tsi_config_t::refchrg

Reference charge current.

tsi_n_consecutive_scans_t tsi_config_t::nscn

tsi_analog_mode_t tsi_config_t::mode

tsi_osc_voltage_rails_t tsi_config_t::dvolt

## Macro Definition Documentation

#define FSL_TSI_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))

## Enumeration Type Documentation

enum tsi_n_consecutive_scans_t

These constants define the tsi number of consecutive scans in a TSI instance for each electrode.

Enumerator
kTSI_ConsecutiveScansNumber_1time | Once per electrode.
kTSI_ConsecutiveScansNumber_2time | Twice per electrode.
kTSI_ConsecutiveScansNumber_3time | 3 times consecutive scan
kTSI_ConsecutiveScansNumber_4time | 4 times consecutive scan
kTSI_ConsecutiveScansNumber_5time | 5 times consecutive scan
kTSI_ConsecutiveScansNumber_6time | 6 times consecutive scan
kTSI_ConsecutiveScansNumber_7time | 7 times consecutive scan
kTSI_ConsecutiveScansNumber_8time | 8 times consecutive scan
kTSI_ConsecutiveScansNumber_9time | 9 times consecutive scan
kTSI_ConsecutiveScansNumber_10time | 10 times consecutive scan
kTSI_ConsecutiveScansNumber_11time | 11 times consecutive scan
kTSI_ConsecutiveScansNumber_12time | 12 times consecutive scan
kTSI_ConsecutiveScansNumber_13time | 13 times consecutive scan
kTSI_ConsecutiveScansNumber_14time | 14 times consecutive scan
kTSI_ConsecutiveScansNumber_15time | 15 times consecutive scan
kTSI_ConsecutiveScansNumber_16time | 16 times consecutive scan
kTSI_ConsecutiveScansNumber_17time | 17 times consecutive scan
kTSI_ConsecutiveScansNumber_18time | 18 times consecutive scan
kTSI_ConsecutiveScansNumber_19time | 19 times consecutive scan
kTSI_ConsecutiveScansNumber_20time | 20 times consecutive scan
kTSI_ConsecutiveScansNumber_21time | 21 times consecutive scan
kTSI_ConsecutiveScansNumber_22time | 22 times consecutive scan
kTSI_ConsecutiveScansNumber_23time | 23 times consecutive scan
kTSI_ConsecutiveScansNumber_24time | 24 times consecutive scan
kTSI_ConsecutiveScansNumber_25time | 25 times consecutive scan
kTSI_ConsecutiveScansNumber_26time | 26 times consecutive scan
kTSI_ConsecutiveScansNumber_27time | 27 times consecutive scan
kTSI_ConsecutiveScansNumber_28time | 28 times consecutive scan
kTSI_ConsecutiveScansNumber_29time | 29 times consecutive scan
kTSI_ConsecutiveScansNumber_30time | 30 times consecutive scan
kTSI_ConsecutiveScansNumber_31time | 31 times consecutive scan
kTSI_ConsecutiveScansNumber_32time | 32 times consecutive scan
kTSI_ConsecutiveScansNumber_1time | Once per electrode.
kTSI_ConsecutiveScansNumber_2time | Twice per electrode.
kTSI_ConsecutiveScansNumber_3time | 3 times consecutive scan
kTSI_ConsecutiveScansNumber_4time | 4 times consecutive scan
kTSI_ConsecutiveScansNumber_5time | 5 times consecutive scan
kTSI_ConsecutiveScansNumber_6time | 6 times consecutive scan
kTSI_ConsecutiveScansNumber_7time | 7 times consecutive scan
kTSI_ConsecutiveScansNumber_8time | 8 times consecutive scan
kTSI_ConsecutiveScansNumber_9time | 9 times consecutive scan
kTSI_ConsecutiveScansNumber_10time | 10 times consecutive scan
kTSI_ConsecutiveScansNumber_11time | 11 times consecutive scan
kTSI_ConsecutiveScansNumber_12time | 12 times consecutive scan
kTSI_ConsecutiveScansNumber_13time | 13 times consecutive scan
kTSI_ConsecutiveScansNumber_14time | 14 times consecutive scan
kTSI_ConsecutiveScansNumber_15time | 15 times consecutive scan
kTSI_ConsecutiveScansNumber_16time | 16 times consecutive scan
kTSI_ConsecutiveScansNumber_17time | 17 times consecutive scan
kTSI_ConsecutiveScansNumber_18time | 18 times consecutive scan
kTSI_ConsecutiveScansNumber_19time | 19 times consecutive scan
kTSI_ConsecutiveScansNumber_20time | 20 times consecutive scan
kTSI_ConsecutiveScansNumber_21time | 21 times consecutive scan
kTSI_ConsecutiveScansNumber_22time | 22 times consecutive scan
kTSI_ConsecutiveScansNumber_23time | 23 times consecutive scan
kTSI_ConsecutiveScansNumber_24time | 24 times consecutive scan
kTSI_ConsecutiveScansNumber_25time | 25 times consecutive scan
kTSI_ConsecutiveScansNumber_26time | 26 times consecutive scan
kTSI_ConsecutiveScansNumber_27time | 27 times consecutive scan
kTSI_ConsecutiveScansNumber_28time | 28 times consecutive scan
kTSI_ConsecutiveScansNumber_29time | 29 times consecutive scan
kTSI_ConsecutiveScansNumber_30time | 30 times consecutive scan
kTSI_ConsecutiveScansNumber_31time | 31 times consecutive scan
kTSI_ConsecutiveScansNumber_32time | 32 times consecutive scan

enum tsi_electrode_osc_prescaler_t

These constants define the TSI electrode oscillator prescaler in a TSI instance.

Enumerator
kTSI_ElecOscPrescaler_1div | Electrode oscillator frequency divided by 1.
kTSI_ElecOscPrescaler_2div | Electrode oscillator frequency divided by 2.
kTSI_ElecOscPrescaler_4div | Electrode oscillator frequency divided by 4.
kTSI_ElecOscPrescaler_8div | Electrode oscillator frequency divided by 8.
kTSI_ElecOscPrescaler_16div | Electrode oscillator frequency divided by 16.
kTSI_ElecOscPrescaler_32div | Electrode oscillator frequency divided by 32.
kTSI_ElecOscPrescaler_64div | Electrode oscillator frequency divided by 64.
kTSI_ElecOscPrescaler_128div | Electrode oscillator frequency divided by 128.
kTSI_ElecOscPrescaler_1div | Electrode oscillator frequency divided by 1.
kTSI_ElecOscPrescaler_2div | Electrode oscillator frequency divided by 2.
kTSI_ElecOscPrescaler_4div | Electrode oscillator frequency divided by 4.
kTSI_ElecOscPrescaler_8div | Electrode oscillator frequency divided by 8.
kTSI_ElecOscPrescaler_16div | Electrode oscillator frequency divided by 16.
kTSI_ElecOscPrescaler_32div | Electrode oscillator frequency divided by 32.
kTSI_ElecOscPrescaler_64div | Electrode oscillator frequency divided by 64.
kTSI_ElecOscPrescaler_128div | Electrode oscillator frequency divided by 128.

enum tsi_analog_mode_t

Set up TSI analog modes in a TSI instance.

Enumerator
kTSI_AnalogModeSel_Capacitive | Active TSI capacitive sensing mode.
kTSI_AnalogModeSel_NoiseNoFreqLim | Single threshold noise detection mode with no freq. limitation.
kTSI_AnalogModeSel_NoiseFreqLim | Single threshold noise detection mode with freq. limitation.
kTSI_AnalogModeSel_AutoNoise | Active TSI analog in automatic noise detection mode.

enum tsi_reference_osc_charge_current_t

These constants define the TSI Reference oscillator charge current select in a TSI (REFCHRG) instance.

Enumerator
kTSI_RefOscChargeCurrent_2uA | Reference oscillator charge current is 2 µA.
kTSI_RefOscChargeCurrent_4uA | Reference oscillator charge current is 4 µA.
kTSI_RefOscChargeCurrent_6uA | Reference oscillator charge current is 6 µA.
kTSI_RefOscChargeCurrent_8uA | Reference oscillator charge current is 8 µA.
kTSI_RefOscChargeCurrent_10uA | Reference oscillator charge current is 10 µA.
kTSI_RefOscChargeCurrent_12uA | Reference oscillator charge current is 12 µA.
kTSI_RefOscChargeCurrent_14uA | Reference oscillator charge current is 14 µA.
kTSI_RefOscChargeCurrent_16uA | Reference oscillator charge current is 16 µA.
kTSI_RefOscChargeCurrent_18uA | Reference oscillator charge current is 18 µA.
kTSI_RefOscChargeCurrent_20uA | Reference oscillator charge current is 20 µA.
kTSI_RefOscChargeCurrent_22uA | Reference oscillator charge current is 22 µA.
kTSI_RefOscChargeCurrent_24uA | Reference oscillator charge current is 24 µA.
kTSI_RefOscChargeCurrent_26uA | Reference oscillator charge current is 26 µA.
kTSI_RefOscChargeCurrent_28uA | Reference oscillator charge current is 28 µA.
kTSI_RefOscChargeCurrent_30uA | Reference oscillator charge current is 30 µA.
kTSI_RefOscChargeCurrent_32uA | Reference oscillator charge current is 32 µA.
kTSI_RefOscChargeCurrent_500nA | Reference oscillator charge current is 500 µA.
kTSI_RefOscChargeCurrent_1uA | Reference oscillator charge current is 1 µA.
kTSI_RefOscChargeCurrent_2uA | Reference oscillator charge current is 2 µA.
kTSI_RefOscChargeCurrent_4uA | Reference oscillator charge current is 4 µA.
kTSI_RefOscChargeCurrent_8uA | Reference oscillator charge current is 8 µA.
kTSI_RefOscChargeCurrent_16uA | Reference oscillator charge current is 16 µA.
kTSI_RefOscChargeCurrent_32uA | Reference oscillator charge current is 32 µA.
kTSI_RefOscChargeCurrent_64uA | Reference oscillator charge current is 64 µA.

enum tsi_osc_voltage_rails_t

These bits indicate the oscillator's voltage rails.

Enumerator
kTSI_OscVolRailsOption_0 | DVOLT value option 0, the value may differ on different platforms.
kTSI_OscVolRailsOption_1 | DVOLT value option 1, the value may differ on different platforms.
kTSI_OscVolRailsOption_2 | DVOLT value option 2, the value may differ on different platforms.
kTSI_OscVolRailsOption_3 | DVOLT value option 3, the value may differ on different platforms.

enum tsi_external_osc_charge_current_t

These bits indicate the electrode oscillator charge and discharge current value in TSI (EXTCHRG) instance.

Enumerator
kTSI_ExtOscChargeCurrent_2uA | External oscillator charge current is 2 µA.
kTSI_ExtOscChargeCurrent_4uA | External oscillator charge current is 4 µA.
kTSI_ExtOscChargeCurrent_6uA | External oscillator charge current is 6 µA.
kTSI_ExtOscChargeCurrent_8uA | External oscillator charge current is 8 µA.
kTSI_ExtOscChargeCurrent_10uA | External oscillator charge current is 10 µA.
kTSI_ExtOscChargeCurrent_12uA | External oscillator charge current is 12 µA.
kTSI_ExtOscChargeCurrent_14uA | External oscillator charge current is 14 µA.
kTSI_ExtOscChargeCurrent_16uA | External oscillator charge current is 16 µA.
kTSI_ExtOscChargeCurrent_18uA | External oscillator charge current is 18 µA.
kTSI_ExtOscChargeCurrent_20uA | External oscillator charge current is 20 µA.
kTSI_ExtOscChargeCurrent_22uA | External oscillator charge current is 22 µA.
kTSI_ExtOscChargeCurrent_24uA | External oscillator charge current is 24 µA.
kTSI_ExtOscChargeCurrent_26uA | External oscillator charge current is 26 µA.
kTSI_ExtOscChargeCurrent_28uA | External oscillator charge current is 28 µA.
kTSI_ExtOscChargeCurrent_30uA | External oscillator charge current is 30 µA.
kTSI_ExtOscChargeCurrent_32uA | External oscillator charge current is 32 µA.
kTSI_ExtOscChargeCurrent_500nA | External oscillator charge current is 500 µA.
kTSI_ExtOscChargeCurrent_1uA | External oscillator charge current is 1 µA.
kTSI_ExtOscChargeCurrent_2uA | External oscillator charge current is 2 µA.
kTSI_ExtOscChargeCurrent_4uA | External oscillator charge current is 4 µA.
kTSI_ExtOscChargeCurrent_8uA | External oscillator charge current is 8 µA.
kTSI_ExtOscChargeCurrent_16uA | External oscillator charge current is 16 µA.
kTSI_ExtOscChargeCurrent_32uA | External oscillator charge current is 32 µA.
kTSI_ExtOscChargeCurrent_64uA | External oscillator charge current is 64 µA.

enum tsi_series_resistor_t

These bits indicate the electrode RS series resistance for the noise mode in TSI (EXTCHRG) instance.

Enumerator
kTSI_SeriesResistance_32k | Series Resistance is 32 kilo ohms.
kTSI_SeriesResistance_187k | Series Resistance is 18 7 kilo ohms.

enum tsi_filter_bits_t

These bits indicate the count of the filter bits in TSI noise mode EXTCHRG[2:1] bits

Enumerator
kTSI_FilterBits_3 | 3 filter bits, 8 peaks increments the cnt+1
kTSI_FilterBits_2 | 2 filter bits, 4 peaks increments the cnt+1
kTSI_FilterBits_1 | 1 filter bits, 2 peaks increments the cnt+1
kTSI_FilterBits_0 | no filter bits,1 peak increments the cnt+1

enum tsi_status_flags_t

Enumerator
kTSI_EndOfScanFlag | End-Of-Scan flag.
kTSI_OutOfRangeFlag | Out-Of-Range flag.
kTSI_ExternalElectrodeErrorFlag | External electrode error flag.
kTSI_OverrunErrorFlag | Overrun error flag.
kTSI_EndOfScanFlag | End-Of-Scan flag.
kTSI_OutOfRangeFlag | Out-Of-Range flag.

enum tsi_interrupt_enable_t

Enumerator
kTSI_GlobalInterruptEnable | TSI module global interrupt.
kTSI_OutOfRangeInterruptEnable | Out-Of-Range interrupt.
kTSI_EndOfScanInterruptEnable | End-Of-Scan interrupt.
kTSI_ErrorInterrruptEnable | Error interrupt.
kTSI_GlobalInterruptEnable | TSI module global interrupt.
kTSI_OutOfRangeInterruptEnable | Out-Of-Range interrupt.
kTSI_EndOfScanInterruptEnable | End-Of-Scan interrupt.

## Function Documentation

void TSI_Init | ( | TSI_Type * | base,
|  | const tsi_config_t * | config
| ) |  |

Initializes the peripheral to the targeted state specified by parameter configuration, such as sets prescalers, number of scans, clocks, delta voltage series resistor, filter bits, reference, and electrode charge current and threshold.

Parameters

  base | TSI peripheral base address.
  config | Pointer to TSI module configuration structure.

Returns
  none

void TSI_Deinit | ( | TSI_Type * | base | ) |

De-initializes the peripheral to default state.

Parameters

  base | TSI peripheral base address.

Returns
  none

void TSI_GetNormalModeDefaultConfig | ( | tsi_config_t * | userConfig | ) |

This interface sets userConfig structure to a default value. The configuration structure only includes the settings for the whole TSI. The user configure is set to these values:

userConfig->prescaler = kTSI_ElecOscPrescaler_2div;
userConfig->extchrg = kTSI_ExtOscChargeCurrent_4uA;
userConfig->refchrg = kTSI_RefOscChargeCurrent_4uA;
userConfig->nscn = kTSI_ConsecutiveScansNumber_10time;
userConfig->mode = kTSI_AnalogModeSel_Capacitive;
userConfig->dvolt = kTSI_OscVolRailsOption_0;
userConfig->resistor = kTSI_SeriesResistance_32k;
userConfig->filter = kTSI_FilterBits_1;
userConfig->thresh = 0U;
userConfig->thresl = 0U;

Parameters

  userConfig | Pointer to the TSI user configuration structure.

void TSI_GetLowPowerModeDefaultConfig | ( | tsi_config_t * | userConfig | ) |

This interface sets userConfig structure to a default value. The configuration structure only includes the settings for the whole TSI. The user configure is set to these values:

userConfig->prescaler = kTSI_ElecOscPrescaler_2div;
userConfig->extchrg = kTSI_ExtOscChargeCurrent_4uA;
userConfig->refchrg = kTSI_RefOscChargeCurrent_4uA;
userConfig->nscn = kTSI_ConsecutiveScansNumber_10time;
userConfig->mode = kTSI_AnalogModeSel_Capacitive;
userConfig->dvolt = kTSI_OscVolRailsOption_0;
userConfig->resistor = kTSI_SeriesResistance_32k;
userConfig->filter = kTSI_FilterBits_1;
userConfig->thresh = 400U;
userConfig->thresl = 0U;

Parameters

  userConfig | Pointer to the TSI user configuration structure.

void TSI_Calibrate | ( | TSI_Type * | base,
|  | tsi_calibration_data_t * | calBuff
| ) |  |

Calibrates the peripheral to fetch the initial counter value of the enabled electrodes. This API is mostly used at initial application setup. Call this function after the TSI_Init API and use the calibrated counter values to set up applications (such as to determine under which counter value we can confirm a touch event occurs).

Parameters

  base | TSI peripheral base address.
  calBuff | Data buffer that store the calibrated counter value.

Returns
  none

void TSI_EnableInterrupts | ( | TSI_Type * | base,
|  | uint32_t | mask
| ) |  |

Parameters

  base | TSI peripheral base address.
  mask | interrupt source The parameter can be combination of the following source if defined: kTSI_GlobalInterruptEnable kTSI_EndOfScanInterruptEnable kTSI_OutOfRangeInterruptEnable

void TSI_DisableInterrupts | ( | TSI_Type * | base,
|  | uint32_t | mask
| ) |  |

Parameters

  base | TSI peripheral base address.
  mask | interrupt source The parameter can be combination of the following source if defined: kTSI_GlobalInterruptEnable kTSI_EndOfScanInterruptEnable kTSI_OutOfRangeInterruptEnable

static uint32_t TSI_GetStatusFlags | ( | TSI_Type * | base | ) |
| inline static

This function gets the TSI interrupt flags.

Parameters

  base | TSI peripheral base address.

Returns
  The mask of these status flags combination.

void TSI_ClearStatusFlags | ( | TSI_Type * | base,
|  | uint32_t | mask
| ) |  |

This function clears the TSI interrupt flag, automatically cleared flags can't be cleared by this function.

Parameters

  base | TSI peripheral base address.
  mask | The status flags to clear.

static uint32_t TSI_GetScanTriggerMode | ( | TSI_Type * | base | ) |
| inline static

Parameters

  base | TSI peripheral base address.

Returns
  Scan trigger mode.

static bool TSI_IsScanInProgress | ( | TSI_Type * | base | ) |
| inline static

Parameters

  base | TSI peripheral base address.

Returns
  True - scan is in progress. False - scan is not in progress.

static void TSI_SetElectrodeOSCPrescaler | ( | TSI_Type * | base,
|  | tsi_electrode_osc_prescaler_t | prescaler
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  prescaler | Prescaler value.

Returns
  none.

static void TSI_SetNumberOfScans | ( | TSI_Type * | base,
|  | tsi_n_consecutive_scans_t | number
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  number | Number of scans.

Returns
  none.

static void TSI_EnableModule | ( | TSI_Type * | base,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  enable | Choose whether to enable or disable module; true Enable TSI module; false Disable TSI module;

Returns
  none.

static void TSI_EnableLowPower | ( | TSI_Type * | base,
|  | bool | enable
| ) |  |
| inline static

This enables the TSI module function in low power modes.

Parameters

  base | TSI peripheral base address.
  enable | Choose to enable or disable STOP mode. true Enable module in STOP mode; false Disable module in STOP mode;

Returns
  none.

static void TSI_EnableHardwareTriggerScan | ( | TSI_Type * | base,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  enable | Choose to enable hardware trigger or software trigger scan. true Enable hardware trigger scan; false Enable software trigger scan;

Returns
  none.

static void TSI_StartSoftwareTrigger | ( | TSI_Type * | base | ) |
| inline static

Parameters

  base | TSI peripheral base address.

Returns
  none.

static void TSI_SetMeasuredChannelNumber | ( | TSI_Type * | base,
|  | uint8_t | channel
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  channel | Channel number 0 ... 15.

Returns
  none.

static uint8_t TSI_GetMeasuredChannelNumber | ( | TSI_Type * | base | ) |
| inline static

Parameters

  base | TSI peripheral base address.

Returns
  uint8_t Channel number 0 ... 15.

static void TSI_EnableDmaTransfer | ( | TSI_Type * | base,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  enable | Choose to enable DMA transfer or not. true Enable DMA transfer; false Disable DMA transfer;

Returns
  none.

static uint16_t TSI_GetCounter | ( | TSI_Type * | base | ) |
| inline static

Parameters

  base | TSI peripheral base address.

Returns
  Accumulated scan counter value ticked by the reference clock.

static void TSI_SetLowThreshold | ( | TSI_Type * | base,
|  | uint16_t | low_threshold
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  low_threshold | Low counter threshold.

Returns
  none.

static void TSI_SetHighThreshold | ( | TSI_Type * | base,
|  | uint16_t | high_threshold
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  high_threshold | High counter threshold.

Returns
  none.

static void TSI_SetAnalogMode | ( | TSI_Type * | base,
|  | tsi_analog_mode_t | mode
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  mode | Mode value.

Returns
  none.

static uint8_t TSI_GetNoiseModeResult | ( | TSI_Type * | base | ) |
| inline static

Parameters

  base | TSI peripheral base address.

Returns
  Value of the GENCS[MODE] bit-fields.

static void TSI_SetReferenceChargeCurrent | ( | TSI_Type * | base,
|  | tsi_reference_osc_charge_current_t | current
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  current | The reference oscillator charge current.

Returns
  none.

static void TSI_SetElectrodeChargeCurrent | ( | TSI_Type * | base,
|  | tsi_external_osc_charge_current_t | current
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  current | External electrode charge current.

Returns
  none.

static void TSI_SetOscVoltageRails | ( | TSI_Type * | base,
|  | tsi_osc_voltage_rails_t | dvolt
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  dvolt | The voltage rails.

Returns
  none.

static void TSI_SetElectrodeSeriesResistor | ( | TSI_Type * | base,
|  | tsi_series_resistor_t | resistor
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  resistor | Series resistance.

Returns
  none.

static void TSI_SetFilterBits | ( | TSI_Type * | base,
|  | tsi_filter_bits_t | filter
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  filter | Series resistance.

Returns
  none.