diff options
author | Joel Bodenmann <joel@unormal.org> | 2013-01-10 14:51:31 +0100 |
---|---|---|
committer | Joel Bodenmann <joel@unormal.org> | 2013-01-10 14:51:31 +0100 |
commit | d5e7afe756fe4c19dd9360baed23599b268709af (patch) | |
tree | 5f9532e6da0274c65b799b85e9f2ba2378f09fde /drivers | |
parent | 6cc67bad84176614936f2c6439d640637186764d (diff) | |
download | uGFX-d5e7afe756fe4c19dd9360baed23599b268709af.tar.gz uGFX-d5e7afe756fe4c19dd9360baed23599b268709af.tar.bz2 uGFX-d5e7afe756fe4c19dd9360baed23599b268709af.zip |
4-bit mode implemented
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/tdisp/HD44780/tdisp_lld.c | 35 | ||||
-rw-r--r-- | drivers/tdisp/HD44780/tdisp_lld_board_example.h | 4 |
2 files changed, 24 insertions, 15 deletions
diff --git a/drivers/tdisp/HD44780/tdisp_lld.c b/drivers/tdisp/HD44780/tdisp_lld.c index 0cbd414b..9644eaa8 100644 --- a/drivers/tdisp/HD44780/tdisp_lld.c +++ b/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); diff --git a/drivers/tdisp/HD44780/tdisp_lld_board_example.h b/drivers/tdisp/HD44780/tdisp_lld_board_example.h index de9e0b0b..3f5c47d7 100644 --- a/drivers/tdisp/HD44780/tdisp_lld_board_example.h +++ b/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 */ |