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 a 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, 3))
 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 = TSC_INT_SIG_EN_VALID_SIG_EN_MASK,
  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 = TSC_DEBUG_MODE_ADC_CONV_VALUE_MASK
}
 @ 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 = 0U << TSC_DEBUG_MODE2_DE_GLITCH_SHIFT,
  kTSC_glitchThresholdALT1 = 1U << TSC_DEBUG_MODE2_DE_GLITCH_SHIFT,
  kTSC_glitchThresholdALT2 = 2U << TSC_DEBUG_MODE2_DE_GLITCH_SHIFT,
  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...
 
void TSC_GetDefaultConfig (tsc_config_t *config)
 Gets an available pre-defined settings for the controller's configuration. More...
 
static void TSC_ReturnToIdleStatus (TSC_Type *base)
 Make the TSC module return to idle status after finish the current state operation. More...
 
static void TSC_StartSenseDetection (TSC_Type *base)
 Start sense detection and (if work in auto-measure mode) measure after detect a touch. More...
 
static void TSC_StartMeasure (TSC_Type *base)
 start measure X/Y coordinate value after detect a touch. More...
 
static void TSC_DropMeasure (TSC_Type *base)
 Drop measure X/Y coordinate value after detect a touch and controller return to idle status. More...
 
static void TSC_SoftwareReset (TSC_Type *base)
 This is a synchronization reset, which resets every register except IPS directly access ones. More...
 
uint32_t TSC_GetMeasureValue (TSC_Type *base, tsc_corrdinate_value_selection_t selection)
 Get Y coordinate value or X coordinate value. More...
 
static void TSC_EnableInterruptSignals (TSC_Type *base, uint32_t mask)
 Enable the interrupt signals. More...
 
static void TSC_DisableInterruptSignals (TSC_Type *base, uint32_t mask)
 Disable the interrupt signals. More...
 
static void TSC_EnableInterrupts (TSC_Type *base, uint32_t mask)
 Enable the interrupts. More...
 
static void TSC_DisableInterrupts (TSC_Type *base, uint32_t mask)
 Disable the interrupts. More...
 
static uint32_t TSC_GetInterruptStatusFlags (TSC_Type *base)
 Get interrupt status flags. More...
 
static void TSC_ClearInterruptStatusFlags (TSC_Type *base, uint32_t mask)
 Clear interrupt status flags. More...
 
static uint32_t TSC_GetADCStatusFlags (TSC_Type *base)
 Get the status flags of ADC working with TSC. More...
 
static uint32_t TSC_GetStatusFlags (TSC_Type *base)
 Get the status flags of TSC. 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...
 

Field 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".

Macro Definition Documentation

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

Version 2.0.3.

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.
void TSC_GetDefaultConfig ( tsc_config_t config)

This function initializes the converter configuration structure with available settings. The default values of measureDelayTime and prechargeTime is tested on LCD8000-43T screen and work normally. The default values are:

* config->enableAutoMeausre = false;
* config->measureDelayTime = 0xFFFFU;
* config->prechargeTime = 0xFFFFU;
* config->detectionMode = kTSC_4WireDetectionMode;
*
Parameters
configPointer to "tsc_config_t" structure.
static void TSC_ReturnToIdleStatus ( TSC_Type *  base)
inlinestatic
   Application could check TSC status to confirm that the controller has return to idle status.
Parameters
baseTSC peripheral base address.
static void TSC_StartSenseDetection ( TSC_Type *  base)
inlinestatic
Parameters
baseTSC peripheral base address.
static void TSC_StartMeasure ( TSC_Type *  base)
inlinestatic
Parameters
baseTSC peripheral base address.
static void TSC_DropMeasure ( TSC_Type *  base)
inlinestatic
Parameters
baseTSC peripheral base address.
static void TSC_SoftwareReset ( TSC_Type *  base)
inlinestatic
Parameters
baseTSC peripheral base address.
uint32_t TSC_GetMeasureValue ( TSC_Type *  base,
tsc_corrdinate_value_selection_t  selection 
)

The value is an ADC conversion value.

Parameters
baseTSC peripheral base address.
selectionSelect alternative measure value which is Y coordinate value or X coordinate value. See "tsc_corrdinate_value_selection_t".
Returns
If selection is "kTSC_XCoordinateValueSelection", the API returns x-coordinate vlaue. If selection is "kTSC_YCoordinateValueSelection", the API returns y-coordinate vlaue.
static void TSC_EnableInterruptSignals ( TSC_Type *  base,
uint32_t  mask 
)
inlinestatic

Interrupt signal will be set when corresponding event happens. Specific events point to "_tsc_interrupt_signal_mask" . Specific interrupt signal point to "_tsc_interrupt_status_flag_mask";

Parameters
baseTSC peripheral base address.
maskInterrupt signals mask. See "_tsc_interrupt_signal_mask".
static void TSC_DisableInterruptSignals ( TSC_Type *  base,
uint32_t  mask 
)
inlinestatic

Interrupt signal will be set when corresponding event happens. Specific events point to "_tsc_interrupt_signal_mask". Specific interrupt signal point to "_tsc_interrupt_status_flag_mask";

Parameters
baseTSC peripheral base address.
maskInterrupt signals mask. See "_tsc_interrupt_signal_mask".
static void TSC_EnableInterrupts ( TSC_Type *  base,
uint32_t  mask 
)
inlinestatic

Notice: Only interrupts and signals are all enabled, interrupts could work normally.

Parameters
baseTSC peripheral base address.
maskInterrupts mask. See "_tsc_interrupt_mask".
static void TSC_DisableInterrupts ( TSC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseTSC peripheral base address.
maskInterrupts mask. See "_tsc_interrupt_mask".
static uint32_t TSC_GetInterruptStatusFlags ( TSC_Type *  base)
inlinestatic

Interrupt status falgs are valid when corresponding interrupt signals are enabled.

Parameters
baseTSC peripheral base address.
Returns
Status flags asserted mask. See "_tsc_interrupt_status_flag_mask".
static void TSC_ClearInterruptStatusFlags ( TSC_Type *  base,
uint32_t  mask 
)
inlinestatic

Interrupt status falgs are valid when corresponding interrupt signals are enabled.

Parameters
baseTSC peripheral base address.
maskStatus flags mask. See "_tsc_interrupt_status_flag_mask".
static uint32_t TSC_GetADCStatusFlags ( TSC_Type *  base)
inlinestatic
Parameters
baseTSC peripheral base address.
Returns
Status flags asserted mask. See "_tsc_adc_status_flag_mask".
static uint32_t TSC_GetStatusFlags ( TSC_Type *  base)
inlinestatic
Parameters
baseTSC peripheral base address.
Returns
Status flags asserted mask. See "_tsc_status_flag_mask".