📄 mx1touch.hpp
字号:
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// MX1TOUCH- Touch Screen driver written to utilize the FreeScale MX1
// built-in touch controller.
//
//
// Notes:
//
// This driver has been tested with the MX1 ADS eval board exclusively.
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
#ifndef _MX1TOUCH_
#define _MX1TOUCH_
#include "peg.hpp"
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// ASP registers
typedef struct {
volatile PEGULONG DataIn;
volatile PEGULONG Spare1[3];
volatile PEGULONG Control;
volatile PEGULONG SampleRate;
volatile PEGULONG IntCtrl;
volatile PEGULONG Status;
volatile PEGULONG Spare2[3];
volatile PEGULONG ClockDiv;
volatile PEGULONG Compare;
volatile PEGULONG FIFOPtr;
} ASP_REG_BLOCK;
/*--------------------------------------------------------------------------*/
// Delay values- User defined delay values. These values are currently
// in 10ms ticks, which is the timebase used when creating this driver.
// You can adjust these values if needed for your system.
/*--------------------------------------------------------------------------*/
#if defined(PEGSMX)
#define TOUCH_POLLING_PERIOD 3 // Polling Interval
#define TOUCH_SETTLE_DELAY 10 // How long to settle on a value?
#define TOUCH_NOISE_LIMIT 500 // some variation in consecutive ATOD
// readings is normal. A lot of variation
// indicates the screen is settling and
// the user is just touching or releasing.
// How much variation between reads is OK
// is determined by this variable
#define TOUCH_DELAY(a) count(a, ticks, INF);
#elif defined(PEG_QUADROS)
#define TOUCH_POLLING_PERIOD 3 // Polling Interval
#define TOUCH_SETTLE_DELAY 5 // How long to settle on a value?
#define TOUCH_NOISE_LIMIT 400 // some variation in consecutive ATOD
// readings is normal. A lot of variation
// indicates the screen is settling and
// the user is just touching or releasing.
// How much variation between reads is OK
// is determined by this variable
#define TOUCH_DELAY(a) KS_SleepTask(COUNTER1, a);
#elif defined(PEG_PRKERNEL)
#define TOUCH_POLLING_PERIOD 3 // Polling Interval
#define TOUCH_SETTLE_DELAY 5 // How long to settle on a value?
#define TOUCH_NOISE_LIMIT 400 // some variation in consecutive ATOD
// readings is normal. A lot of variation
// indicates the screen is settling and
// the user is just touching or releasing.
// How much variation between reads is OK
// is determined by this variable
#define TOUCH_DELAY(a) dly_tsk(a);
#endif
/*--------------------------------------------------------------------------*/
// Miscellaneous definitions used in the driver code...
/*--------------------------------------------------------------------------*/
#define PEN_DOWN_IRQ 46
#define PEN_UP_IRQ 5
#define PEN_DATA_IRQ 33
#define ASP_FIFO_DEPTH 12
#define ASP_INIT_VAL 0x02005001; // init value, not enabled
#define ASP_ENABLE 0x02005003; // turn on ASP module
#define ASP_DMCNT 6 // decimation count
#define ASP_BIT_SEL 0 // starting bit of FIR output
#define ASP_IDLE_CNT 2 // idle clocks between samples
#define ASP_DATA_SETUP 2 // delay after switch change
#define TS_TOUCHED 0x8000 // Touch State Last Touched
#define TS_TOUCH_SENT 0x4000 // PM_LBUTTONDOWN was sent
/*--------------------------------------------------------------------------*/
// TOUCH_CAL_DATA
//
// Calibration data used to convert raw ATOD values into pixel coords
/*--------------------------------------------------------------------------*/
typedef struct
{
PEGUSHORT RawXVals[4];
PEGUSHORT RawYVals[4];
PEGINT ScreenWidth;
PEGINT ScreenHeight;
PEGINT CenterX;
PEGINT CenterY;
PEGBOOL IsCalibrated;
} TOUCH_CAL_DATA;
/*--------------------------------------------------------------------------*/
// indexes into TOUCH_CAL_DATA
/*--------------------------------------------------------------------------*/
#define TC_UL 0
#define TC_LL 1
#define TC_UR 2
#define TC_LR 3
void TouchConfigureHardware(void); // called first
void CalibrateTouchScreen(void); // called second
void TouchSample(PEGUSHORT *pPutX, PEGUSHORT *pPutY);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -