2012-06-01 08:33:08 +00:00
|
|
|
#ifndef TOUCHPAD_H
|
|
|
|
#define TOUCHPAD_H
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
2012-06-10 22:00:07 +00:00
|
|
|
#include "glcd.h"
|
2012-06-16 23:35:21 +00:00
|
|
|
#include "ads7843_lld.h"
|
|
|
|
#include "xpt2046_lld.h"
|
2012-06-01 08:33:08 +00:00
|
|
|
|
2012-06-01 10:44:48 +00:00
|
|
|
#define CONVERSIONS 3
|
|
|
|
|
2012-06-01 08:33:08 +00:00
|
|
|
#define SET_CS(a) (TP_PORT->BSRR = 1 << (TP_CS + (a ? 0 : 16)))
|
|
|
|
|
2012-06-11 12:34:17 +00:00
|
|
|
struct cal {
|
2012-06-04 14:40:38 +00:00
|
|
|
float xm;
|
|
|
|
float ym;
|
|
|
|
float xn;
|
|
|
|
float yn;
|
2012-06-04 07:06:55 +00:00
|
|
|
};
|
|
|
|
|
2012-06-19 19:05:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2012-06-07 22:07:43 +00:00
|
|
|
/*
|
|
|
|
* Description: initializes touchpad (SPI)
|
|
|
|
*
|
2012-06-11 11:07:44 +00:00
|
|
|
* param: SPI driver
|
2012-06-07 22:07:43 +00:00
|
|
|
*
|
|
|
|
* return: none
|
|
|
|
*/
|
2012-06-11 11:07:44 +00:00
|
|
|
void tpInit(SPIDriver *spip);
|
2012-06-07 22:07:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: reads out PEN_IRQ from touchpad controller
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: 1 = touchpad pressed / 0 = touchpad not pressed
|
|
|
|
*/
|
2012-06-03 22:15:38 +00:00
|
|
|
uint8_t tpIRQ(void);
|
2012-06-07 22:07:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: reads-out X coordinate, calibrated
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: X coordinate, relative to screen zero-point
|
|
|
|
*/
|
2012-06-01 08:33:08 +00:00
|
|
|
uint16_t tpReadX(void);
|
2012-06-07 22:07:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: reads-out Y coordinate, calibrated
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: Y coordinate, relative to screen zero-point
|
|
|
|
*/
|
2012-06-01 08:33:08 +00:00
|
|
|
uint16_t tpReadY(void);
|
2012-06-07 22:07:43 +00:00
|
|
|
|
2012-06-15 08:18:52 +00:00
|
|
|
/*
|
|
|
|
* Description: reads-out Z value / pressure
|
|
|
|
* only available when controller supports, returns
|
|
|
|
* zero otherwise.
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: pressure on the touchpad
|
|
|
|
*/
|
|
|
|
uint16_t tpReadZ(void);
|
|
|
|
|
2012-06-07 22:07:43 +00:00
|
|
|
/*
|
|
|
|
* Description: calibration routine
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: none
|
|
|
|
*/
|
2012-06-04 07:06:55 +00:00
|
|
|
void tpCalibrate(void);
|
2012-06-01 08:33:08 +00:00
|
|
|
|
2012-06-19 19:05:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-01 08:33:08 +00:00
|
|
|
#endif
|
2012-06-10 16:59:54 +00:00
|
|
|
|