diff options
author | Joel Bodenmann <joel@unormal.org> | 2014-10-11 18:24:12 +0200 |
---|---|---|
committer | Joel Bodenmann <joel@unormal.org> | 2014-10-11 18:24:12 +0200 |
commit | d9f93a31bb5fd7ba5de69f2593e2dacb8218dd63 (patch) | |
tree | 199bb5437fc422b5ffc6282e9663eed350449340 | |
parent | 097bce6aa4df5f4bacef3976cd7b7fab26a72c4a (diff) | |
download | uGFX-d9f93a31bb5fd7ba5de69f2593e2dacb8218dd63.tar.gz uGFX-d9f93a31bb5fd7ba5de69f2593e2dacb8218dd63.tar.bz2 uGFX-d9f93a31bb5fd7ba5de69f2593e2dacb8218dd63.zip |
ADS7843 porting - not tested yet!
-rw-r--r-- | boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h | 22 | ||||
-rw-r--r-- | boards/base/FireBull-STM32F103-FB/gmouse_lld_ADS7843_board.h (renamed from boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_board.h) | 23 | ||||
-rw-r--r-- | drivers/ginput/touch/ADS7843/driver.mk | 2 | ||||
-rw-r--r-- | drivers/ginput/touch/ADS7843/ginput_lld_mouse.c | 94 | ||||
-rw-r--r-- | drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h | 21 | ||||
-rw-r--r-- | drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c | 77 | ||||
-rw-r--r-- | drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843_board_template.h (renamed from drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_template.h) | 2 |
7 files changed, 100 insertions, 141 deletions
diff --git a/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h b/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h deleted file mode 100644 index f3a89208..00000000 --- a/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -#ifndef _LLD_GINPUT_MOUSE_CONFIG_H -#define _LLD_GINPUT_MOUSE_CONFIG_H - -#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH -#define GINPUT_MOUSE_NEED_CALIBRATION TRUE -#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE -#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12 -#define GINPUT_MOUSE_READ_CYCLES 4 -#define GINPUT_MOUSE_POLL_PERIOD 3 -#define GINPUT_MOUSE_MAX_CLICK_JITTER 2 -#define GINPUT_MOUSE_MAX_MOVE_JITTER 2 -#define GINPUT_MOUSE_CLICK_TIME 500 - -#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ - diff --git a/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_board.h b/boards/base/FireBull-STM32F103-FB/gmouse_lld_ADS7843_board.h index 6ca1a897..aa3a41e7 100644 --- a/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_board.h +++ b/boards/base/FireBull-STM32F103-FB/gmouse_lld_ADS7843_board.h @@ -8,6 +8,13 @@ #ifndef _GINPUT_LLD_MOUSE_BOARD_H #define _GINPUT_LLD_MOUSE_BOARD_H +#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_CLICK_ERROR 4 +#define GMOUSE_ADS7843_FINGER_MOVE_ERROR 4 + static const SPIConfig spicfg = { 0, GPIOC, @@ -15,13 +22,25 @@ static const SPIConfig spicfg = { /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, }; -static inline void init_board(void) +static bool_t init_board(GMouse* m, unsigned driverinstance) { + (void)m; + + // Only one touch interface on this board + if (driverinstance) + return FALSE; + + // Set the GPIO modes + palSetPadMode(GPIOC, 4, PAL_MODE_INPUT); + + // Start the SPI peripheral spiStart(&SPID1, &spicfg); + + return TRUE; } static inline bool_t getpin_pressed(void) -{ +{ return (!palReadPad(GPIOC, 4)); } diff --git a/drivers/ginput/touch/ADS7843/driver.mk b/drivers/ginput/touch/ADS7843/driver.mk index 31e9ab2c..221dd4fc 100644 --- a/drivers/ginput/touch/ADS7843/driver.mk +++ b/drivers/ginput/touch/ADS7843/driver.mk @@ -1,5 +1,5 @@ # List the required driver. -GFXSRC += $(GFXLIB)/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c +GFXSRC += $(GFXLIB)/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c # Required include directories GFXINC += $(GFXLIB)/drivers/ginput/touch/ADS7843 diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c deleted file mode 100644 index cb9b6f4e..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c +++ /dev/null @@ -1,94 +0,0 @@ -/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/
-
-#include "src/ginput/driver_mouse.h"
-
-#include "ginput_lld_mouse_board.h"
-
-#if defined(GINPUT_MOUSE_YX_INVERTED) && GINPUT_MOUSE_YX_INVERTED
- #define CMD_X 0x91
- #define CMD_Y 0xD1
-#else
- #define CMD_X 0xD1
- #define CMD_Y 0x91
-#endif
-
-
-static uint16_t sampleBuf[7];
-static coord_t lastx, lasty;
-
-static void filter(void) {
- uint16_t temp;
- int i,j;
-
- for(i = 0; i < 4; i++) {
- for(j = i; j < 7; j++) {
- if(sampleBuf[i] > sampleBuf[j]) {
- /* Swap the values */
- temp = sampleBuf[i];
- sampleBuf[i] = sampleBuf[j];
- sampleBuf[j] = temp;
- }
- }
- }
-}
-
-void ginput_lld_mouse_init(void) {
- init_board();
-}
-
-void ginput_lld_mouse_get_reading(MouseReading *pt) {
- uint16_t i;
-
- // If touch-off return the previous results
- if (!getpin_pressed()) {
- pt->x = lastx;
- pt->y = lasty;
- pt->z = 0;
- pt->buttons = 0;
- return;
- }
-
- // Read the port to get the touch settings
- aquire_bus();
-
- /* Get the X value
- * Discard the first conversion - very noisy and keep the ADC on hereafter
- * till we are done with the sampling. Note that PENIRQ is disabled while reading.
- * Finally switch on PENIRQ once again - perform a dummy read.
- * Once we have the readings, find the medium using our filter function
- */
- read_value(CMD_X);
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_value(CMD_X);
- read_value(CMD_X-1);
- filter();
- lastx = (coord_t)sampleBuf[3];
-
- /* Get the Y value using the same process as above */
- read_value(CMD_Y);
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_value(CMD_Y);
- read_value(CMD_Y-1);
- filter();
- lasty = (coord_t)sampleBuf[3];
-
- // Release the bus
- release_bus();
-
- // Return the results
- pt->x = lastx;
- pt->y = lasty;
- pt->z = 100;
- pt->buttons = GINPUT_TOUCH_PRESSED;
-}
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h deleted file mode 100644 index 31840a51..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -#ifndef _LLD_GINPUT_MOUSE_CONFIG_H -#define _LLD_GINPUT_MOUSE_CONFIG_H - -#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH -#define GINPUT_MOUSE_NEED_CALIBRATION TRUE -#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE -#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5 -#define GINPUT_MOUSE_READ_CYCLES 4 -#define GINPUT_MOUSE_POLL_PERIOD 25 -#define GINPUT_MOUSE_MAX_CLICK_JITTER 10 -#define GINPUT_MOUSE_MAX_MOVE_JITTER 2 -#define GINPUT_MOUSE_CLICK_TIME 500 - -#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ diff --git a/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c new file mode 100644 index 00000000..a58ca938 --- /dev/null +++ b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c @@ -0,0 +1,77 @@ +/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#include "gfx.h"
+
+#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE)
+
+#define GMOUSE_DRIVER_VMT GMOUSEVMT_ADS7843
+#include "src/ginput/driver_mouse.h"
+
+// Get the hardware interface
+#include "gmouse_lld_ADS7843_board.h"
+
+// If the board file doesn't specify how many extra bytes it wants - assume 0
+#ifndef BOARD_DATA_SIZE
+ #define BOARD_DATA_SIZE 0
+#endif
+
+#define CMD_X 0xD1
+#define CMD_Y 0x91
+
+void read_xyz(GMouse* m, GMouseReading* pdr)
+{
+ (void)m;
+
+ // No buttons
+ pdr->buttons = 0;
+
+ if (getpin_pressed()) {
+ aquire_bus();
+ pdr->x = read_value(CMD_X);
+ pdr->y = read_value(CMD_Y);
+ pdr->z = 1;
+ release_bus();
+ } else {
+ // Don't touch x and y values here
+ pdr->z = 0;
+ }
+}
+
+const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
+ {
+ GDRIVER_TYPE_TOUCH,
+ GMOUSE_VFLG_TOUCH | GMOUSE_VFLG_CALIBRATE | GMOUSE_VFLG_CAL_TEST |
+ GMOUSE_VFLG_ONLY_DOWN | GMOUSE_VFLG_POORUPDOWN,
+ sizeof(GMouse)+BOARD_DATA_SIZE,
+ _gmouseInitDriver,
+ _gmousePostInitDriver,
+ _gmouseDeInitDriver
+ },
+ 1, // z_max - (currently?) not supported
+ 0, // z_min - (currently?) not supported
+ 1, // z_touchon
+ 0, // z_touchoff
+ { // pen_jitter
+ GMOUSE_ADS7843_PEN_CALIBRATE_ERROR, // calibrate
+ GMOUSE_ADS7843_PEN_CLICK_ERROR, // click
+ GMOUSE_ADS7843_PEN_MOVE_ERROR // move
+ },
+ { // finger_jitter
+ GMOUSE_ADS7843_FINGER_CALIBRATE_ERROR, // calibrate
+ GMOUSE_ADS7843_FINGER_CLICK_ERROR, // click
+ GMOUSE_ADS7843_FINGER_MOVE_ERROR // move
+ },
+ init_board, // init
+ 0, // deinit
+ read_xyz, // get
+ 0, // calsave
+ 0 // calload
+}};
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
+
diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_template.h b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843_board_template.h index 09783adf..2e3dee65 100644 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_template.h +++ b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843_board_template.h @@ -8,7 +8,7 @@ #ifndef _GINPUT_LLD_MOUSE_BOARD_H #define _GINPUT_LLD_MOUSE_BOARD_H -static inline void init_board(void) { +static bool_t init_board(GMouse* m, unsigned driverinstance) { } |