From 292ca0d44edfcff960e52c0c7d8f5a8578e74068 Mon Sep 17 00:00:00 2001 From: Tectu Date: Wed, 8 Aug 2012 22:51:23 +0200 Subject: [PATCH 01/24] makefiles update --- halext/drivers/gdispNokia6610/gdisp_lld.mk | 4 ++-- halext/drivers/gdispS6d1121/gdisp_lld.mk | 4 ++-- halext/drivers/gdispSsd1289/gdisp_lld.mk | 4 ++-- halext/drivers/gdispTestStub/gdisp_lld.mk | 4 ++-- halext/halext.mk | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/halext/drivers/gdispNokia6610/gdisp_lld.mk b/halext/drivers/gdispNokia6610/gdisp_lld.mk index dbcfe27f..43ed7581 100644 --- a/halext/drivers/gdispNokia6610/gdisp_lld.mk +++ b/halext/drivers/gdispNokia6610/gdisp_lld.mk @@ -1,5 +1,5 @@ # List the required driver. -HALSRC += ${CHIBIOS}/os/halext/drivers/gdispNokia6610/gdisp_lld.c +HALSRC += $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.c # Required include directories -HALINC += ${CHIBIOS}/os/halext/drivers/gdispNokia6610 +HALINC += $(LCDLIB)/halext/drivers/gdispNokia6610 diff --git a/halext/drivers/gdispS6d1121/gdisp_lld.mk b/halext/drivers/gdispS6d1121/gdisp_lld.mk index 632655ea..1ad9ab88 100644 --- a/halext/drivers/gdispS6d1121/gdisp_lld.mk +++ b/halext/drivers/gdispS6d1121/gdisp_lld.mk @@ -1,5 +1,5 @@ # List the required driver. -HALSRC += ${CHIBIOS}/os/halext/drivers/gdispS6d1121/gdisp_lld.c +HALSRC += $(LCDLIB)/halext/drivers/gdispS6d1121/gdisp_lld.c # Required include directories -HALINC += ${CHIBIOS}/os/halext/drivers/gdispS6d1121 +HALINC += $(LCDLIB)/halext/drivers/gdispS6d1121 diff --git a/halext/drivers/gdispSsd1289/gdisp_lld.mk b/halext/drivers/gdispSsd1289/gdisp_lld.mk index 05d0d319..97d84f4d 100644 --- a/halext/drivers/gdispSsd1289/gdisp_lld.mk +++ b/halext/drivers/gdispSsd1289/gdisp_lld.mk @@ -1,5 +1,5 @@ # List the required driver. -HALSRC += ${CHIBIOS}/os/halext/drivers/gdispSsd1289/gdisp_lld.c +HALSRC += $(LCDLIB)/halext/drivers/gdispSsd1289/gdisp_lld.c # Required include directories -HALINC += ${CHIBIOS}/os/halext/drivers/gdispSsd1289 +HALINC += $(LCDLIB)/halext/drivers/gdispSsd1289 diff --git a/halext/drivers/gdispTestStub/gdisp_lld.mk b/halext/drivers/gdispTestStub/gdisp_lld.mk index 50ee07a6..c58725e5 100644 --- a/halext/drivers/gdispTestStub/gdisp_lld.mk +++ b/halext/drivers/gdispTestStub/gdisp_lld.mk @@ -1,5 +1,5 @@ # List the required driver. -HALSRC += ${CHIBIOS}/os/halext/drivers/gdispTestStub/gdisp_lld.c +HALSRC += $(LCDLIB)/halext/drivers/gdispTestStub/gdisp_lld.c # Required include directories -HALINC += ${CHIBIOS}/os/halext/drivers/gdispTestStub +HALINC += $(LCDLIB)/halext/drivers/gdispTestStub diff --git a/halext/halext.mk b/halext/halext.mk index 8768a07b..5afb24b0 100644 --- a/halext/halext.mk +++ b/halext/halext.mk @@ -1,9 +1,9 @@ # List of all the ChibiOS/RT META files, there is no need to remove the files # from this list, you can disable parts of the kernel by editing halconf.h. -HALSRC += ${CHIBIOS}/os/halext/src/gdisp.c \ - ${CHIBIOS}/os/halext/src/gdisp_fonts.c \ - ${CHIBIOS}/os/halext/src/gdisp_emulation.c +HALSRC += $(LCDLIB)/halext/src/gdisp.c \ + $(LCDLIB)/halext/src/gdisp_fonts.c \ + $(LCDLIB)/halext/src/gdisp_emulation.c # Required include directories -HALINC += ${CHIBIOS}/os/halext/include +HALINC += $(LCDLIB)/halext/include From 22d66771f2a9d85eaf96e5ae2fba4b4ac0f3bce3 Mon Sep 17 00:00:00 2001 From: Tectu Date: Wed, 8 Aug 2012 23:28:10 +0200 Subject: [PATCH 02/24] added touchpad driver structure for halext --- .../touchpad/touchpadXPT2046/readme.txt | 17 + .../touchpad/touchpadXPT2046/touchpad_lld.c | 336 ++++++++++++++++++ .../touchpad/touchpadXPT2046/touchpad_lld.mk | 6 + .../touchpadXPT2046/touchpad_lld_config.h | 45 +++ 4 files changed, 404 insertions(+) create mode 100644 halext/drivers/touchpad/touchpadXPT2046/readme.txt create mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c create mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk create mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h diff --git a/halext/drivers/touchpad/touchpadXPT2046/readme.txt b/halext/drivers/touchpad/touchpadXPT2046/readme.txt new file mode 100644 index 00000000..83611acf --- /dev/null +++ b/halext/drivers/touchpad/touchpadXPT2046/readme.txt @@ -0,0 +1,17 @@ +This low level driver is a test stub that doesn't talk to any +real hardware. It is included to allow testing of the compilation +process. + +Do not use this driver as a template for new drivers. Use the + templates/gdispXXXXX directory for that. + +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) + you want to compile test eg: GDISP_NEED_MULTITHREAD + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c new file mode 100644 index 00000000..44431e30 --- /dev/null +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -0,0 +1,336 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +/** + * @file gdispTestStub/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source (stub). + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + GDISPDriver GDISP; +#endif + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +void gdisp_lld_init(void) { + /* Initialise the GDISP structure */ + GDISP.Width = 128; + GDISP.Height = 128; + GDISP.Orientation = portrait; + GDISP.Powermode = powerOff; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) { +} + +/* ---- Optional Routines ---- */ +/* + All the below routines are optional. + Defining them will increase speed but everything + will work if they are not defined. + If you are not using a routine - turn it off using + the appropriate GDISP_HARDWARE_XXXX macro. + Don't bother coding for obvious similar routines if + there is no performance penalty as the emulation software + makes a good job of using similar routines. + eg. If gdisp_lld_fillarea() is defined there is little + point in defining gdisp_lld_clear() unless the + performance bonus is significant. + For good performance it is suggested to implement + gdisp_lld_fillarea() and gdisp_lld_blitarea(). +*/ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void gdisp_lld_clear(color_t UNUSED(color)) { + } +#endif + +#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x0, y0 The start of the line + * @param[in] x1, y1 The end of the line + * @param[in] color The color of the line + * + * @notapi + */ + void gdisp_lld_drawline(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) { + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void gdisp_lld_fillarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) { + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void gdisp_lld_blitarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), pixel_t *UNUSED(buffer)) { + } +#endif + +/* Circular Drawing Functions */ +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) + /** + * @brief Draw a circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void gdisp_lld_drawcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void gdisp_lld_fillcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) + /** + * @brief Draw an ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void gdisp_lld_drawellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void gdisp_lld_fillellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a transparent background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * + * @notapi + */ + void gdisp_lld_drawchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a filled background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * @param[in] bgcolor The background color + * + * @notapi + */ + void gdisp_lld_fillchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) { + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t gdisp_lld_getpixelcolor(coord_t UNUSED(x), coord_t UNUSED(y)) { + return 0; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void gdisp_lld_verticalscroll(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) { + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void gdisp_lld_control(int UNUSED(what), void *UNUSED(value)) { + } +#endif + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk new file mode 100644 index 00000000..e97deff8 --- /dev/null +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +HLSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c + +# Required include directories +HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046 + diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h new file mode 100644 index 00000000..675d997a --- /dev/null +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -0,0 +1,45 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +/** + * @file touchpadXPT2046/touchpad_lld_config.h + * @brief Touchppad Driver subsystem low level driver. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_CONFIG_H +#define _TOUCHPAD_LLD_CONFIG_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define TOUCHPAD_X_DIRECTION TRUE +#define TOUCHPAD_Y_DIRECTION TRUE +#define TOUCHPAD_Z_DIRECTION TRUE /* pressure measurement */ + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_CONFIG_H */ +/** @} */ From 82dbef4c8d961f5bb3f95667a2c8fe0ddfd6ba22 Mon Sep 17 00:00:00 2001 From: Tectu Date: Wed, 8 Aug 2012 23:41:18 +0200 Subject: [PATCH 03/24] added touchpad XPT2046 driver dummy --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 269 ++---------------- .../touchpadXPT2046/touchpad_lld_config.h | 4 +- 2 files changed, 26 insertions(+), 247 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 44431e30..f3211633 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -28,9 +28,9 @@ #include "ch.h" #include "hal.h" -#include "gdisp.h" +#include "touchpad.h" -#if HAL_USE_GDISP || defined(__DOXYGEN__) +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver local definitions. */ @@ -50,7 +50,7 @@ /*===========================================================================*/ #if !defined(__DOXYGEN__) - GDISPDriver GDISP; + TOUCHPADDriver TOUCHPAD; #endif /*===========================================================================*/ @@ -70,267 +70,48 @@ /*===========================================================================*/ /* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ /** * @brief Low level GDISP driver initialization. * * @notapi */ -void gdisp_lld_init(void) { - /* Initialise the GDISP structure */ - GDISP.Width = 128; - GDISP.Height = 128; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOff; +void touchpad_lld_init(void) { + /* Initialise the TOUCHPAD structure */ } /** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel + * @brief Reads out the X direction. * * @notapi */ -void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) { +uint16_t touchpad_lld_read_x(void) { + /* ToDo */ + return 0; +} + +/* + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t touchpad_lld_read_y(void) { + /* ToDo */ + return 0; } /* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If gdisp_lld_fillarea() is defined there is little - point in defining gdisp_lld_clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - gdisp_lld_fillarea() and gdisp_lld_blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel +#if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) + /* + * @brief Reads out the Z direction / pressure. * * @notapi */ - void gdisp_lld_clear(color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void gdisp_lld_drawline(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void gdisp_lld_fillarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void gdisp_lld_blitarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), pixel_t *UNUSED(buffer)) { - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void gdisp_lld_drawcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void gdisp_lld_fillcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void gdisp_lld_drawellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void gdisp_lld_fillellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void gdisp_lld_drawchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void gdisp_lld_fillchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t gdisp_lld_getpixelcolor(coord_t UNUSED(x), coord_t UNUSED(y)) { + uint16_t toucpad_lld_read_y(void) { + /* ToDo */ return 0; } #endif -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void gdisp_lld_verticalscroll(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void gdisp_lld_control(int UNUSED(what), void *UNUSED(value)) { - } -#endif - -#endif /* HAL_USE_GDISP */ +#endif /* HAL_USE_TOUCHPAD */ /** @} */ diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 675d997a..6c491e27 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -35,9 +35,7 @@ /* Driver hardware support. */ /*===========================================================================*/ -#define TOUCHPAD_X_DIRECTION TRUE -#define TOUCHPAD_Y_DIRECTION TRUE -#define TOUCHPAD_Z_DIRECTION TRUE /* pressure measurement */ +#define TOUCHPAD_PRESSURE_DIRECTION TRUE #endif /* HAL_USE_TOUCHPAD */ From 308184ead1c6071a739c7a233287a4c0412ca817 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 00:43:52 +0200 Subject: [PATCH 04/24] some more touchpad stuff --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 15 +++++++++------ .../touchpadXPT2046/touchpad_lld_config.h | 2 +- halext/halext.mk | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index f3211633..2f280169 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -50,7 +50,7 @@ /*===========================================================================*/ #if !defined(__DOXYGEN__) - TOUCHPADDriver TOUCHPAD; + TOUCHPADDriver Touchpad; #endif /*===========================================================================*/ @@ -72,12 +72,15 @@ /* ---- Required Routines ---- */ /** - * @brief Low level GDISP driver initialization. + * @brief Low level Touchpad driver initialization. * * @notapi */ -void touchpad_lld_init(void) { +void tp_lld_init(TOUCHPADDriver *tp) { /* Initialise the TOUCHPAD structure */ + + /* ToDo */ + (void)tp; } /** @@ -85,7 +88,7 @@ void touchpad_lld_init(void) { * * @notapi */ -uint16_t touchpad_lld_read_x(void) { +uint16_t tp_lld_read_x(void) { /* ToDo */ return 0; } @@ -95,7 +98,7 @@ uint16_t touchpad_lld_read_x(void) { * * @notapi */ -uint16_t touchpad_lld_read_y(void) { +uint16_t tp_lld_read_y(void) { /* ToDo */ return 0; } @@ -107,7 +110,7 @@ uint16_t touchpad_lld_read_y(void) { * * @notapi */ - uint16_t toucpad_lld_read_y(void) { + uint16_t tp_lld_read_y(void) { /* ToDo */ return 0; } diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 6c491e27..52493836 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -35,7 +35,7 @@ /* Driver hardware support. */ /*===========================================================================*/ -#define TOUCHPAD_PRESSURE_DIRECTION TRUE +#define TOUCHPAD_PRESSURE TRUE #endif /* HAL_USE_TOUCHPAD */ diff --git a/halext/halext.mk b/halext/halext.mk index 5afb24b0..80ddf666 100644 --- a/halext/halext.mk +++ b/halext/halext.mk @@ -3,7 +3,8 @@ HALSRC += $(LCDLIB)/halext/src/gdisp.c \ $(LCDLIB)/halext/src/gdisp_fonts.c \ - $(LCDLIB)/halext/src/gdisp_emulation.c + $(LCDLIB)/halext/src/gdisp_emulation.c \ + $(LCDLIB)/halext/src/touchpad.c # Required include directories HALINC += $(LCDLIB)/halext/include From ebcc53e8e7e124d3e96af95c9f64b4be79cbcae1 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 00:44:12 +0200 Subject: [PATCH 05/24] some more touchpad stuff --- halext/include/touchpad.h | 86 ++++++++++++++++++++++ halext/include/touchpad_lld.h | 88 +++++++++++++++++++++++ halext/src/touchpad.c | 130 ++++++++++++++++++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 100644 halext/include/touchpad.h create mode 100644 halext/include/touchpad_lld.h create mode 100644 halext/src/touchpad.c diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h new file mode 100644 index 00000000..bf17edf0 --- /dev/null +++ b/halext/include/touchpad.h @@ -0,0 +1,86 @@ +/* + ChibiOS-LCD-Driver/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +/** + * @file touchpad.h + * @brief TOUCHPAD Touchpad Driver subsystem header file. + * + * @addgroup TOUCHPAD + * @{ + */ +#ifndef _TOUCHPAD_H +#define _TOUCHPAD_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Low Level Driver details and error checks. */ +/*===========================================================================*/ + +/* Include the low level driver information */ +#include "touchpad_lld.h" + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#if TOUCHPAD_NEED_MULTITHREAD + + void tpInit(TOUCHPADDriver *tp); + uint16_t tpReadX(void); + uint16_t tpReadY(void); + +#else + + #define tpInit(tp) tp_lld_init(tp) + #define tpReadX() tp_lld_read_x() + #define tpReadY() tp_lld_read_y() + +#endif + + + +#if TOUCHPAD_PRESSURE + + uint16_t tpReadZ(void); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_H */ +/** @} */ + diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h new file mode 100644 index 00000000..e659803c --- /dev/null +++ b/halext/include/touchpad_lld.h @@ -0,0 +1,88 @@ +/* + ChibiOS-LCD-Driver/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +/** + * @file touchpad_lld.h + * @brief TOUCHPAD Driver subsystem low level driver header. + * + * @addgroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_H +#define _TOUCHPAD_LLD_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Include the low level driver configuration information */ +/*===========================================================================*/ + +#include "gdisp_lld_config.h" + +/*===========================================================================*/ +/* Error checks. */ +/*===========================================================================*/ + +#ifndef TOUCHPAD_PRESSURE + #define TOUCHPAD_PRESSURE FALSE +#endif + +/*===========================================================================*/ +/* Driver types. */ +/*===========================================================================*/ + +/** + * @brief Structure representing a Touchpad driver. + */ +struct TOUCHPADDriver { + /* ToDo */ +}; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + extern TOUCHPADDriver Touchpad; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* Core functions */ + void tp_lld_init(void); + uint16_t tp_lld_read_x(void); + uint16_t tp_lld_read_y(void); + + #if TOUCHPAD_PRESSURE + uint16_t tp_lld_read_z(void); + #endif + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_H */ +/** @} */ + diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c new file mode 100644 index 00000000..69d47f42 --- /dev/null +++ b/halext/src/touchpad.c @@ -0,0 +1,130 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +/** + * @file touchpad.c + * @brief Touchpad Driver code. + * + * @addgroup TOUCHPAD + * @{ + */ +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +#if GDISP_NEED_MULTITHREAD + #warning "GDISP: Multithread support not complete" + #define MUTEX_INIT /* Not defined yet */ + #define MUTEX_ENTER /* Not defined yet */ + #define MUTEX_EXIT /* Not defined yet */ +#endif + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Touchpad Driver initialization. + * @note This function is NOT currently implicitly invoked by @p halInit(). + * It must be called manually. + * + * @init + */ + void tpInit(TOUCHPADDriver * UNUSED(tp)) { + /* Initialise Mutex */ + MUTEX_INIT + + /* Initialise driver */ + MUTEX_ENTER + tp_lld_init(tp); + MUTEX_EXIT + } +#endif + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The X position in pixels. + * + * @api + */ + uint16_t tpReadX(void) { + return (tp_lld_read_x()); + } +#endif + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The Y position in pixels. + * + * @api + */ + uint16_t tpReadY(void) { + return (tp_lld_read_y()); + } +#endif + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Get the pressure. + * + * @return The pressure. + * + * @api + */ + uint16_t tpReadZ(void) { + return (tp_lld_read_z()); + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + From ed29707da6ba034db1fe7fbf11abe98f530b3647 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:00:09 +0200 Subject: [PATCH 06/24] fixed a few TOUCHPAD_MULTITHREAD stuffs --- halext/include/touchpad.h | 15 ++++++++++----- halext/include/touchpad_lld.h | 4 +++- halext/src/touchpad.c | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index bf17edf0..5991b6ae 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -59,22 +59,27 @@ extern "C" { uint16_t tpReadX(void); uint16_t tpReadY(void); + #if TOUCHPAD_PRESSURE + + uint16_t tpReadZ(void); + + #endif + #else #define tpInit(tp) tp_lld_init(tp) #define tpReadX() tp_lld_read_x() #define tpReadY() tp_lld_read_y() -#endif + #if TOUCHPAD_PRESSURE + #define tpReadZ() tp_lld_read_z() - -#if TOUCHPAD_PRESSURE - - uint16_t tpReadZ(void); + #endif #endif + #ifdef __cplusplus } #endif diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index e659803c..ccff7d4d 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -35,7 +35,7 @@ /* Include the low level driver configuration information */ /*===========================================================================*/ -#include "gdisp_lld_config.h" +#include "touchpad_lld_config.h" /*===========================================================================*/ /* Error checks. */ @@ -49,6 +49,8 @@ /* Driver types. */ /*===========================================================================*/ +typedef struct TOUCHPADDriver TOUCHPADDriver; + /** * @brief Structure representing a Touchpad driver. */ diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 69d47f42..29ff9eb5 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -32,7 +32,7 @@ #if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) #if GDISP_NEED_MULTITHREAD - #warning "GDISP: Multithread support not complete" + #warning "TOUCHPAD: Multithread support not complete" #define MUTEX_INIT /* Not defined yet */ #define MUTEX_ENTER /* Not defined yet */ #define MUTEX_EXIT /* Not defined yet */ From 384529af26a27ef7500b4ff97fbcd85e50385f7b Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:07:04 +0200 Subject: [PATCH 07/24] a few more touchpad things --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 2 + .../touchpad/touchpadXPT2046/xpt2046_lld.c.h | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 2f280169..03f04203 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -61,6 +61,8 @@ /* Driver local functions. */ /*===========================================================================*/ +#include "xpt2046_lld.c.h" + /*===========================================================================*/ /* Driver interrupt handlers. */ /*===========================================================================*/ diff --git a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h new file mode 100644 index 00000000..2e891684 --- /dev/null +++ b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h @@ -0,0 +1,40 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +#ifndef _XPT2046_H +#define _XPT2046_H + +void tp_lld_init(TOUCHPADDriver *tp) { + +} + +uint16_t tp_lld_read_x(void) { + return 42; +} + +uint16_t tp_lld_read_y(void) { + return 42; +} + +uint16_t tp_lld_read_z(void) { + return 42; +} + +#endif /* _XPT2046_H */ From 640b7473935bea33102187a2833dae940b345576 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:20:15 +0200 Subject: [PATCH 08/24] more touchpad stuff --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 14 +++++++------- halext/include/touchpad.h | 2 +- halext/readme.txt | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 03f04203..8a2de34e 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -19,10 +19,10 @@ */ /** - * @file gdispTestStub/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source (stub). + * @file touchpadXPT2046/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. * - * @addtogroup GDISP + * @addtogroup TOUCHPAD * @{ */ @@ -78,7 +78,7 @@ * * @notapi */ -void tp_lld_init(TOUCHPADDriver *tp) { +void tp_lld_init(void) { /* Initialise the TOUCHPAD structure */ /* ToDo */ @@ -92,7 +92,7 @@ void tp_lld_init(TOUCHPADDriver *tp) { */ uint16_t tp_lld_read_x(void) { /* ToDo */ - return 0; + return 42; } /* @@ -102,7 +102,7 @@ uint16_t tp_lld_read_x(void) { */ uint16_t tp_lld_read_y(void) { /* ToDo */ - return 0; + return 42; } /* ---- Optional Routines ---- */ @@ -114,7 +114,7 @@ uint16_t tp_lld_read_y(void) { */ uint16_t tp_lld_read_y(void) { /* ToDo */ - return 0; + return 42; } #endif diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 5991b6ae..12b462fd 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -67,7 +67,7 @@ extern "C" { #else - #define tpInit(tp) tp_lld_init(tp) + #define tpInit(tp) tp_lld_init() #define tpReadX() tp_lld_read_x() #define tpReadY() tp_lld_read_y() diff --git a/halext/readme.txt b/halext/readme.txt index 5983635a..1123e827 100644 --- a/halext/readme.txt +++ b/halext/readme.txt @@ -6,14 +6,14 @@ To include any of these functions/drivers in your project... include $(LCDLIB)/lcd.mk 3/ In your project Makefile add the makefiles for any specific drivers you want e.g - include $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.mk + include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk 4/ In your project halconf.h turn on the support you want eg. /** - * @brief Enables the GDISP subsystem. + * @brief Enables the Touchpad subsystem. */ - #if !defined(HAL_USE_GDISP) || defined(__DOXYGEN__) - #define HAL_USE_GDISP TRUE + #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__) + #define HAL_USE_TOUCHPAD TRUE #endif 5/ Do a make clean. From 1c0212bb2b13624076fafb5acf627af858a4a27b Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:21:30 +0200 Subject: [PATCH 09/24] Revert "added touchpad driver structure for halext" This reverts commit 22d66771f2a9d85eaf96e5ae2fba4b4ac0f3bce3. --- .../touchpad/touchpadXPT2046/readme.txt | 17 - .../touchpad/touchpadXPT2046/touchpad_lld.c | 336 ------------------ .../touchpad/touchpadXPT2046/touchpad_lld.mk | 6 - .../touchpadXPT2046/touchpad_lld_config.h | 45 --- 4 files changed, 404 deletions(-) delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/readme.txt delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h diff --git a/halext/drivers/touchpad/touchpadXPT2046/readme.txt b/halext/drivers/touchpad/touchpadXPT2046/readme.txt deleted file mode 100644 index 83611acf..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -This low level driver is a test stub that doesn't talk to any -real hardware. It is included to allow testing of the compilation -process. - -Do not use this driver as a template for new drivers. Use the - templates/gdispXXXXX directory for that. - -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) - you want to compile test eg: GDISP_NEED_MULTITHREAD - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c deleted file mode 100644 index 44431e30..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver 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-LCD-Driver 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 . -*/ - -/** - * @file gdispTestStub/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source (stub). - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -#if !defined(__DOXYGEN__) - GDISPDriver GDISP; -#endif - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -void gdisp_lld_init(void) { - /* Initialise the GDISP structure */ - GDISP.Width = 128; - GDISP.Height = 128; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOff; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) { -} - -/* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If gdisp_lld_fillarea() is defined there is little - point in defining gdisp_lld_clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - gdisp_lld_fillarea() and gdisp_lld_blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void gdisp_lld_clear(color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void gdisp_lld_drawline(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void gdisp_lld_fillarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void gdisp_lld_blitarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), pixel_t *UNUSED(buffer)) { - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void gdisp_lld_drawcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void gdisp_lld_fillcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void gdisp_lld_drawellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void gdisp_lld_fillellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void gdisp_lld_drawchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void gdisp_lld_fillchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t gdisp_lld_getpixelcolor(coord_t UNUSED(x), coord_t UNUSED(y)) { - return 0; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void gdisp_lld_verticalscroll(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void gdisp_lld_control(int UNUSED(what), void *UNUSED(value)) { - } -#endif - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk deleted file mode 100644 index e97deff8..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List the required driver. -HLSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c - -# Required include directories -HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046 - diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h deleted file mode 100644 index 675d997a..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver 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-LCD-Driver 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 . -*/ - -/** - * @file touchpadXPT2046/touchpad_lld_config.h - * @brief Touchppad Driver subsystem low level driver. - * - * @addtogroup TOUCHPAD - * @{ - */ - -#ifndef _TOUCHPAD_LLD_CONFIG_H -#define _TOUCHPAD_LLD_CONFIG_H - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define TOUCHPAD_X_DIRECTION TRUE -#define TOUCHPAD_Y_DIRECTION TRUE -#define TOUCHPAD_Z_DIRECTION TRUE /* pressure measurement */ - -#endif /* HAL_USE_TOUCHPAD */ - -#endif /* _TOUCHPAD_LLD_CONFIG_H */ -/** @} */ From 79c053567816521b601e44981bf3af5b0e40f752 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:31:24 +0200 Subject: [PATCH 10/24] more touchpad stuff --- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk | 2 +- halext/src/touchpad.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk index e97deff8..9409795b 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk @@ -1,5 +1,5 @@ # List the required driver. -HLSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +HALSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c # Required include directories HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046 diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 29ff9eb5..f65ca0cd 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -77,12 +77,12 @@ */ void tpInit(TOUCHPADDriver * UNUSED(tp)) { /* Initialise Mutex */ - MUTEX_INIT + //MUTEX_INIT /* Initialise driver */ - MUTEX_ENTER - tp_lld_init(tp); - MUTEX_EXIT + //MUTEX_ENTER + tp_lld_init(); + //MUTEX_EXIT } #endif From 19bb3b15dd368b019cdab1b12565156b84f9d32a Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 02:03:26 +0200 Subject: [PATCH 11/24] tpInit() --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 16 ++++--- .../touchpad/touchpadXPT2046/xpt2046_lld.c.h | 46 +++++++++++++++---- halext/include/touchpad.h | 6 +-- halext/include/touchpad_lld.h | 8 +++- 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 8a2de34e..4dc29dbe 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -56,6 +56,12 @@ /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ +static const SPIConfig spicfg = { + NULL, + TP_CS_PORT, + TP_CS, + SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, +}; /*===========================================================================*/ /* Driver local functions. */ @@ -78,11 +84,8 @@ * * @notapi */ -void tp_lld_init(void) { - /* Initialise the TOUCHPAD structure */ - - /* ToDo */ - (void)tp; +void tp_lld_init(TOUCHPADDriver *tp) { + spiStart(tp->spid, &spicfg); } /** @@ -112,7 +115,7 @@ uint16_t tp_lld_read_y(void) { * * @notapi */ - uint16_t tp_lld_read_y(void) { + uint16_t tp_lld_read_z(void) { /* ToDo */ return 42; } @@ -120,3 +123,4 @@ uint16_t tp_lld_read_y(void) { #endif /* HAL_USE_TOUCHPAD */ /** @} */ + diff --git a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h index 2e891684..97adc1ad 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h +++ b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h @@ -21,20 +21,50 @@ #ifndef _XPT2046_H #define _XPT2046_H -void tp_lld_init(TOUCHPADDriver *tp) { +#include "ch.h" +#include "hal.h" +#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) +#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) + +__inline uint16_t lld_tpReadX(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t x; + + txbuf[0] = 0xd0; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + x = rxbuf[0] << 4; + x |= rxbuf[1] >> 4; + + return x; } -uint16_t tp_lld_read_x(void) { - return 42; +__inline uint16_t lld_tpReadY(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0x90; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; } -uint16_t tp_lld_read_y(void) { - return 42; +__inline uint16_t lld_tpReadZ(void) { + return 0; } -uint16_t tp_lld_read_z(void) { - return 42; -} #endif /* _XPT2046_H */ + diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 12b462fd..c6e44b55 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -60,21 +60,17 @@ extern "C" { uint16_t tpReadY(void); #if TOUCHPAD_PRESSURE - uint16_t tpReadZ(void); - #endif #else - #define tpInit(tp) tp_lld_init() + #define tpInit(tp) tp_lld_init(tp) #define tpReadX() tp_lld_read_x() #define tpReadY() tp_lld_read_y() #if TOUCHPAD_PRESSURE - #define tpReadZ() tp_lld_read_z() - #endif #endif diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index ccff7d4d..ab2e54d6 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -55,7 +55,11 @@ typedef struct TOUCHPADDriver TOUCHPADDriver; * @brief Structure representing a Touchpad driver. */ struct TOUCHPADDriver { - /* ToDo */ + /* + * @brief Pointer to SPI driver. + * @note SPI driver must be enabled in mcu- and halconf.h + */ + SPIDriver *spid; }; /*===========================================================================*/ @@ -71,7 +75,7 @@ extern "C" { #endif /* Core functions */ - void tp_lld_init(void); + void tp_lld_init(TOUCHPADDriver *tp); uint16_t tp_lld_read_x(void); uint16_t tp_lld_read_y(void); From 4c3e1847dede93bf3f1671a00e86c57c0c1387ac Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 02:22:10 +0200 Subject: [PATCH 12/24] removed TOUCHPAD_NEED_MULTITASKING --- .../touchpad/touchpadXPT2046/xpt2046_lld.c.h | 2 + halext/include/touchpad.h | 35 +++--- halext/src/touchpad.c | 105 ++++++++++-------- 3 files changed, 73 insertions(+), 69 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h index 97adc1ad..2b33034a 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h +++ b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h @@ -62,6 +62,8 @@ __inline uint16_t lld_tpReadY(void) { } __inline uint16_t lld_tpReadZ(void) { + /* ToDo */ + return 0; } diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index c6e44b55..222411cf 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -45,6 +45,16 @@ /* Type definitions */ /*===========================================================================*/ +/** + * @brief Struct used for calibration + */ +struct cal { + float xm; + float ym; + float xn; + float yn; +}; + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ @@ -53,29 +63,14 @@ extern "C" { #endif -#if TOUCHPAD_NEED_MULTITHREAD - - void tpInit(TOUCHPADDriver *tp); - uint16_t tpReadX(void); - uint16_t tpReadY(void); - - #if TOUCHPAD_PRESSURE - uint16_t tpReadZ(void); - #endif - -#else - - #define tpInit(tp) tp_lld_init(tp) - #define tpReadX() tp_lld_read_x() - #define tpReadY() tp_lld_read_y() - - #if TOUCHPAD_PRESSURE - #define tpReadZ() tp_lld_read_z() - #endif +void tpInit(TOUCHPADDriver *tp); +uint16_t tpReadX(void); +uint16_t tpReadY(void); +#if TOUCHPAD_PRESSURE + uint16_t tpReadZ(void); #endif - #ifdef __cplusplus } #endif diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index f65ca0cd..4adb25fe 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -27,17 +27,11 @@ */ #include "ch.h" #include "hal.h" +#include "gdisp.h" #include "touchpad.h" #if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) -#if GDISP_NEED_MULTITHREAD - #warning "TOUCHPAD: Multithread support not complete" - #define MUTEX_INIT /* Not defined yet */ - #define MUTEX_ENTER /* Not defined yet */ - #define MUTEX_EXIT /* Not defined yet */ -#endif - /*===========================================================================*/ /* Driver local definitions. */ /*===========================================================================*/ @@ -58,6 +52,9 @@ /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ +volatile static struct cal cal = { + 1, 1, 0, 0 +}; /*===========================================================================*/ /* Driver local functions. */ @@ -67,52 +64,62 @@ /* Driver exported functions. */ /*===========================================================================*/ -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Touchpad Driver initialization. - * @note This function is NOT currently implicitly invoked by @p halInit(). - * It must be called manually. - * - * @init - */ - void tpInit(TOUCHPADDriver * UNUSED(tp)) { - /* Initialise Mutex */ - //MUTEX_INIT +/** + * @brief Touchpad Driver initialization. + * @note This function is NOT currently implicitly invoked by @p halInit(). + * It must be called manually. + * + * @init + */ +void tpInit(TOUCHPADDriver *tp) { + /* Initialise Mutex */ + //MUTEX_INIT - /* Initialise driver */ - //MUTEX_ENTER - tp_lld_init(); - //MUTEX_EXIT - } -#endif + /* Initialise driver */ + //MUTEX_ENTER + tp_lld_init(tp); + //MUTEX_EXIT +} -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Get the X-Coordinate, relative to screen zero point. - * - * @return The X position in pixels. - * - * @api - */ - uint16_t tpReadX(void) { - return (tp_lld_read_x()); - } -#endif +/** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The X position in pixels. + * + * @api + */ +uint16_t tpReadX(void) { + uint16_t x, y; -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Get the X-Coordinate, relative to screen zero point. - * - * @return The Y position in pixels. - * - * @api - */ - uint16_t tpReadY(void) { - return (tp_lld_read_y()); - } -#endif + x = cal.xm * _tpReadRealX() + cal.xn; + y = cal.ym * _tpReadRealY() + cal.yn; -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + //switch(gdispGetOrientation()) { + switch(portrait) { // implement gdispGetOrientation() + case portrait: + return x; + case landscape: + return SCREEN_HEIGHT - y; + case portraitInv: + return SCREEN_WIDTH - x; + case landscapeInv: + return y; + } + return x; +} + +/** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The Y position in pixels. + * + * @api + */ +uint16_t tpReadY(void) { + return (tp_lld_read_y()); +} + +#if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) /** * @brief Get the pressure. * From 55c8323950397d7bb6829f9fbd1a50a61d4913ce Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 02:31:42 +0200 Subject: [PATCH 13/24] more touchpad stuff --- halext/include/touchpad.h | 7 +++++ halext/src/touchpad.c | 61 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 222411cf..21e71a97 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -30,6 +30,13 @@ #if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) +/** + * @brief specifies how many conversions are made for a readout. + * + * @note higher is more accurate, but takes more time + */ +#define CONVERSIONS 3 + /*===========================================================================*/ /* Driver constants. */ /*===========================================================================*/ diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 4adb25fe..912e2256 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -60,6 +60,44 @@ volatile static struct cal cal = { /* Driver local functions. */ /*===========================================================================*/ +/** + * @brief returns the uncalibrated readout of the X direction from the controller + * + * @noapi + */ +static uint16_t _tpReadRealX(void) { + uint32_t results = 0; + uint16_t i, x; + + for(i = 0; i < CONVERSIONS; i++) { + tp_lld_read_x(); /* dummy, reduce noise on SPI */ + results += tp_lld_read_x(); + } + + x = (((SCREEN_WIDTH-1) * (results/CONVERSIONS)) / 2048); + + return x; +} + +/** + * @brief return the uncalibrated readout of the Y-direction from the controller + * + * @noapi + */ +static uint16_t _tpReadRealY(void) { + uint32_t results = 0; + uint16_t i, y; + + for(i = 0; i < CONVERSIONS; i++) { + tp_lld_read_y(); /* dummy, reduce noise on SPI */ + results += tp_lld_read_y(); + } + + y = (((SCREEN_HEIGHT-1) * (results/CONVERSIONS)) / 2048); + + return y; +} + /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ @@ -105,7 +143,8 @@ uint16_t tpReadX(void) { case landscapeInv: return y; } - return x; + + return x; } /** @@ -116,7 +155,24 @@ uint16_t tpReadX(void) { * @api */ uint16_t tpReadY(void) { - return (tp_lld_read_y()); + uint16_t x, y; + + x = cal.xm * _tpReadRealX() + cal.xn; + y = cal.ym * _tpReadRealY() + cal.yn; + + //switch(gdispGetOrientation()) { + switch(portrait) { // implement gdispGetOrientation() + case portrait: + return y; + case landscape: + return x; + case portraitInv: + return SCREEN_HEIGHT - y; + case landscapeInv: + return SCREEN_WIDTH - x; + } + + return y; } #if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) @@ -128,6 +184,7 @@ uint16_t tpReadY(void) { * @api */ uint16_t tpReadZ(void) { + /* ToDo */ return (tp_lld_read_z()); } #endif From 18581a40deb63aba81b9f1f6ccd7e6d9163034fd Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 03:01:21 +0200 Subject: [PATCH 14/24] touchpad fix --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 37 ++++++++-- .../touchpad/touchpadXPT2046/xpt2046_lld.c.h | 72 ------------------- 2 files changed, 31 insertions(+), 78 deletions(-) delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 4dc29dbe..a42f1bf8 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -36,6 +36,9 @@ /* Driver local definitions. */ /*===========================================================================*/ +#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) +#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) + #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) @@ -67,8 +70,6 @@ static const SPIConfig spicfg = { /* Driver local functions. */ /*===========================================================================*/ -#include "xpt2046_lld.c.h" - /*===========================================================================*/ /* Driver interrupt handlers. */ /*===========================================================================*/ @@ -94,8 +95,20 @@ void tp_lld_init(TOUCHPADDriver *tp) { * @notapi */ uint16_t tp_lld_read_x(void) { - /* ToDo */ - return 42; + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0x90; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; } /* @@ -104,8 +117,20 @@ uint16_t tp_lld_read_x(void) { * @notapi */ uint16_t tp_lld_read_y(void) { - /* ToDo */ - return 42; + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0x90; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; } /* ---- Optional Routines ---- */ diff --git a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h deleted file mode 100644 index 2b33034a..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver 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-LCD-Driver 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 . -*/ - -#ifndef _XPT2046_H -#define _XPT2046_H - -#include "ch.h" -#include "hal.h" - -#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) -#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) - -__inline uint16_t lld_tpReadX(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t x; - - txbuf[0] = 0xd0; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - x = rxbuf[0] << 4; - x |= rxbuf[1] >> 4; - - return x; -} - -__inline uint16_t lld_tpReadY(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0x90; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -__inline uint16_t lld_tpReadZ(void) { - /* ToDo */ - - return 0; -} - - -#endif /* _XPT2046_H */ - From 385798b21217742ae63380bfdf623e9a5b2c9c36 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 03:07:07 +0200 Subject: [PATCH 15/24] touchpad fix --- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c | 2 +- halext/src/touchpad.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index a42f1bf8..4d02be69 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -99,7 +99,7 @@ uint16_t tp_lld_read_x(void) { uint8_t rxbuf[2]; uint16_t y; - txbuf[0] = 0x90; + txbuf[0] = 0xd0; TP_CS_LOW; spiSend(&SPID1, 1, txbuf); spiReceive(&SPID1, 2, rxbuf); diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 912e2256..7f7c87f6 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -132,8 +132,8 @@ uint16_t tpReadX(void) { x = cal.xm * _tpReadRealX() + cal.xn; y = cal.ym * _tpReadRealY() + cal.yn; - //switch(gdispGetOrientation()) { - switch(portrait) { // implement gdispGetOrientation() + /* + switch(gdispGetOrientation()) { // implement gdispGetOrientation() case portrait: return x; case landscape: @@ -143,6 +143,7 @@ uint16_t tpReadX(void) { case landscapeInv: return y; } + */ return x; } @@ -160,8 +161,8 @@ uint16_t tpReadY(void) { x = cal.xm * _tpReadRealX() + cal.xn; y = cal.ym * _tpReadRealY() + cal.yn; - //switch(gdispGetOrientation()) { - switch(portrait) { // implement gdispGetOrientation() + /* + switch(gdispGetOrientation()) { // implement gdispGetOrientation() case portrait: return y; case landscape: @@ -171,6 +172,7 @@ uint16_t tpReadY(void) { case landscapeInv: return SCREEN_WIDTH - x; } + */ return y; } From 69bcdbba84f936e5da1dd430c75ebd2a9ded41c8 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 03:16:13 +0200 Subject: [PATCH 16/24] added XPT2046 readme --- halext/drivers/touchpad/touchpadXPT2046/readme.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 halext/drivers/touchpad/touchpadXPT2046/readme.txt diff --git a/halext/drivers/touchpad/touchpadXPT2046/readme.txt b/halext/drivers/touchpad/touchpadXPT2046/readme.txt new file mode 100644 index 00000000..992d346d --- /dev/null +++ b/halext/drivers/touchpad/touchpadXPT2046/readme.txt @@ -0,0 +1,9 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_TOUCHPAD TRUE + +2. To your makefile add the following lines: + include $(LCDLIB)/lcd.mk + include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk + From 956f6125446cd73fc839a58a999dbe57e5a35e97 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 03:21:52 +0200 Subject: [PATCH 17/24] TOUCHPAD_PRESSURE -> TOUCHPAD_HAS_PRESSURE --- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c | 2 +- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h | 2 +- halext/include/touchpad.h | 3 ++- halext/include/touchpad_lld.h | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 4d02be69..f85a68d9 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -134,7 +134,7 @@ uint16_t tp_lld_read_y(void) { } /* ---- Optional Routines ---- */ -#if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) +#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) /* * @brief Reads out the Z direction / pressure. * diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 52493836..17f33dd4 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -35,7 +35,7 @@ /* Driver hardware support. */ /*===========================================================================*/ -#define TOUCHPAD_PRESSURE TRUE +#define TOUCHPAD_HAS_PRESSURE TRUE #endif /* HAL_USE_TOUCHPAD */ diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 21e71a97..4f9dce1a 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -73,8 +73,9 @@ extern "C" { void tpInit(TOUCHPADDriver *tp); uint16_t tpReadX(void); uint16_t tpReadY(void); +void tpCalibrate(void); -#if TOUCHPAD_PRESSURE +#if TOUCHPAD_HAS_PRESSURE uint16_t tpReadZ(void); #endif diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index ab2e54d6..7b33f366 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -41,8 +41,8 @@ /* Error checks. */ /*===========================================================================*/ -#ifndef TOUCHPAD_PRESSURE - #define TOUCHPAD_PRESSURE FALSE +#ifndef TOUCHPAD_HAS_PRESSURE + #define TOUCHPAD_HAS_PRESSURE FALSE #endif /*===========================================================================*/ From 03c27adb1c86d37548e695fd89937f01ed528954 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 03:30:45 +0200 Subject: [PATCH 18/24] added tpIRQ() --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 13 +++++++++++++ .../touchpadXPT2046/touchpad_lld_config.h | 1 + halext/include/touchpad.h | 5 ++++- halext/include/touchpad_lld.h | 10 +++++++++- halext/src/touchpad.c | 17 +++++++++++++++-- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index f85a68d9..d44d7212 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -134,6 +134,19 @@ uint16_t tp_lld_read_y(void) { } /* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @noapi + */ + uint8_t tp_lld_irq(void) { + return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); + } +#endif + #if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) /* * @brief Reads out the Z direction / pressure. diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 17f33dd4..399117f9 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -35,6 +35,7 @@ /* Driver hardware support. */ /*===========================================================================*/ +#define TOUCHPAD_HAS_IRQ TRUE #define TOUCHPAD_HAS_PRESSURE TRUE #endif /* HAL_USE_TOUCHPAD */ diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 4f9dce1a..445d3202 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -73,7 +73,10 @@ extern "C" { void tpInit(TOUCHPADDriver *tp); uint16_t tpReadX(void); uint16_t tpReadY(void); -void tpCalibrate(void); + +#if TOUCHPAD_HAS_IRQ + uint8_t tpIRQ(void); +#endif #if TOUCHPAD_HAS_PRESSURE uint16_t tpReadZ(void); diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index 7b33f366..c0339e05 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -41,6 +41,10 @@ /* Error checks. */ /*===========================================================================*/ +#ifndef TOUCHPAD_HAS_IRQ + #define TOUCHPAD_HAS_IRQ FALSE +#endif + #ifndef TOUCHPAD_HAS_PRESSURE #define TOUCHPAD_HAS_PRESSURE FALSE #endif @@ -79,7 +83,11 @@ extern "C" { uint16_t tp_lld_read_x(void); uint16_t tp_lld_read_y(void); - #if TOUCHPAD_PRESSURE + #if TOUCHPAD_HAS_IRQ + uint8_t tp_lld_irq(void); + #endif + + #if TOUCHPAD_HAS_PRESSURE uint16_t tp_lld_read_z(void); #endif diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 7f7c87f6..2b51504a 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -107,7 +107,7 @@ static uint16_t _tpReadRealY(void) { * @note This function is NOT currently implicitly invoked by @p halInit(). * It must be called manually. * - * @init + * @api */ void tpInit(TOUCHPADDriver *tp) { /* Initialise Mutex */ @@ -177,7 +177,20 @@ uint16_t tpReadY(void) { return y; } -#if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /** + * @brief returns if touchpad is pressed or not + * + * @return 1 if pressed, 0 otherwise + * + * @api + */ + uint8_t tpIRQ(void) { + return tp_lld_irq(); + } +#endif + +#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) /** * @brief Get the pressure. * From b8e412e066db3f3f231a6873e5f4da15ff297c2d Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 03:43:30 +0200 Subject: [PATCH 19/24] implemented tpCalibrate() --- halext/include/gdisp_lld.h | 2 ++ halext/src/touchpad.c | 50 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/halext/include/gdisp_lld.h b/halext/include/gdisp_lld.h index 970fd712..e9edbe96 100644 --- a/halext/include/gdisp_lld.h +++ b/halext/include/gdisp_lld.h @@ -296,6 +296,8 @@ #define RED_OF(c) (((c) & 0xF800)>>8) #define GREEN_OF(c) (((c)&0x007E)>>3) #define BLUE_OF(c) (((c)&0x001F)<<3) + #define RGB565CONVERT(red, green, blue) (uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 )) + #elif defined(GDISP_PIXELFORMAT_RGB888) typedef uint32_t color_t; diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 2b51504a..5274e350 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -98,6 +98,30 @@ static uint16_t _tpReadRealY(void) { return y; } +/** + * @brief draws a cross. Used for calibration. + * + * @noapi + */ +static void _tpDrawCross(uint16_t x, uint16_t y) { + gdispDrawLine(x-15, y, x-2, y, 0xffff); + gdispDrawLine(x+2, y, x+15, y, 0xffff); + gdispDrawLine(x, y-15, x, y-2, 0xffff); + gdispDrawLine(x, y+2, x, y+15, 0xffff); + + gdispDrawLine(x-15, y+15, x-7, y+15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x-15, y+7, x-15, y+15, RGB565CONVERT(184,158,131)); + + gdispDrawLine(x-15, y-15, x-7, y-15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x-15, y-7, x-15, y-15, RGB565CONVERT(184,158,131)); + + gdispDrawLine(x+7, y+15, x+15, y+15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x+15, y+7, x+15, y+15, RGB565CONVERT(184,158,131)); + + gdispDrawLine(x+7, y-15, x+15, y-15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x+15, y-15, x+15, y-7, RGB565CONVERT(184,158,131)); +} + /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ @@ -177,6 +201,32 @@ uint16_t tpReadY(void) { return y; } +void tpCalibrate(void) { + uint16_t cross[2][2] = {{40,50}, {200, 280}}; + uint16_t points[2][2]; + uint8_t i; + + //gdispSetOrientation(portrait); + gdispClear(Red); + gdispDrawString(40, 10, "Calibration", &fontUI1Double, White); + + for(i = 0; i < 2; i++) { + _tpDrawCross(cross[i][0], cross[i][1]); + while(!tpIRQ()); + points[i][0] = _tpReadRealX(); + points[i][1] = _tpReadRealY(); + chThdSleepMilliseconds(100); + while(tpIRQ()); + gdispFillArea(cross[i][0]-15, cross[i][1]-15, 42, 42, Red); + } + + cal.xm = ((float)cross[1][0] - (float)cross[0][0]) / ((float)points[1][0] - (float)points[0][0]); + cal.ym = ((float)cross[1][1] - (float)cross[0][1]) / ((float)points[1][1] - (float)points[0][1]); + + cal.xn = (float)cross[0][0] - cal.xm * (float)points[0][0]; + cal.yn = (float)cross[0][1] - cal.ym * (float)points[0][1]; +} + #if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) /** * @brief returns if touchpad is pressed or not From 883b9345b4c1d98b25f634f9fd19582bdd1f4273 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 09:31:07 +0200 Subject: [PATCH 20/24] added ADS7843 touchpad driver --- .../touchpad/touchpadADS7843/readme.txt | 9 ++ .../touchpad/touchpadADS7843/touchpad_lld.c | 152 ++++++++++++++++++ .../touchpad/touchpadADS7843/touchpad_lld.mk | 6 + .../touchpadADS7843/touchpad_lld_config.h | 44 +++++ 4 files changed, 211 insertions(+) create mode 100644 halext/drivers/touchpad/touchpadADS7843/readme.txt create mode 100644 halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c create mode 100644 halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk create mode 100644 halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h diff --git a/halext/drivers/touchpad/touchpadADS7843/readme.txt b/halext/drivers/touchpad/touchpadADS7843/readme.txt new file mode 100644 index 00000000..34a57bc0 --- /dev/null +++ b/halext/drivers/touchpad/touchpadADS7843/readme.txt @@ -0,0 +1,9 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_TOUCHPAD TRUE + +2. To your makefile add the following lines: + include $(LCDLIB)/lcd.mk + include $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk + diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c new file mode 100644 index 00000000..85db56e7 --- /dev/null +++ b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c @@ -0,0 +1,152 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +/** + * @file touchpadADS7843/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) +#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + TOUCHPADDriver Touchpad; +#endif + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ +static const SPIConfig spicfg = { + NULL, + TP_CS_PORT, + TP_CS, + SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, +}; + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ + +/** + * @brief Low level Touchpad driver initialization. + * + * @notapi + */ +void tp_lld_init(TOUCHPADDriver *tp) { + spiStart(tp->spid, &spicfg); +} + +/** + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t tp_lld_read_x(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0xd0; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; +} + +/* + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t tp_lld_read_y(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0x90; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; +} + +/* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @noapi + */ + uint8_t tp_lld_irq(void) { + return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk new file mode 100644 index 00000000..42f66b8c --- /dev/null +++ b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +HALSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c + +# Required include directories +HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843 + diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h new file mode 100644 index 00000000..1e878795 --- /dev/null +++ b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h @@ -0,0 +1,44 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver 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-LCD-Driver 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 . +*/ + +/** + * @file touchpadADS7843/touchpad_lld_config.h + * @brief Touchpad Driver subsystem low level driver. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_CONFIG_H +#define _TOUCHPAD_LLD_CONFIG_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define TOUCHPAD_HAS_IRQ TRUE +#define TOUCHPAD_HAS_PRESSURE FALSE + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_CONFIG_H */ +/** @} */ From fdb5d8a5808dbe9081bc39088a71351c71629d62 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 09:35:54 +0200 Subject: [PATCH 21/24] fixed licensing on XPT2046 --- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c | 2 +- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index d44d7212..00f6336c 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2012 + ChibiOS-LCD-Driver - Copyright (C) 2012 Joel Bodenmann aka Tectu This file is part of ChibiOS-LCD-Driver. diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 399117f9..4ddd8da0 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2012 + ChibiOS-LCD-Driver - Copyright (C) 2012 Joel Bodenmann aka Tectu This file is part of ChibiOS-LCD-Driver. From fda647c6c2111857cec188a7f6f104c459d87684 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 09:39:22 +0200 Subject: [PATCH 22/24] doc --- halext/src/touchpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 5274e350..3539ad32 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -74,6 +74,7 @@ static uint16_t _tpReadRealX(void) { results += tp_lld_read_x(); } + // 12-bit x = (((SCREEN_WIDTH-1) * (results/CONVERSIONS)) / 2048); return x; @@ -93,6 +94,7 @@ static uint16_t _tpReadRealY(void) { results += tp_lld_read_y(); } + // 12-bit y = (((SCREEN_HEIGHT-1) * (results/CONVERSIONS)) / 2048); return y; From e9bf4f92f05e0f34a5cc4734de791087e3f37e9e Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 08:57:45 +0200 Subject: [PATCH 23/24] added doxyfile --- Doxyfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Doxyfile diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 00000000..4c38027b --- /dev/null +++ b/Doxyfile @@ -0,0 +1,23 @@ +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "ChibiOS-LCD-Driver" +PROJECT_NUMBER = 0.0.1 +PROJECT_BRIEF = "Library for interfacing GLCDs with Touchpad to ChibiOS" +OUTPUT_LANGUAGE = English +TAB_SIZE = 2 +OPTIMIZE_OUTPUT_FOR_C = YES +INPUT = +RECURSIVE = YES +GENERATE_LATEX = NO +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_DYNAMIC_SECTIONS = YES +GENERATE_TREEVIEW = YES +DISABLE_INDEX = YES +TREEVIEW_WIDTH = 300 +SEARCHENGINE = YES +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +GRAPHICAL_HIERARCHY = YES + From 36a95ec8a68560cb4dac56e417b6d7d7503dd9e4 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 08:58:24 +0200 Subject: [PATCH 24/24] readme update --- readme | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme b/readme index 94ed8222..0b67c9b0 100644 --- a/readme +++ b/readme @@ -1,3 +1,8 @@ +## Doxygen +run doxygen in the toplevel directory to generate the doxygen documentation in html + + + ## Wiki please read the wiki pages to this project carefully, before you ask any questions: