Hello,
You can also check the eGUI code. It includes drivers for resistive touch screen and ADC.
https://github.com/Gargy007/eGUI/tree/master/D4D/low_level_drivers/touch_screen
This is the configyration for TWR-K70 using the TWR-LCD touch screen. Notice, you need hardware rework to connect resistive touch in TWR-LCD to TWR-K70.
#define D4DTCH_ADC_HW D4DTCH_ADC_HW_KINETIS
#define D4DTCH_ADC_ID 1 // Use ADC module 1
#define D4DTCH_MCU_USER_INIT {D4DTCH_X_PLUS_PCR = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;\
D4DTCH_X_MINUS_PCR = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;\
D4DTCH_Y_PLUS_PCR = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;\
D4DTCH_Y_MINUS_PCR = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;\
}
// X+ wire definition
#define D4DTCH_X_PLUS 17
#define D4DTCH_X_PLUS_PORT GPIOA_PDOR // Data output register
#define D4DTCH_X_PLUS_DDR GPIOA_PDDR // Output enable register
#define D4DTCH_X_PLUS_ADCH 17 // ADC channel number
#define D4DTCH_X_PLUS_PCR PORTA_PCR17
// X- wire definition
#define D4DTCH_X_MINUS 10
#define D4DTCH_X_MINUS_PORT GPIOB_PDOR
#define D4DTCH_X_MINUS_DDR GPIOB_PDDR
#define D4DTCH_X_MINUS_PCR PORTB_PCR10
// Y+ wire definition
#define D4DTCH_Y_PLUS 6
#define D4DTCH_Y_PLUS_PORT GPIOB_PDOR
#define D4DTCH_Y_PLUS_DDR GPIOB_PDDR
#define D4DTCH_Y_PLUS_ADCH 12
#define D4DTCH_Y_PLUS_PCR PORTB_PCR6
//#define D4DTCH_INIT_Y_PLUS OUTPUT(D4DTCH_Y_PLUS); RESET(D4DTCH_Y_PLUS);
//#define D4DTCH_RESET_Y_PLUS RESET(D4DTCH_Y_PLUS);
//#define D4DTCH_SET_Y_PLUS SET(D4DTCH_Y_PLUS);
// Y- wire definition
#define D4DTCH_Y_MINUS 5
#define D4DTCH_Y_MINUS_PORT GPIOB_PDOR
#define D4DTCH_Y_MINUS_DDR GPIOB_PDDR
#define D4DTCH_Y_MINUS_PCR PORTB_PCR5
//#define D4DTCH_CALIB_CROSS_OFFSET 30
// Constant specifying maximum ADC value for a screen touch (=12bits)
#define D4DTCH_FULL_SCALE 0x0FFF
// Constants specifying minimum ADC value for a screen touch
#define D4DTCH_X_TOUCH_MIN (D4DTCH_FULL_SCALE / 10)
#define D4DTCH_Y_TOUCH_MIN (D4DTCH_FULL_SCALE / 10)
#define D4DTCH_X_TOUCH_OFFMAX (D4DTCH_X_TOUCH_MIN * 3)
#define D4DTCH_Y_TOUCH_OFFMAX (D4DTCH_Y_TOUCH_MIN * 3)
// Constants specifying ADC difference for touch screen sample
//#define D4DTCH_SAMPLE_MARGIN (D4DTCH_FULL_SCALE / 256)