fixing ADS7843 driver - tested

ugfx_release_2.6
Joel Bodenmann 2014-10-11 23:54:50 +02:00
parent 5b897baae7
commit dc1ff7afa8
2 changed files with 16 additions and 7 deletions

View File

@ -11,7 +11,7 @@
#define GMOUSE_ADS7843_PEN_CALIBRATE_ERROR 2
#define GMOUSE_ADS7843_PEN_CLICK_ERROR 2
#define GMOUSE_ADS7843_PEN_MOVE_ERROR 2
#define GMOUSE_ADS7843_FINGER_CALIBRATE_ERROR 4
#define GMOUSE_ADS7843_FINGER_CALIBRATE_ERROR 20
#define GMOUSE_ADS7843_FINGER_CLICK_ERROR 4
#define GMOUSE_ADS7843_FINGER_MOVE_ERROR 4
@ -31,7 +31,7 @@ static bool_t init_board(GMouse* m, unsigned driverinstance)
return FALSE;
// Set the GPIO modes
palSetPadMode(GPIOC, 4, PAL_MODE_INPUT);
palSetPadMode(GPIOC, 4, PAL_MODE_INPUT_PULLUP);
// Start the SPI peripheral
spiStart(&SPID1, &spicfg);

View File

@ -20,8 +20,9 @@
#define BOARD_DATA_SIZE 0
#endif
#define CMD_X 0xD1
#define CMD_Y 0x91
#define CMD_X 0xD1
#define CMD_Y 0x91
#define CMD_ENABLE_IRQ 0x80
void read_xyz(GMouse* m, GMouseReading* pdr)
{
@ -31,10 +32,18 @@ void read_xyz(GMouse* m, GMouseReading* pdr)
pdr->buttons = 0;
if (getpin_pressed()) {
pdr->z = 1; // Set to Z_MAX as we are pressed
aquire_bus();
pdr->x = read_value(CMD_X);
pdr->y = read_value(CMD_Y);
pdr->z = 1;
read_value(CMD_X); // Dummy read - disable PenIRQ
pdr->x = read_value(CMD_X); // Read X-Value
read_value(CMD_Y); // Dummy read - disable PenIRQ
pdr->y = read_value(CMD_Y); // Read Y-Value
read_value(CMD_ENABLE_IRQ); // Enable IRQ
release_bus();
} else {
// Don't touch x and y values here