diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h | 2 | ||||
-rw-r--r-- | drivers/gdisp/SSD1963/gdisp_lld_panel_example.h | 2 | ||||
-rw-r--r-- | drivers/ginput/dial/GADC/ginput_lld.mk | 5 | ||||
-rw-r--r-- | drivers/ginput/dial/GADC/ginput_lld_dial.c | 101 | ||||
-rw-r--r-- | drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h | 48 | ||||
-rw-r--r-- | drivers/ginput/dial/GADC/ginput_lld_dial_config.h | 50 | ||||
-rw-r--r-- | drivers/ginput/dial/GADC/readme.txt | 16 | ||||
-rw-r--r-- | drivers/ginput/touch/ADS7843/ginput_lld_mouse.c | 21 |
8 files changed, 237 insertions, 8 deletions
diff --git a/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h b/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h index 12d40486..ad9fa8e4 100644 --- a/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h +++ b/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h @@ -19,7 +19,7 @@ */
/**
- * @file drivers/gdisp/SSD1963/gdisp_lld_board_example.h
+ * @file drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h
* @brief GDISP Graphic Driver subsystem board interface for the SSD1963 display.
*
* @addtogroup GDISP
diff --git a/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h b/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h index d0eea0d3..109d7332 100644 --- a/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h +++ b/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h @@ -19,7 +19,7 @@ */ /** - * @file SSD1963/gdisp_lld_panel.h + * @file drivers/gdisp/SSD1963/gdisp_lld_panel_example.h * @brief TFT LCD panel properties. * * @addtogroup GDISP diff --git a/drivers/ginput/dial/GADC/ginput_lld.mk b/drivers/ginput/dial/GADC/ginput_lld.mk new file mode 100644 index 00000000..763549b8 --- /dev/null +++ b/drivers/ginput/dial/GADC/ginput_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +GFXSRC += $(GFXLIB)/drivers/ginput/dial/GADC/ginput_lld_dial.c + +# Required include directories +GFXINC += $(GFXLIB)/drivers/ginput/dial/GADC diff --git a/drivers/ginput/dial/GADC/ginput_lld_dial.c b/drivers/ginput/dial/GADC/ginput_lld_dial.c new file mode 100644 index 00000000..ced71a27 --- /dev/null +++ b/drivers/ginput/dial/GADC/ginput_lld_dial.c @@ -0,0 +1,101 @@ +/* + ChibiOS/GFX - Copyright (C) 2012, 2013 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +/** + * @file drivers/ginput/dial/GADC/ginput_lld_dial.c + * @brief GINPUT Dial low level driver source for GADC hardware. + * + * @defgroup Dial Dial + * @ingroup GINPUT + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if GFX_USE_GINPUT && GINPUT_NEED_DIAL + +#include "ginput/lld/dial.h" + +#if GINPUT_DIAL_NUM_PORTS >= 5 + #error "GINPUT: Dial - GADC driver currently only supports 4 devices" +#endif + +static adcsample_t samplebuf[GINPUT_DIAL_NUM_PORTS]; + +#if GINPUT_DIAL_CYCLE_POLL + static uint16_t cycle; +#endif + +static void GADCCallback(adcsample_t *buffer, void *param) { + ((DialCallbackFn)param)(buffer-samplebuf, buffer[0]); +} + +void ginput_lld_dial_init(void) { + #if GINPUT_DIAL_CYCLE_POLL + cycle = 0; + #endif +} + +void ginput_lld_dial_poll(DialCallbackFn fn) { + #if GINPUT_DIAL_CYCLE_POLL + switch(cycle++) { + #if GINPUT_DIAL_NUM_PORTS >= 1 + case 0: + gadcLowSpeedStart(GINPUT_DIAL_DEVICE0, samplebuf+0, GADCCallback, (void *)fn); + break; + #endif + #if GINPUT_DIAL_NUM_PORTS >= 2 + case 1: + gadcLowSpeedStart(GINPUT_DIAL_DEVICE1, samplebuf+1, GADCCallback, (void *)fn); + break; + #endif + #if GINPUT_DIAL_NUM_PORTS >= 3 + case 2: + gadcLowSpeedStart(GINPUT_DIAL_DEVICE2, samplebuf+2, GADCCallback, (void *)fn); + break; + #endif + #if GINPUT_DIAL_NUM_PORTS >= 4 + case 3: + gadcLowSpeedStart(GINPUT_DIAL_DEVICE3, samplebuf+3, GADCCallback, (void *)fn); + break; + #endif + } + if (cycle >= GINPUT_DIAL_NUM_PORTS) + cycle = 0; + #else + #if GINPUT_DIAL_NUM_PORTS >= 1 + gadcLowSpeedStart(GINPUT_DIAL_DEVICE0, samplebuf+0, GADCCallback, (void *)fn); + #endif + #if GINPUT_DIAL_NUM_PORTS >= 2 + gadcLowSpeedStart(GINPUT_DIAL_DEVICE1, samplebuf+1, GADCCallback, (void *)fn); + #endif + #if GINPUT_DIAL_NUM_PORTS >= 3 + gadcLowSpeedStart(GINPUT_DIAL_DEVICE2, samplebuf+2, GADCCallback, (void *)fn); + #endif + #if GINPUT_DIAL_NUM_PORTS >= 4 + gadcLowSpeedStart(GINPUT_DIAL_DEVICE3, samplebuf+3, GADCCallback, (void *)fn); + #endif + #endif +} + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */ +/** @} */ diff --git a/drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h b/drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h new file mode 100644 index 00000000..13788188 --- /dev/null +++ b/drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h @@ -0,0 +1,48 @@ +/* + ChibiOS/GFX - Copyright (C) 2012, 2013 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +/** + * @file drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h + * @brief GINPUT Dial Driver config file. + * + * @defgroup Dial Dial + * @ingroup GINPUT + * @{ + */ + +#ifndef _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H +#define _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H + +#if GFX_USE_GINPUT && GINPUT_NEED_DIAL + +/*===========================================================================*/ +/* Analogue devices on this board */ +/*===========================================================================*/ + +#define GINPUT_DIAL_NUM_PORTS 1 +#define GINPUT_DIAL_DEVICE0 GADC_PHYSDEV_DIAL +#define GINPUT_DIAL_POLL_PERIOD 200 +#define GINPUT_DIAL_CYCLE_POLL FALSE + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */ + +#endif /* _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H */ +/** @} */ + diff --git a/drivers/ginput/dial/GADC/ginput_lld_dial_config.h b/drivers/ginput/dial/GADC/ginput_lld_dial_config.h new file mode 100644 index 00000000..535b09a6 --- /dev/null +++ b/drivers/ginput/dial/GADC/ginput_lld_dial_config.h @@ -0,0 +1,50 @@ +/* + ChibiOS/GFX - Copyright (C) 2012, 2013 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +/** + * @file drivers/ginput/dial/GADC/ginput_lld_dial_config.h + * @brief GINPUT Dial Driver configuration header. + * + * @defgroup Dial Dial + * @ingroup GINPUT + * @{ + */ + +#ifndef _GINPUT_LLD_DIAL_CONFIG_H +#define _GINPUT_LLD_DIAL_CONFIG_H + +#if GFX_USE_GINPUT && GINPUT_NEED_DIAL + +#define GINPUT_DIAL_MAX_VALUE ((1<<GADC_BITS_PER_SAMPLE)-1) + +#if GINPUT_TOGGLE_USE_CUSTOM_BOARD + /* Include the user supplied board definitions */ + #include "ginput_lld_dial_board.h" +#elif defined(BOARD_OLIMEX_SAM7_EX256) + #include "ginput_lld_dial_board_olimexsam7ex256.h" +#else + /* Include the user supplied board definitions */ + #include "ginput_lld_dial_board.h" +#endif + +#endif /* GFX_USE_GDISP && GINPUT_NEED_DIAL */ + +#endif /* _GINPUT_LLD_DIAL_CONFIG_H */ +/** @} */ diff --git a/drivers/ginput/dial/GADC/readme.txt b/drivers/ginput/dial/GADC/readme.txt new file mode 100644 index 00000000..5c303870 --- /dev/null +++ b/drivers/ginput/dial/GADC/readme.txt @@ -0,0 +1,16 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define GFX_USE_GINPUT TRUE + #define GINPUT_NEED_DIAL TRUE + #define GINPUT_NEED_GADC TRUE + d) If you are not using a known board then create a ginput_lld_toggle_board.h file + and ensure it is on your include path. + Use the ginput_lld_dial_board_example.h file as a basis. + Currently known boards are: + Olimex SAM7-EX256 + +2. To your makefile add the following lines: + include $(GFXLIB)/drivers/ginput/dial/GADC/ginput_lld.mk + include $(GFXLIB)/drivers/gadc/yourGADCdriver/gadc_lld.mk +
\ No newline at end of file diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c index 11193442..9371760a 100644 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c @@ -45,6 +45,15 @@ #include "ginput_lld_mouse_board_example.h"
#endif
+#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;
@@ -115,18 +124,18 @@ void ginput_lld_mouse_get_reading(MouseReading *pt) { * Finally switch on PENIRQ once again - perform a dummy read.
* Once we have the readings, find the medium using our filter function
*/
- read_value(0xD1);
+ read_value(CMD_X);
for(i = 0; i < 7; i++)
- sampleBuf[i] = read_value(0xD1);
- read_value(0xD0);
+ 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(0x91);
+ read_value(CMD_Y);
for(i = 0; i < 7; i++)
- sampleBuf[i] = read_value(0x91);
- read_value(0x90);
+ sampleBuf[i] = read_value(CMD_Y);
+ read_value(CMD_Y-1);
filter();
lasty = (coord_t)sampleBuf[3];
|