Browse Source

4-bit mode implemented

remotes/origin_old/ugfx_release_2.6
Joel Bodenmann 10 years ago
parent
commit
d5e7afe756
  1. 35
      drivers/tdisp/HD44780/tdisp_lld.c
  2. 4
      drivers/tdisp/HD44780/tdisp_lld_board_example.h
  3. 16
      include/tdisp/tdisp.h
  4. 4
      src/tdisp/tdisp.c

35
drivers/tdisp/HD44780/tdisp_lld.c

@ -41,42 +41,51 @@
#include "tdisp_lld_board_example.h"
void TDISP_LLD(write_cmd)(uint8_t data) {
setpin_rs(FALSE);
setpin_rw(FALSE);
static void _writeData(uint8_t data) {
write_bus(data);
setpin_e(TRUE);
chThdSleepMicroseconds(1);
setpin_e(FALSE);
chThdSleepMicroseconds(5);
}
void TDISP_LLD(write_cmd)(uint8_t data) {
setpin_rs(FALSE);
setpin_rw(FALSE);
#if TDISP_NEED_4BIT_MODE
_writeData(data>>4);
#endif
_writeData(data);
}
void TDISP_LLD(write_data)(uint8_t data) {
setpin_rs(TRUE);
setpin_rw(FALSE);
write_bus(data);
setpin_e(TRUE);
chThdSleepMicroseconds(1);
setpin_e(FALSE);
chThdSleepMicroseconds(5);
#if TDISP_NEED_4BIT_MODE
_writeData(data>>4);
#endif
_writeData(data);
}
bool_t TDISP_LLD(init)(void) {
/* initialise hardware */
/* initialise MCU hardware */
init_board();
/* initialise controller */
/* wait some time */
chThdSleepMilliseconds(50);
TDISP_LLD(write_cmd)(0x38);
chThdSleepMilliseconds(64);
TDISP_LLD(write_cmd)(0x0f);
chThdSleepMicroseconds(50);
TDISP_LLD(write_cmd)(0x01);
chThdSleepMilliseconds(5);
TDISP_LLD(write_cmd)(0x06);
chThdSleepMicroseconds(50);

4
drivers/tdisp/HD44780/tdisp_lld_board_example.h

@ -31,7 +31,7 @@
void init_board(void) {
palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
palSetGroupMode(GPIOD, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
palSetGroupMode(GPIOG, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL);
}
void setpin_e(bool_t state) {
@ -56,7 +56,7 @@ void setpin_rw(bool_t state) {
}
void write_bus(uint8_t data) {
palWritePort(GPIOD, data);
palWritePort(GPIOG, data);
}
#endif /* _TDISP_LLD_BOARD_H */

16
include/tdisp/tdisp.h

@ -41,6 +41,22 @@
/* Include the low level driver information */
#include "tdisp/lld/tdisp_lld.h"
#ifndef TDISP_NEED_4BIT_MODE
#define TDISP_NEED_4BIT_MODE FALSE
#endif
#ifndef TDISP_NEED_8BIT_MODE
#define TDISP_NEED_8BIT_MODE FALSE
#endif
#if (!TDISP_NEED_4BIT_MODE && !TDISP_NEED_8BIT_MODE)
#error "Either TDISP_NEED_4BIT_MODE or TDISP_NEED_8BIT_MODE needs to be set to TRUE in your gfxconf.h!"
#endif
#if (TDISP_NEED_4BIT_MODE && TDISP_NEED_8BIT_MODE)
#error "Only TDISP_NEED_4BIT_MODE or TDISP_NEED_8BIT_MODE can be set to TRUE, not both at one!"
#endif
/**
* @brief TDISP driver initialisation
* @note This function is not implicitly invoked by @p halInit().

4
src/tdisp/tdisp.c

@ -65,12 +65,12 @@ void tdispDrawString(char *s) {
}
void tdispDrawCharLocation(coord_t col, coord_t row, char c) {
tdispGotoXY(x, y);
tdispGotoXY(col, row);
tdispDrawChar(c);
}
void tdispDrawStringLocation(coord_t col, coord_t row, char *s) {
tdispGotoXY(x, y);
tdispGotoXY(col, row);
tdispDrawString(s);
}

Loading…
Cancel
Save