aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2013-04-20 04:07:57 -0700
committerAndrew Hannam <andrewh@inmarket.com.au>2013-04-20 04:07:57 -0700
commitdc85ef79aa520e000f15dfb5d781ce0a86babd0b (patch)
tree92a9f37aeef2468be6eeaa56111603de9e88d6f4 /drivers
parent5412fa559673f46cdec652068eaaddcbb6271779 (diff)
parent86b35d641d44b4d89ba279a947d42fb8680feadc (diff)
downloaduGFX-dc85ef79aa520e000f15dfb5d781ce0a86babd0b.tar.gz
uGFX-dc85ef79aa520e000f15dfb5d781ce0a86babd0b.tar.bz2
uGFX-dc85ef79aa520e000f15dfb5d781ce0a86babd0b.zip
Merge pull request #27 from Tectu/master
Merge Tectu Changes
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gdisp/ILI9320/gdisp_lld_board_olimex_pic32mx_lcd.h5
-rw-r--r--drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h2
-rw-r--r--drivers/gdisp/SSD1963/gdisp_lld_panel_example.h2
-rw-r--r--drivers/ginput/touch/MCU/ginput_lld_mouse.c2
-rw-r--r--drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h164
-rw-r--r--drivers/tdisp/HD44780/tdisp_lld.c110
-rw-r--r--drivers/tdisp/HD44780/tdisp_lld_board_st_stm32f4_discovery.h81
7 files changed, 327 insertions, 39 deletions
diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_pic32mx_lcd.h b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_pic32mx_lcd.h
index ec63352a..f208f917 100644
--- a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_pic32mx_lcd.h
+++ b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_pic32mx_lcd.h
@@ -77,11 +77,16 @@ static noinline void gdisp_lld_reset_pin(bool_t state) {
}
static noinline void gdisp_lld_write_index(uint16_t data) {
+ volatile uint16_t dummy;
+
PmpWaitBusy();
palClearPad(IOPORTA, 10);
PMDIN = data;
PmpWaitBusy();
palSetPad(IOPORTA, 10);
+
+ dummy = PMDIN;
+ (void)dummy;
}
static noinline void gdisp_lld_write_data(uint16_t data) {
diff --git a/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h b/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h
index 12d40486..ad9fa8e4 100644
--- a/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h
+++ b/drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h
@@ -19,7 +19,7 @@
*/
/**
- * @file drivers/gdisp/SSD1963/gdisp_lld_board_example.h
+ * @file drivers/gdisp/SSD1963/gdisp_lld_board_example_gpio.h
* @brief GDISP Graphic Driver subsystem board interface for the SSD1963 display.
*
* @addtogroup GDISP
diff --git a/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h b/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h
index d0eea0d3..109d7332 100644
--- a/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h
+++ b/drivers/gdisp/SSD1963/gdisp_lld_panel_example.h
@@ -19,7 +19,7 @@
*/
/**
- * @file SSD1963/gdisp_lld_panel.h
+ * @file drivers/gdisp/SSD1963/gdisp_lld_panel_example.h
* @brief TFT LCD panel properties.
*
* @addtogroup GDISP
diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse.c b/drivers/ginput/touch/MCU/ginput_lld_mouse.c
index 2a5b6944..1b7e1988 100644
--- a/drivers/ginput/touch/MCU/ginput_lld_mouse.c
+++ b/drivers/ginput/touch/MCU/ginput_lld_mouse.c
@@ -40,6 +40,8 @@
#include "ginput_lld_mouse_board.h"
#elif defined(BOARD_OLIMEX_STM32_LCD)
#include "ginput_lld_mouse_board_olimex_stm32_lcd.h"
+#elif defined(BOARD_OLIMEX_PIC32MX_LCD)
+ #include "ginput_lld_mouse_board_olimex_pic32mx_lcd.h"
#else
#include "ginput_lld_mouse_board.h"
#endif
diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h
new file mode 100644
index 00000000..4f55124d
--- /dev/null
+++ b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h
@@ -0,0 +1,164 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h
+ * @brief GINPUT Touch low level driver source for the MCU on the example board.
+ *
+ * @defgroup Mouse Mouse
+ * @ingroup GINPUT
+ *
+ * @{
+ */
+
+#ifndef _GINPUT_LLD_MOUSE_BOARD_H
+#define _GINPUT_LLD_MOUSE_BOARD_H
+
+static const ADCConfig ADCC = {
+ .vref = ADC_VREF_CFG_AVDD_AVSS,
+ .stime = 15,
+ .irq = EIC_IRQ_ADC,
+ .base = _ADC10_BASE_ADDRESS,
+};
+static struct ADCDriver ADCD;
+
+#define YNEG 13 // U
+#define XNEG 15 // R
+#define XPOS 12 // L
+#define YPOS 11 // D
+
+#define ADC_MAX 1023
+
+#define TOUCH_THRESHOULD 50
+
+static const ADCConversionGroup ADC_X_CG = {
+ .circular = FALSE,
+ .num_channels = 1,
+ .channels = 1 << XNEG,
+};
+
+static const ADCConversionGroup ADC_Y_CG = {
+ .circular = FALSE,
+ .num_channels = 1,
+ .channels = 1 << YPOS,
+};
+
+/**
+ * @brief Initialise the board for the touch.
+ *
+ * @notapi
+ */
+static inline void init_board(void) {
+ adcObjectInit(&ADCD);
+ adcStart(&ADCD, &ADCC);
+}
+
+/**
+ * @brief Check whether the surface is currently touched
+ * @return TRUE if the surface is currently touched
+ *
+ * @notapi
+ */
+static inline bool_t getpin_pressed(void) {
+ adcsample_t samples[2] = {0, };
+
+ // Set X+ to ground
+ palSetPadMode(IOPORTB, XPOS, PAL_MODE_OUTPUT);
+ palClearPad(IOPORTB, XPOS);
+
+ // Set Y- to VCC
+ palSetPadMode(IOPORTB, YNEG, PAL_MODE_OUTPUT);
+ palSetPad(IOPORTB, YNEG);
+
+ palSetPadMode(IOPORTB, XNEG, PAL_MODE_INPUT_ANALOG);
+ palSetPadMode(IOPORTB, YPOS, PAL_MODE_INPUT_ANALOG);
+
+ adcConvert(&ADCD, &ADC_X_CG, &samples[0], 1);
+ adcConvert(&ADCD, &ADC_Y_CG, &samples[1], 1);
+
+ return (ADC_MAX - (samples[1] - samples[0])) > TOUCH_THRESHOULD;
+}
+
+/**
+ * @brief Aquire the bus ready for readings
+ *
+ * @notapi
+ */
+static inline void aquire_bus(void) {
+}
+
+/**
+ * @brief Release the bus after readings
+ *
+ * @notapi
+ */
+static inline void release_bus(void) {
+}
+
+/**
+ * @brief Read an x value from touch controller
+ * @return The value read from the controller
+ *
+ * @notapi
+ */
+static inline uint16_t read_x_value(void) {
+ adcsample_t sample;
+
+ palSetPadMode(IOPORTB, XPOS, PAL_MODE_OUTPUT);
+ palSetPad(IOPORTB, XPOS);
+
+ palSetPadMode(IOPORTB, XNEG, PAL_MODE_OUTPUT);
+ palClearPad(IOPORTB, XNEG);
+
+ palSetPadMode(IOPORTB, YNEG, PAL_MODE_INPUT);
+
+ palSetPadMode(IOPORTB, YPOS, PAL_MODE_INPUT_ANALOG);
+
+ adcConvert(&ADCD, &ADC_Y_CG, &sample, 1);
+
+ return ADC_MAX - sample;
+}
+
+/**
+ * @brief Read an y value from touch controller
+ * @return The value read from the controller
+ *
+ * @notapi
+ */
+static inline uint16_t read_y_value(void) {
+ adcsample_t sample;
+
+ palSetPadMode(IOPORTB, YNEG, PAL_MODE_OUTPUT);
+ palClearPad(IOPORTB, YNEG);
+
+ palSetPadMode(IOPORTB, YPOS, PAL_MODE_OUTPUT);
+ palSetPad(IOPORTB, YPOS);
+
+ palSetPadMode(IOPORTB, XPOS, PAL_MODE_INPUT);
+
+ palSetPadMode(IOPORTB, XNEG, PAL_MODE_INPUT_ANALOG);
+
+ adcConvert(&ADCD, &ADC_X_CG, &sample, 1);
+
+ return ADC_MAX - sample;
+}
+
+#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
+/** @} */
diff --git a/drivers/tdisp/HD44780/tdisp_lld.c b/drivers/tdisp/HD44780/tdisp_lld.c
index 76557d1d..b68d1f55 100644
--- a/drivers/tdisp/HD44780/tdisp_lld.c
+++ b/drivers/tdisp/HD44780/tdisp_lld.c
@@ -32,21 +32,23 @@
#if GFX_USE_TDISP /*|| defined(__DOXYGEN__)*/
-/* Include the hardware interface details */
-#if defined(BOARD_OLIMEX_STM32_E407)
+/* check first if the user has defined his/her own lowlevel-board file */
+#if defined(TDISP_USE_CUSTOM_BOARD) && TDISP_USE_CUSTOM_BOARD
+ /* Include the user supplied board definitions */
+ #include "tdisp_lld_board.h"
+#elif defined(BOARD_OLIMEX_STM32_E407)
#include "tdisp_lld_board_olimex_e407.h"
#elif defined(BOARD_ST_STM32F4_DISCOVERY)
- #include "tdisp_lld_board_st_stm32f4_discovery.h"
-#else
#include "tdisp_lld_board_example.h"
#endif
+
/* The user may override the default display size */
#ifndef TDISP_COLUMNS
#define TDISP_COLUMNS 16
#endif
#ifndef TDISP_ROWS
- #define TDISP_ROWS 2
+ #define TDISP_ROWS 2
#endif
/* Controller Specific Properties */
@@ -56,15 +58,15 @@
/* Define the properties of our controller */
tdispStruct TDISP = {
- TDISP_COLUMNS, TDISP_ROWS, /* cols, rows */
+ TDISP_COLUMNS, TDISP_ROWS, /* cols, rows */
CUSTOM_CHAR_XBITS, CUSTOM_CHAR_YBITS, /* charBitsX, charBitsY */
- CUSTOM_CHAR_COUNT /* maxCustomChars */
+ CUSTOM_CHAR_COUNT /* maxCustomChars */
};
/* Our display control */
-#define DISPLAY_ON 0x04
-#define CURSOR_ON 0x02
-#define CURSOR_BLINK 0x01
+#define TDISP_DISPLAY_ON 0x04
+#define TDISP_CURSOR_ON 0x02
+#define TDISP_CURSOR_BLINK 0x01
static uint8_t displaycontrol;
@@ -72,28 +74,77 @@ static uint8_t displaycontrol;
bool_t tdisp_lld_init(void) {
/* initialise hardware */
init_board();
-
- /* wait some time */
- chThdSleepMilliseconds(50);
-
- write_cmd(0x38);
- chThdSleepMilliseconds(64);
-
- displaycontrol = DISPLAY_ON | CURSOR_ON | CURSOR_BLINK; // The default displaycontrol
- write_cmd(0x08 | displaycontrol);
- chThdSleepMicroseconds(50);
-
- write_cmd(0x01); // Clear the screen
- chThdSleepMilliseconds(5);
-
+
+ /* The first part is the initialing code.
+ * In this part only the lower nibble of the
+ * byte is written directly to the display, thus
+ * without write_cmd, which sends both high and
+ * low nibble.
+ */
+
+ /* Give the LCD a little time to wake up */
+ chThdSleepMilliseconds(15);
+
+ /* write three times 0x03 to display
+ * with RS = low.
+ */
+ palClearPad(PORT_CTRL, PIN_RS);
+ #if BUS_4BITS
+ writeToLCD(0x03); // 1x
+ writeToLCD(0x03); // 2x
+ writeToLCD(0x03); // 3x
+ /* Put display in 4-bit mode by
+ * write 0x02 to display.
+ */
+ writeToLCD(0x02); // 4bit-modus
+ #else
+ writeToLCD(0x30); // 1x
+ writeToLCD(0x30); // 2x
+ writeToLCD(0x30); // 3x
+ #endif
+
+ /* From this point on, the LCD accepts
+ * bytes sent with highnibbel first and than
+ *the lownibble.
+ */
+
+ /* 4-bit modus, 2 lines en 5x7 characters */
+ write_cmd(0x28);
+
+ displaycontrol = TDISP_DISPLAY_ON;
+
+ /* set display on, cursor off and no blinking */
+ write_cmd(0x0C);
+ /* set cursor move direction */
write_cmd(0x06);
- chThdSleepMicroseconds(50);
+ /* END OF INITIALISATION */
+
+// /* wait some time */
+// chThdSleepMilliseconds(50);
+//
+// write_cmd(0x38);
+// chThdSleepMilliseconds(64);
+//
+// displaycontrol = DISPLAY_ON | CURSOR_ON | CURSOR_BLINK; // The default displaycontrol
+// write_cmd(0x08 | displaycontrol);
+// chThdSleepMicroseconds(50);
+//
+// write_cmd(0x01); // Clear the screen
+// chThdSleepMilliseconds(5);
+//
+// write_cmd(0x06);
+// chThdSleepMicroseconds(50);
return TRUE;
}
+/* Clears the display. The display needs
+ * a long time to process this command. So
+ * an extra delay is insterted.
+ */
void tdisp_lld_clear(void) {
write_cmd(0x01);
+// chThdSleepMilliseconds(LONG_DELAY_MS);
}
void tdisp_lld_draw_char(char c) {
@@ -122,11 +173,14 @@ void tdisp_lld_create_char(uint8_t address, uint8_t *charmap) {
int i;
write_cmd(0x40 | (address << 3));
- for(i = 0; i < CUSTOM_CHAR_YBITS; i++)
+ for(i = 0; i < CUSTOM_CHAR_YBITS; i++) {
write_data(charmap[i]);
+ }
+
}
-void tdisp_lld_control(uint16_t what, void *value) {
+void tdisp_lld_control(uint16_t what, uint16_t value) {
+
switch(what) {
case TDISP_CTRL_BACKLIGHT:
if ((uint8_t)value)
@@ -136,7 +190,7 @@ void tdisp_lld_control(uint16_t what, void *value) {
write_cmd(0x08 | displaycontrol);
break;
case TDISP_CTRL_CURSOR:
- switch((cursorshape)value) {
+ switch((uint8_t)value) {
case cursorOff:
displaycontrol &= ~CURSOR_ON;
break;
diff --git a/drivers/tdisp/HD44780/tdisp_lld_board_st_stm32f4_discovery.h b/drivers/tdisp/HD44780/tdisp_lld_board_st_stm32f4_discovery.h
index ceae7a4d..1fe222dc 100644
--- a/drivers/tdisp/HD44780/tdisp_lld_board_st_stm32f4_discovery.h
+++ b/drivers/tdisp/HD44780/tdisp_lld_board_st_stm32f4_discovery.h
@@ -30,41 +30,104 @@
#define _TDISP_LLD_BOARD_H
/* Configure these to match the hardware connections on your board */
-#define BUS_4BITS FALSE
-#define PORT_DATA GPIOG
-#define PORT_CTRL GPIOE
+#define BUS_4BITS TRUE
+
+/* Configure the bitoffset in the dataport so they match with the
+ * hardware pins. An offset of 0 means bit0 stays at bit0 of the dataport.
+ * If the offset is set to 3, bit0 of the nibble will be positioned at
+ * P[A..G]3 of the hardware-port.
+ */
+#define hardware_offset 3
+
+/* The port where the data is sent to. In the
+ * low-leveldriver het hardware_offset is taken
+ * into account. If for example the hardware_offset
+ * is set to 3, then de data will be sent to
+ * PE3, PE4, PE5 en PE6, if the dataport where GPIOE.
+ */
+#define PORT_DATA GPIOE
+
+/* The port used to controle the controle lines of
+ * the display.
+ */
+#define PORT_CTRL GPIOD
+/* Pin to controle the R/S-line of the display */
#define PIN_RS 0
-#define PIN_RW 1
-#define PIN_EN 2
+/* Pin to controle the EN-line of the display */
+#define PIN_EN 1
+/* Pin to controle the R/W-pin of the display.
+ * If reading of the display is not used disable
+ * reading in the gfxconf.h and put a dummy value here
+ * as it will not be used.
+ */
+#define PIN_RW 7
+
static void init_board(void) {
+ /* Initialize the ports for data and controle-lines */
palSetGroupMode(PORT_CTRL, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
palSetGroupMode(PORT_DATA, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
- palClearPad(PORT_CTRL, PIN_RW);
+ /* Set alle controle pins to low */
+ palClearPad(PORT_CTRL, PIN_RS);
+ palClearPad(PORT_CTRL, PIN_EN);
+ #if TDISP_NEED_READ
+ palClearPad(PORT_CTRL, PIN_RW);
+ #endif
}
+/* This is the low-level routine for sending the bits
+ * to the LCD-display. This routine shifts
+ * the bits so they match the hardware port.
+ */
static void writeToLCD(uint8_t data) {
- palWritePort(PORT_DATA, data);
+ palWritePort(PORT_DATA, data<<hardware_offset);
palSetPad(PORT_CTRL, PIN_EN);
chThdSleepMicroseconds(1);
palClearPad(PORT_CTRL, PIN_EN);
+ /* wait a little while so that de display can process the data */
chThdSleepMicroseconds(5);
}
+/* Writes a command to the display. The
+ * RS-line is pulled low and than the
+ * data is send.
+ */
static void write_cmd(uint8_t data) {
palClearPad(PORT_CTRL, PIN_RS);
#if BUS_4BITS
+ /* first send the high-nibble */
writeToLCD(data>>4);
#endif
- writeToLCD(data);
+ /* send the low-nibble */
+ #if BUS_4BITS
+ /* in 4-bit mode the high-nibble is zeroed out */
+ writeToLCD(data & 0x0F);
+ #else
+ writeToLCD(data);
+ #endif
}
+// static void write_initcmd(uint8_t data) {
+// write_cmd(data);
+// }
+
+/* Write data to the display. The
+ * RS-line is pulled high and than the
+ * data is send.
+ */
static void write_data(uint8_t data) {
palSetPad(PORT_CTRL, PIN_RS);
#if BUS_4BITS
+ /* first send the high-nibble */
writeToLCD(data>>4);
#endif
- writeToLCD(data);
+ /* send the low-nibble */
+ #if BUS_4BITS
+ /* in 4-bit mode the high-nibble is zeroed out */
+ writeToLCD(data & 0x0F);
+ #else
+ writeToLCD(data);
+ #endif
}
#endif /* _TDISP_LLD_BOARD_H */