MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
TSC: Touch Screen Controller Driver

Overview

The MCUXpresso SDK provides Peripheral driver for the Touch Screen Controller(TSC) module of MCUXpresso SDK devices.

Typical use case

4-wire Polling Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/fsl_tsc

4-wire Interrupt Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/fsl_tsc

Data Structures

struct  tsc_config_t
 @ Controller configuration. More...
 

Macros

#define FSL_TSC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 TSC driver version. More...
 

Enumerations

enum  tsc_detection_mode_t {
  kTSC_Detection4WireMode = 0U,
  kTSC_Detection5WireMode = 1U
}
 @ Controller detection mode. More...
 
enum  tsc_corrdinate_value_selection_t {
  kTSC_XCoordinateValueSelection = 0U,
  kTSC_YCoordinateValueSelection = 1U
}
 @ Coordinate value mask. More...
 
enum  _tsc_interrupt_signal_mask {
  kTSC_IdleSoftwareSignalEnable = TSC_INT_SIG_EN_IDLE_SW_SIG_EN_MASK,
  kTSC_ValidSignalEnable,
  kTSC_DetectSignalEnable,
  kTSC_MeasureSignalEnable = TSC_INT_SIG_EN_MEASURE_SIG_EN_MASK
}
 @ Interrupt signal enable/disable mask. More...
 
enum  _tsc_interrupt_mask {
  kTSC_IdleSoftwareInterruptEnable,
  kTSC_DetectInterruptEnable,
  kTSC_MeasureInterruptEnable = TSC_INT_EN_MEASURE_INT_EN_MASK
}
 @ Interrupt enable/disable mask. More...
 
enum  _tsc_interrupt_status_flag_mask {
  kTSC_IdleSoftwareFlag,
  kTSC_ValidSignalFlag,
  kTSC_DetectSignalFlag = TSC_INT_STATUS_DETECT_MASK,
  kTSC_MeasureSignalFlag
}
 @ Interrupt Status flag mask. More...
 
enum  _tsc_adc_status_flag_mask {
  kTSC_ADCCOCOSignalFlag,
  kTSC_ADCConversionValueFlag
}
 @ ADC status flag mask. More...
 
enum  _tsc_status_flag_mask {
  kTSC_IntermediateStateFlag = TSC_DEBUG_MODE2_INTERMEDIATE_MASK,
  kTSC_DetectFiveWireFlag = TSC_DEBUG_MODE2_DETECT_FIVE_WIRE_MASK,
  kTSC_DetectFourWireFlag = TSC_DEBUG_MODE2_DETECT_FOUR_WIRE_MASK,
  kTSC_GlitchThresholdFlag = TSC_DEBUG_MODE2_DE_GLITCH_MASK,
  kTSC_StateMachineFlag
}
 @ TSC status flag mask. More...
 
enum  tsc_state_machine_t {
  kTSC_IdleState = 0U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT,
  kTSC_1stPreChargeState = 1U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT,
  kTSC_1stDetectState = 2U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT,
  kTSC_XMeasureState = 3U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT,
  kTSC_YMeasureState = 4U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT,
  kTSC_2ndPreChargeState = 5U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT,
  kTSC_2ndDetectState = 6U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT
}
 TSC state machine. More...
 
enum  tsc_glitch_threshold_t {
  kTSC_glitchThresholdALT0,
  kTSC_glitchThresholdALT1,
  kTSC_glitchThresholdALT2,
  kTSC_glitchThresholdALT3
}
 TSC glitch threshold. More...
 
enum  tsc_trigger_signal_t {
  kTSC_TriggerToChannel0 = 1U << 0U,
  kTSC_TriggerToChannel1 = 1U << 1U,
  kTSC_TriggerToChannel2 = 1U << 2U,
  kTSC_TriggerToChannel3 = 1U << 3U,
  kTSC_TriggerToChannel4 = 1U << 4U
}
 @ Hardware trigger select signal, select which ADC channel to start conversion. More...
 
enum  tsc_port_source_t {
  kTSC_WiperPortSource = 0U,
  kTSC_YnlrPortSource = 1U,
  kTSC_YpllPortSource = 2U,
  kTSC_XnurPortSource = 3U,
  kTSC_XpulPortSource = 4U
}
 @ TSC controller ports. More...
 
enum  tsc_port_mode_t {
  kTSC_PortOffMode = 0U,
  kTSC_Port200k_PullUpMode = 1U << 2U,
  kTSC_PortPullUpMode = 1U << 1U,
  kTSC_PortPullDownMode = 1U << 0U
}
 @ TSC port mode. More...
 

Functions

void TSC_Init (TSC_Type *base, const tsc_config_t *config)
 Initialize the TSC module. More...
 
void TSC_Deinit (TSC_Type *base)
 De-initializes the TSC module. More...
 

Variables

bool tsc_config_t::enableAutoMeasure
 Enable the auto-measure. More...
 
uint32_t tsc_config_t::measureDelayTime
 Set delay time(0U~0xFFFFFFU) to even potential distribution ready.It is a preparation for measure stage. More...
 
uint32_t tsc_config_t::prechargeTime
 Set pre-charge time(1U~0xFFFFFFFFU) to make the upper layer of screen to charge to positive high. More...
 
tsc_detection_mode_t tsc_config_t::detectionMode
 Select the detection mode. More...
 

Data Structure Documentation

struct tsc_config_t

Data Fields

bool enableAutoMeasure
 Enable the auto-measure. More...
 
uint32_t measureDelayTime
 Set delay time(0U~0xFFFFFFU) to even potential distribution ready.It is a preparation for measure stage. More...
 
uint32_t prechargeTime
 Set pre-charge time(1U~0xFFFFFFFFU) to make the upper layer of screen to charge to positive high. More...
 
tsc_detection_mode_t detectionMode
 Select the detection mode. More...
 

Macro Definition Documentation

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

Version 2.0.0.

Enumeration Type Documentation

Enumerator
kTSC_Detection4WireMode 

4-Wire Detection Mode.

kTSC_Detection5WireMode 

5-Wire Detection Mode.

Enumerator
kTSC_XCoordinateValueSelection 

X coordinate value is selected.

kTSC_YCoordinateValueSelection 

Y coordinate value is selected.

Enumerator
kTSC_IdleSoftwareSignalEnable 

Enable the interrupt signal when the controller has return to idle status.

The signal is only valid after using TSC_ReturnToIdleStatus API.

kTSC_ValidSignalEnable 

Enable the interrupt signal when controller receives a detect signal after measurement.

kTSC_DetectSignalEnable 

Enable the interrupt signal when controller receives a detect signal.

kTSC_MeasureSignalEnable 

Enable the interrupt signal after the touch detection which follows measurement.

Enumerator
kTSC_IdleSoftwareInterruptEnable 

Enable the interrupt when the controller has return to idle status.

The interrupt is only valid after using TSC_ReturnToIdleStatus API.

kTSC_DetectInterruptEnable 

Enable the interrupt when controller receive a detect signal.

kTSC_MeasureInterruptEnable 

Enable the interrupt after the touch detection which follows measurement.

Enumerator
kTSC_IdleSoftwareFlag 

This flag is set if the controller has return to idle status.

The flag is only valid after using TSC_ReturnToIdleStatus API.

kTSC_ValidSignalFlag 

This flag is set if controller receives a detect signal after measurement.

kTSC_DetectSignalFlag 

This flag is set if controller receives a detect signal.

kTSC_MeasureSignalFlag 

This flag is set after the touch detection which follows measurement.

Note: Valid signal falg will be cleared along with measure signal flag.

Enumerator
kTSC_ADCCOCOSignalFlag 

This signal is generated by ADC when a conversion is completed.

kTSC_ADCConversionValueFlag 

This signal is generated by ADC and indicates the result of an ADC conversion.

Enumerator
kTSC_IntermediateStateFlag 

This flag is set if TSC is in intermediate state, between two state machine states.

kTSC_DetectFiveWireFlag 

This flag is set if TSC receives a 5-wire detect signal.

It is only valid when the TSC in detect state and DETECT_ENABLE_FIVE_WIRE bit is set.

kTSC_DetectFourWireFlag 

This flag is set if TSC receives a 4-wire detect signal.

It is only valid when the TSC in detect state and DETECT_ENABLE_FOUR_WIRE bit is set.

kTSC_GlitchThresholdFlag 

This field indicates glitch threshold.The threshold is defined by number of clock cycles.

See "tsc_glitch_threshold_t". If value = 00, Normal function: 0x1fff ipg clock cycles, Low power mode: 0x9 low power clock cycles. If value = 01, Normal function: 0xfff ipg clock cycles, Low power mode: :0x7 low power clock cycles. If value = 10, Normal function: 0x7ff ipg clock cycles, Low power mode:0x5 low power clock cycles. If value = 11, Normal function: 0x3 ipg clock cycles, Low power mode:0x3 low power clock cycles.

kTSC_StateMachineFlag 

This field indicates the state of TSC.

See "tsc_state_machine_t"; if value = 000, Controller is in idle state. if value = 001, Controller is in 1st-Pre-charge state. if value = 010, Controller is in 1st-detect state. if value = 011, Controller is in x-measure state. if value = 100, Controller is in y-measure state. if value = 101, Controller is in 2nd-Pre-charge state. if value = 110, Controller is in 2nd-detect state.

These seven states are TSC complete workflow.

Enumerator
kTSC_IdleState 

Controller is in idle state.

kTSC_1stPreChargeState 

Controller is in 1st-Pre-charge state.

kTSC_1stDetectState 

Controller is in 1st-detect state.

kTSC_XMeasureState 

Controller is in x-measure state.

kTSC_YMeasureState 

Controller is in y-measure state.

kTSC_2ndPreChargeState 

Controller is in 2nd-Pre-charge state.

kTSC_2ndDetectState 

Controller is in 2nd-detect state.

Enumerator
kTSC_glitchThresholdALT0 

Normal function: 0x1fff ipg clock cycles, Low power mode: 0x9 low power clock cycles.

kTSC_glitchThresholdALT1 

Normal function: 0xfff ipg clock cycles, Low power mode: :0x7 low power clock cycles.

kTSC_glitchThresholdALT2 

Normal function: 0x7ff ipg clock cycles, Low power mode: :0x5 low power clock cycles.

kTSC_glitchThresholdALT3 

Normal function: 0x3 ipg clock cycles, Low power mode: :0x3 low power clock cycles.

Enumerator
kTSC_TriggerToChannel0 

Trigger to ADC channel0.

ADC_HC0 register will be used to conversion.

kTSC_TriggerToChannel1 

Trigger to ADC channel1.

ADC_HC1 register will be used to conversion.

kTSC_TriggerToChannel2 

Trigger to ADC channel2.

ADC_HC2 register will be used to conversion.

kTSC_TriggerToChannel3 

Trigger to ADC channel3.

ADC_HC3 register will be used to conversion.

kTSC_TriggerToChannel4 

Trigger to ADC channel4.

ADC_HC4 register will be used to conversion.

Enumerator
kTSC_WiperPortSource 

TSC controller wiper port.

kTSC_YnlrPortSource 

TSC controller ynlr port.

kTSC_YpllPortSource 

TSC controller ypll port.

kTSC_XnurPortSource 

TSC controller xnur port.

kTSC_XpulPortSource 

TSC controller xpul port.

Enumerator
kTSC_PortOffMode 

Disable pull up/down mode.

kTSC_Port200k_PullUpMode 

200k-pull up mode.

kTSC_PortPullUpMode 

Pull up mode.

kTSC_PortPullDownMode 

Pull down mode.

Function Documentation

void TSC_Init ( TSC_Type *  base,
const tsc_config_t config 
)
Parameters
baseTSC peripheral base address.
configPointer to "tsc_config_t" structure.
void TSC_Deinit ( TSC_Type *  base)
Parameters
baseTSC peripheral base address.

Variable Documentation

bool tsc_config_t::enableAutoMeasure

It indicates after detect touch, whether automatic start measurement

uint32_t tsc_config_t::measureDelayTime

If measure dalay time is too short, maybe it would have an undesired effect on measure value.

uint32_t tsc_config_t::prechargeTime

It is a preparation for detection stage. Pre-charge time must is greater than 0U, otherwise TSC could not work normally. If pre-charge dalay time is too short, maybe it would have an undesired effect on generation of valid signal(kTSC_ValidSignalFlag).

tsc_detection_mode_t tsc_config_t::detectionMode

See "tsc_detection_mode_t".