| 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 | Enumerations | Functions
TSIv2 Driver
TSI: Touch Sensing Input

## Overview

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

# Typical use case

TSI_Init(TSI0);
TSI_Configure(TSI0, &user_config);
TSI_EnableChannel(TSI0, channelMask);
TSI_EnableInterrupts(TSI0, kTSI_GlobalInterruptEnable | kTSI_EndOfScanInterruptEnable);
TSI_EnablePeriodicalScan(TSI0);
TSI_EnableModule(TSI0);
while(1);

## Files
file | fsl_tsi_v2.h

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

## 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_low_power_clock_source_t { kTSI_LowPowerClockSource_LPOCLK = 0U, kTSI_LowPowerClockSource_VLPOSCCLK = 1U }
| TSI low power mode clock source. More...
enum | tsi_low_power_scan_interval_t { kTSI_LowPowerInterval_1ms = 0U, kTSI_LowPowerInterval_5ms = 1U, kTSI_LowPowerInterval_10ms = 2U, kTSI_LowPowerInterval_15ms = 3U, kTSI_LowPowerInterval_20ms = 4U, kTSI_LowPowerInterval_30ms = 5U, kTSI_LowPowerInterval_40ms = 6U, kTSI_LowPowerInterval_50ms = 7U, kTSI_LowPowerInterval_75ms = 8U, kTSI_LowPowerInterval_100ms = 9U, kTSI_LowPowerInterval_125ms = 10U, kTSI_LowPowerInterval_150ms = 11U, kTSI_LowPowerInterval_200ms = 12U, kTSI_LowPowerInterval_300ms = 13U, kTSI_LowPowerInterval_400ms = 14U, kTSI_LowPowerInterval_500ms = 15U }
| TSI low power scan intervals. 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 current select. 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 current select. More...
enum | tsi_active_mode_clock_source_t { kTSI_ActiveClkSource_LPOSCCLK = 0U, kTSI_ActiveClkSource_MCGIRCLK = 1U, kTSI_ActiveClkSource_OSCERCLK = 2U }
| TSI Active mode clock source. More...
enum | tsi_active_mode_prescaler_t { kTSI_ActiveModePrescaler_1div = 0U, kTSI_ActiveModePrescaler_2div = 1U, kTSI_ActiveModePrescaler_4div = 2U, kTSI_ActiveModePrescaler_8div = 3U, kTSI_ActiveModePrescaler_16div = 4U, kTSI_ActiveModePrescaler_32div = 5U, kTSI_ActiveModePrescaler_64div = 6U, kTSI_ActiveModePrescaler_128div = 7U }
| TSI active mode prescaler. 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 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 the interrupt flags. More...
void | TSI_ClearStatusFlags (TSI_Type *base, uint32_t mask)
| Clears the interrupt flags. 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 electrode oscillator 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)
| Enables/disables the TSI module in low power stop mode. More...
static void | TSI_EnablePeriodicalScan (TSI_Type *base, bool enable)
| Enables/disables the periodical (hardware) trigger scan. More...
static void | TSI_StartSoftwareTrigger (TSI_Type *base)
| Starts a measurement (trigger a new measurement). More...
static void | TSI_SetLowPowerScanInterval (TSI_Type *base, tsi_low_power_scan_interval_t interval)
| Sets a low power scan interval. More...
static void | TSI_SetLowPowerClock (TSI_Type *base, uint32_t clock)
| Sets a low power clock. 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 electrode charge current. More...
static void | TSI_SetScanModulo (TSI_Type *base, uint32_t modulo)
| Sets the scan modulo value. More...
static void | TSI_SetActiveModeSource (TSI_Type *base, uint32_t source)
| Sets the active mode source. More...
static void | TSI_SetActiveModePrescaler (TSI_Type *base, tsi_active_mode_prescaler_t prescaler)
| Sets the active mode prescaler. More...
static void | TSI_SetLowPowerChannel (TSI_Type *base, uint16_t channel)
| Sets the low power channel. More...
static uint32_t | TSI_GetLowPowerChannel (TSI_Type *base)
| Gets the enabled channel in low power modes. More...
static void | TSI_EnableChannel (TSI_Type *base, uint16_t channel, bool enable)
| Enables/disables a channel. More...
static void | TSI_EnableChannels (TSI_Type *base, uint16_t channelsMask, bool enable)
| Enables/disables channels. More...
static bool | TSI_IsChannelEnabled (TSI_Type *base, uint16_t channel)
| Returns if a channel is enabled. More...
static uint16_t | TSI_GetEnabledChannels (TSI_Type *base)
| Returns the mask of enabled channels. More...
static uint16_t | TSI_GetWakeUpChannelCounter (TSI_Type *base)
| Gets the wake up channel counter for low-power mode usage. More...
static uint16_t | TSI_GetNormalModeCounter (TSI_Type *base, uint16_t channel)
| Gets the TSI conversion counter of a specific channel in normal mode. More...
static void | TSI_SetLowThreshold (TSI_Type *base, uint16_t low_threshold)
| Sets a low threshold. More...
static void | TSI_SetHighThreshold (TSI_Type *base, uint16_t high_threshold)
| Sets a high threshold. 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_low_power_clock_source_t

Enumerator
kTSI_LowPowerClockSource_LPOCLK | LPOCLK is selected.
kTSI_LowPowerClockSource_VLPOSCCLK | VLPOSCCLK is selected.

enum tsi_low_power_scan_interval_t

These constants define the TSI low power scan intervals in a TSI instance.

Enumerator
kTSI_LowPowerInterval_1ms | 1 ms scan interval
kTSI_LowPowerInterval_5ms | 5 ms scan interval
kTSI_LowPowerInterval_10ms | 10 ms scan interval
kTSI_LowPowerInterval_15ms | 15 ms scan interval
kTSI_LowPowerInterval_20ms | 20 ms scan interval
kTSI_LowPowerInterval_30ms | 30 ms scan interval
kTSI_LowPowerInterval_40ms | 40 ms scan interval
kTSI_LowPowerInterval_50ms | 50 ms scan interval
kTSI_LowPowerInterval_75ms | 75 ms scan interval
kTSI_LowPowerInterval_100ms | 100 ms scan interval
kTSI_LowPowerInterval_125ms | 125 ms scan interval
kTSI_LowPowerInterval_150ms | 150 ms scan interval
kTSI_LowPowerInterval_200ms | 200 ms scan interval
kTSI_LowPowerInterval_300ms | 300 ms scan interval
kTSI_LowPowerInterval_400ms | 400 ms scan interval
kTSI_LowPowerInterval_500ms | 500 ms scan interval

enum tsi_reference_osc_charge_current_t

These constants define the TSI Reference oscillator charge current select in a TSI 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_external_osc_charge_current_t

These constants define the TSI External oscillator charge current select in a TSI 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_active_mode_clock_source_t

These constants define the active mode clock source in a TSI instance.

Enumerator
kTSI_ActiveClkSource_LPOSCCLK | Active mode clock source is set to LPOOSC Clock.
kTSI_ActiveClkSource_MCGIRCLK | Active mode clock source is set to MCG Internal reference clock.
kTSI_ActiveClkSource_OSCERCLK | Active mode clock source is set to System oscillator output.

enum tsi_active_mode_prescaler_t

These constants define the TSI active mode prescaler in a TSI instance.

Enumerator
kTSI_ActiveModePrescaler_1div | Input clock source divided by 1.
kTSI_ActiveModePrescaler_2div | Input clock source divided by 2.
kTSI_ActiveModePrescaler_4div | Input clock source divided by 4.
kTSI_ActiveModePrescaler_8div | Input clock source divided by 8.
kTSI_ActiveModePrescaler_16div | Input clock source divided by 16.
kTSI_ActiveModePrescaler_32div | Input clock source divided by 32.
kTSI_ActiveModePrescaler_64div | Input clock source divided by 64.
kTSI_ActiveModePrescaler_128div | Input clock source divided by 128.

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 the parameter configuration, such as initialize and set prescalers, number of scans, clocks, delta voltage capacitance trimmer, reference, and electrode charge current and threshold.

Parameters

  base | TSI peripheral base address.
  config | Pointer to the TSI peripheral 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 the 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.lpclks = kTSI_LowPowerClockSource_LPOCLK;
userConfig.lpscnitv = kTSI_LowPowerInterval_100ms;
userConfig.amclks = kTSI_ActiveClkSource_LPOSCCLK;
userConfig.ampsc = kTSI_ActiveModePrescaler_8div;
userConfig.ps = kTSI_ElecOscPrescaler_2div;
userConfig.extchrg = kTSI_ExtOscChargeCurrent_10uA;
userConfig.refchrg = kTSI_RefOscChargeCurrent_10uA;
userConfig.nscn = kTSI_ConsecutiveScansNumber_8time;
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.lpclks = kTSI_LowPowerClockSource_LPOCLK;
userConfig.lpscnitv = kTSI_LowPowerInterval_100ms;
userConfig.amclks = kTSI_ActiveClkSource_LPOSCCLK;
userConfig.ampsc = kTSI_ActiveModePrescaler_64div;
userConfig.ps = kTSI_ElecOscPrescaler_1div;
userConfig.extchrg = kTSI_ExtOscChargeCurrent_2uA;
userConfig.refchrg = kTSI_RefOscChargeCurrent_32uA;
userConfig.nscn = kTSI_ConsecutiveScansNumber_26time;
userConfig.thresh = 15000U;
userConfig.thresl = 1000U;

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 the 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 a touch event occurs).

Note
  This API is called in normal power modes.
  For K60 series, the calibrated baseline counter value CANNOT be used in low power modes. To obtain the calibrated counter values in low power modes, see K60 Mask Set Errata for Mask 5N22D.

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 a combination of the following source if defined: kTSI_GlobalInterruptEnable kTSI_EndOfScanInterruptEnable kTSI_OutOfRangeInterruptEnable kTSI_ErrorInterrruptEnable

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

Parameters

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

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

This function get TSI interrupt flags.

Parameters

  base | TSI peripheral base address.

Returns
  The mask of these status flag bits.

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

This function clears the TSI interrupt flags.

Note
  The 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 - if scan is in progress. False - if 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 TSI module. true Enable module; false Disable module;

Returns
  none.

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

Parameters

  base | TSI peripheral base address.
  enable | Choose whether to enable TSI module in low power modes. true Enable module in low power modes; false Disable module in low power modes;

Returns
  none.

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

Parameters

  base | TSI peripheral base address.
  enable | Choose whether to enable periodical trigger scan. true Enable periodical 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_SetLowPowerScanInterval | ( | TSI_Type * | base,
|  | tsi_low_power_scan_interval_t | interval
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  interval | Interval for low power scan.

Returns
  none.

static void TSI_SetLowPowerClock | ( | TSI_Type * | base,
|  | uint32_t | clock
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  clock | Low power clock selection.

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 | The external electrode charge current.

Returns
  none.

static void TSI_SetScanModulo | ( | TSI_Type * | base,
|  | uint32_t | modulo
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  modulo | Scan modulo value.

Returns
  none.

static void TSI_SetActiveModeSource | ( | TSI_Type * | base,
|  | uint32_t | source
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  source | Active mode clock source (LPOSCCLK, MCGIRCLK, OSCERCLK).

Returns
  none.

static void TSI_SetActiveModePrescaler | ( | TSI_Type * | base,
|  | tsi_active_mode_prescaler_t | prescaler
| ) |  |
| inline static

Parameters

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

Returns
  none.

static void TSI_SetLowPowerChannel | ( | TSI_Type * | base,
|  | uint16_t | channel
| ) |  |
| inline static

Only one channel can be enabled in low power mode.

Parameters

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

Returns
  none.

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

Note
  Only one channel can be enabled in low power mode.

Parameters

  base | TSI peripheral base address.

Returns
  Channel number.

static void TSI_EnableChannel | ( | TSI_Type * | base,
|  | uint16_t | channel,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  channel | Channel to be enabled.
  enable | Choose whether to enable specific channel. true Enable the specific channel; false Disable the specific channel;

Returns
  none.

static void TSI_EnableChannels | ( | TSI_Type * | base,
|  | uint16_t | channelsMask,
|  | bool | enable
| ) |  |
| inline static

The function enables or disables channels by mask. It can enable/disable all channels at once.

Parameters

  base | TSI peripheral base address.
  channelsMask | Channels mask that indicate channels that are to be enabled/disabled.
  enable | Choose to enable or disable the specified channels. true Enable the specified channels; false Disable the specified channels;

Returns
  none.

static bool TSI_IsChannelEnabled | ( | TSI_Type * | base,
|  | uint16_t | channel
| ) |  |
| inline static

Parameters

  base | TSI peripheral base address.
  channel | Channel to be checked.

Returns
  true - if the channel is enabled; false - if the channel is disabled;

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

Parameters

  base | TSI peripheral base address.

Returns
  Channels mask that indicates currently enabled channels.

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

Parameters

  base | TSI peripheral base address.

Returns
  Wake up counter value.

static uint16_t TSI_GetNormalModeCounter | ( | TSI_Type * | base,
|  | uint16_t | channel
| ) |  |
| inline static

Note
  This API can only be used in normal active modes.

Parameters

  base | TSI peripheral base address.
  channel | Index of the specific TSI channel.

Returns
  The counter value of the specific channel.

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.