4-bit mode implemented
This commit is contained in:
parent
6cc67bad84
commit
d5e7afe756
4 changed files with 42 additions and 17 deletions
|
@ -41,10 +41,7 @@
|
|||
|
||||
#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);
|
||||
|
@ -53,30 +50,42 @@ void TDISP_LLD(write_cmd)(uint8_t data) {
|
|||
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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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().
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue