diff options
Diffstat (limited to 'drivers/tdisp/HD44780')
-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 */ |