fixing ADS7843 driver - tested
This commit is contained in:
parent
5b897baae7
commit
dc1ff7afa8
2 changed files with 16 additions and 7 deletions
|
@ -11,7 +11,7 @@
|
||||||
#define GMOUSE_ADS7843_PEN_CALIBRATE_ERROR 2
|
#define GMOUSE_ADS7843_PEN_CALIBRATE_ERROR 2
|
||||||
#define GMOUSE_ADS7843_PEN_CLICK_ERROR 2
|
#define GMOUSE_ADS7843_PEN_CLICK_ERROR 2
|
||||||
#define GMOUSE_ADS7843_PEN_MOVE_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_CLICK_ERROR 4
|
||||||
#define GMOUSE_ADS7843_FINGER_MOVE_ERROR 4
|
#define GMOUSE_ADS7843_FINGER_MOVE_ERROR 4
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ static bool_t init_board(GMouse* m, unsigned driverinstance)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Set the GPIO modes
|
// Set the GPIO modes
|
||||||
palSetPadMode(GPIOC, 4, PAL_MODE_INPUT);
|
palSetPadMode(GPIOC, 4, PAL_MODE_INPUT_PULLUP);
|
||||||
|
|
||||||
// Start the SPI peripheral
|
// Start the SPI peripheral
|
||||||
spiStart(&SPID1, &spicfg);
|
spiStart(&SPID1, &spicfg);
|
||||||
|
|
|
@ -20,8 +20,9 @@
|
||||||
#define BOARD_DATA_SIZE 0
|
#define BOARD_DATA_SIZE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CMD_X 0xD1
|
#define CMD_X 0xD1
|
||||||
#define CMD_Y 0x91
|
#define CMD_Y 0x91
|
||||||
|
#define CMD_ENABLE_IRQ 0x80
|
||||||
|
|
||||||
void read_xyz(GMouse* m, GMouseReading* pdr)
|
void read_xyz(GMouse* m, GMouseReading* pdr)
|
||||||
{
|
{
|
||||||
|
@ -31,10 +32,18 @@ void read_xyz(GMouse* m, GMouseReading* pdr)
|
||||||
pdr->buttons = 0;
|
pdr->buttons = 0;
|
||||||
|
|
||||||
if (getpin_pressed()) {
|
if (getpin_pressed()) {
|
||||||
|
pdr->z = 1; // Set to Z_MAX as we are pressed
|
||||||
|
|
||||||
aquire_bus();
|
aquire_bus();
|
||||||
pdr->x = read_value(CMD_X);
|
|
||||||
pdr->y = read_value(CMD_Y);
|
read_value(CMD_X); // Dummy read - disable PenIRQ
|
||||||
pdr->z = 1;
|
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();
|
release_bus();
|
||||||
} else {
|
} else {
|
||||||
// Don't touch x and y values here
|
// Don't touch x and y values here
|
||||||
|
|
Loading…
Add table
Reference in a new issue