
Oct. 18, 2018
Page
11
of 18
Rev 1.00
M2351 emWin
conversion result can be affected by power noise, mechanical misalignment, etc. To
overcome this issue, the tslib supports calibration function, and the calibration parameter is
stored in APROM offset 0x0007F800.
The touch resolution and the APROM offset store calibration parameters in the
M2351TouchPanel.h.
#ifndef __M2351TOUCHPANEL_H__
#define __M2351TOUCHPANEL_H__
#define __DEMO_TSFILE_ADDR__ 0x0007f800
/* Address for touch paramter NVM */
#ifdef __DEMO_160x128__
#define __DEMO_TS_WIDTH__ 160
#define __DEMO_TS_HEIGHT__ 128
#else
#define __DEMO_TS_WIDTH__ 320
#define __DEMO_TS_HEIGHT__ 240
#endif
int Init_TouchPanel(void);
int Read_TouchPanel(int *x, int *y);
int Uninit_TouchPanel(void);
int Check_TouchPanel(void);
#endif
If APROM is used to store the calibration parameter, main function will load the parameter
from APROM. If the parameter doesn
’t exist, main function will call ts_calibrate() to generate
a copy.
/* Unlock protected registers */
SYS_UnlockReg();
/* Enable FMC ISP function */
FMC_Open();
/* If calibration parameter exists, call ts_calibrate to generate a copy */
if (FMC_Read(__DEMO_TSFILE_ 0x1C) != 0x55AAA55A)
{
FMC_ENABLE_AP_UPDATE();
ts_calibrate(__DEMO_TS_WIDTH__, __DEMO_TS_HEIGHT__);
// Erase page
FMC_Erase(__DEMO_TSFILE_ADDR__);