2013-05-24 15:26:52 +00:00
|
|
|
/*
|
2013-06-15 11:37:22 +00:00
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
2013-06-02 08:58:12 +00:00
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
|
|
|
*
|
2013-07-21 20:20:37 +00:00
|
|
|
* http://ugfx.org/license.html
|
2013-06-02 08:58:12 +00:00
|
|
|
*/
|
2013-01-18 17:00:05 +00:00
|
|
|
|
|
|
|
/**
|
2013-03-10 19:17:24 +00:00
|
|
|
* @file drivers/tdisp/HD44780/tdisp_lld_board_st_stm32f4_discovery.h
|
2013-01-18 17:00:05 +00:00
|
|
|
* @brief TDISP driver subsystem board interface for the HD44780 display
|
|
|
|
*
|
|
|
|
* @addtogroup TDISP
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _TDISP_LLD_BOARD_H
|
|
|
|
#define _TDISP_LLD_BOARD_H
|
|
|
|
|
|
|
|
/* Configure these to match the hardware connections on your board */
|
2013-04-12 07:12:00 +00:00
|
|
|
#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 */
|
2013-01-18 17:00:05 +00:00
|
|
|
#define PIN_RS 0
|
2013-04-12 07:12:00 +00:00
|
|
|
/* 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
|
|
|
|
|
2013-01-18 17:00:05 +00:00
|
|
|
|
|
|
|
static void init_board(void) {
|
2013-04-12 07:12:00 +00:00
|
|
|
/* Initialize the ports for data and controle-lines */
|
2013-01-18 17:00:05 +00:00
|
|
|
palSetGroupMode(PORT_CTRL, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
|
|
|
palSetGroupMode(PORT_DATA, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
2013-04-12 07:12:00 +00:00
|
|
|
/* 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
|
2013-01-18 17:00:05 +00:00
|
|
|
}
|
|
|
|
|
2013-04-12 07:12:00 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2013-01-18 17:00:05 +00:00
|
|
|
static void writeToLCD(uint8_t data) {
|
2013-04-12 07:12:00 +00:00
|
|
|
palWritePort(PORT_DATA, data<<hardware_offset);
|
2013-01-18 17:00:05 +00:00
|
|
|
palSetPad(PORT_CTRL, PIN_EN);
|
2013-06-02 08:58:12 +00:00
|
|
|
gfxSleepMicroseconds(1);
|
2013-01-18 17:00:05 +00:00
|
|
|
palClearPad(PORT_CTRL, PIN_EN);
|
2013-04-12 07:12:00 +00:00
|
|
|
/* wait a little while so that de display can process the data */
|
2013-06-02 08:58:12 +00:00
|
|
|
gfxSleepMicroseconds(5);
|
2013-01-18 17:00:05 +00:00
|
|
|
}
|
|
|
|
|
2013-04-12 07:12:00 +00:00
|
|
|
/* Writes a command to the display. The
|
|
|
|
* RS-line is pulled low and than the
|
|
|
|
* data is send.
|
|
|
|
*/
|
2013-01-18 17:00:05 +00:00
|
|
|
static void write_cmd(uint8_t data) {
|
|
|
|
palClearPad(PORT_CTRL, PIN_RS);
|
|
|
|
#if BUS_4BITS
|
2013-04-12 07:12:00 +00:00
|
|
|
/* first send the high-nibble */
|
2013-01-18 17:00:05 +00:00
|
|
|
writeToLCD(data>>4);
|
|
|
|
#endif
|
2013-04-12 07:12:00 +00:00
|
|
|
/* send the low-nibble */
|
|
|
|
#if BUS_4BITS
|
|
|
|
/* in 4-bit mode the high-nibble is zeroed out */
|
|
|
|
writeToLCD(data & 0x0F);
|
|
|
|
#else
|
|
|
|
writeToLCD(data);
|
|
|
|
#endif
|
2013-01-18 17:00:05 +00:00
|
|
|
}
|
|
|
|
|
2013-04-12 07:12:00 +00:00
|
|
|
// 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.
|
|
|
|
*/
|
2013-01-18 17:00:05 +00:00
|
|
|
static void write_data(uint8_t data) {
|
|
|
|
palSetPad(PORT_CTRL, PIN_RS);
|
|
|
|
#if BUS_4BITS
|
2013-04-12 07:12:00 +00:00
|
|
|
/* first send the high-nibble */
|
2013-01-18 17:00:05 +00:00
|
|
|
writeToLCD(data>>4);
|
|
|
|
#endif
|
2013-04-12 07:12:00 +00:00
|
|
|
/* send the low-nibble */
|
|
|
|
#if BUS_4BITS
|
|
|
|
/* in 4-bit mode the high-nibble is zeroed out */
|
|
|
|
writeToLCD(data & 0x0F);
|
|
|
|
#else
|
|
|
|
writeToLCD(data);
|
|
|
|
#endif
|
2013-01-18 17:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _TDISP_LLD_BOARD_H */
|
|
|
|
/** @} */
|
2013-03-02 21:13:44 +00:00
|
|
|
|