mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
driver/hd44780: cleanup param definition and HD44780_RW_OFF
There's already a macro for undefined gpios: GPIO_UNDEF
This commit is contained in:
parent
04dc65f6ad
commit
8e70cfb2e4
@ -72,7 +72,7 @@ static void _send(const hd44780_t *dev, uint8_t value, hd44780_state_t state)
|
||||
{
|
||||
(state == HD44780_ON) ? gpio_set(dev->p.rs) : gpio_clear(dev->p.rs);
|
||||
/* if RW pin is available, set it to LOW */
|
||||
if (dev->p.rw != HD44780_RW_OFF) {
|
||||
if (dev->p.rw != GPIO_UNDEF) {
|
||||
gpio_clear(dev->p.rw);
|
||||
}
|
||||
/* write data in 8Bit or 4Bit mode */
|
||||
@ -111,7 +111,7 @@ int hd44780_init(hd44780_t *dev, const hd44780_params_t *params)
|
||||
uint8_t count_pins = 0;
|
||||
/* check which pins are used */
|
||||
for (unsigned i = 0; i < HD44780_MAX_PINS; ++i) {
|
||||
if (dev->p.data[i] != HD44780_RW_OFF) {
|
||||
if (dev->p.data[i] != GPIO_UNDEF) {
|
||||
++count_pins;
|
||||
}
|
||||
}
|
||||
@ -138,8 +138,8 @@ int hd44780_init(hd44780_t *dev, const hd44780_params_t *params)
|
||||
dev->roff[3] = 0x40 + dev->p.cols;
|
||||
|
||||
gpio_init(dev->p.rs, GPIO_OUT);
|
||||
/* RW (read/write) of LCD not required, set it to HD44780_RW_OFF (255) */
|
||||
if (dev->p.rw != HD44780_RW_OFF) {
|
||||
/* RW (read/write) of LCD not required, set it to GPIO_UNDEF */
|
||||
if (dev->p.rw != GPIO_UNDEF) {
|
||||
gpio_init(dev->p.rw, GPIO_OUT);
|
||||
}
|
||||
gpio_init(dev->p.enable, GPIO_OUT);
|
||||
@ -151,7 +151,7 @@ int hd44780_init(hd44780_t *dev, const hd44780_params_t *params)
|
||||
xtimer_usleep(HD44780_INIT_WAIT_XXL);
|
||||
gpio_clear(dev->p.rs);
|
||||
gpio_clear(dev->p.enable);
|
||||
if (dev->p.rw != HD44780_RW_OFF) {
|
||||
if (dev->p.rw != GPIO_UNDEF) {
|
||||
gpio_clear(dev->p.rw);
|
||||
}
|
||||
/* put the LCD into 4 bit or 8 bit mode */
|
||||
|
@ -21,29 +21,52 @@
|
||||
#include "board.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#include "hd44780.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define HD44780_PARAMS_ARDUINO { \
|
||||
.cols = 16, \
|
||||
.rows = 2, \
|
||||
.rs = ARDUINO_PIN_2, \
|
||||
.rw = HD44780_RW_OFF, \
|
||||
.enable = ARDUINO_PIN_3, \
|
||||
.data = {ARDUINO_PIN_4, ARDUINO_PIN_5, ARDUINO_PIN_6, ARDUINO_PIN_7, \
|
||||
HD44780_RW_OFF, HD44780_RW_OFF, HD44780_RW_OFF, HD44780_RW_OFF} \
|
||||
}
|
||||
#ifndef HD44780_PARAM_COLS
|
||||
#define HD44780_PARAM_COLS (16U)
|
||||
#endif
|
||||
#ifndef HD44780_PARAM_ROWS
|
||||
#define HD44780_PARAM_ROWS (2U)
|
||||
#endif
|
||||
#ifndef HD44780_PARAM_PIN_RS
|
||||
#define HD44780_PARAM_PIN_RS ARDUINO_PIN_2
|
||||
#endif
|
||||
#ifndef HD44780_PARAM_PIN_RW
|
||||
#define HD44780_PARAM_PIN_RW GPIO_UNDEF
|
||||
#endif
|
||||
#ifndef HD44780_PARAM_PIN_ENABLE
|
||||
#define HD44780_PARAM_PIN_ENABLE ARDUINO_PIN_3
|
||||
#endif
|
||||
#ifndef HD44780_PARAM_PINS_DATA
|
||||
#define HD44780_PARAM_PINS_DATA { ARDUINO_PIN_4, \
|
||||
ARDUINO_PIN_5, \
|
||||
ARDUINO_PIN_6, \
|
||||
ARDUINO_PIN_7, \
|
||||
GPIO_UNDEF, \
|
||||
GPIO_UNDEF, \
|
||||
GPIO_UNDEF, \
|
||||
GPIO_UNDEF }
|
||||
#endif
|
||||
|
||||
#ifndef HD44780_PARAMS
|
||||
#define HD44780_PARAMS { .cols = HD44780_PARAM_COLS, \
|
||||
.rows = HD44780_PARAM_ROWS, \
|
||||
.rs = HD44780_PARAM_PIN_RS, \
|
||||
.rw = HD44780_PARAM_PIN_RW, \
|
||||
.enable = HD44780_PARAM_PIN_ENABLE, \
|
||||
.data = HD44780_PARAM_PINS_DATA }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LCM1602C configuration
|
||||
*/
|
||||
static const hd44780_params_t hd44780_params[] =
|
||||
{
|
||||
HD44780_PARAMS_ARDUINO,
|
||||
HD44780_PARAMS,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -46,11 +46,6 @@ extern "C" {
|
||||
*/
|
||||
#define HD44780_MAX_PINS (8U)
|
||||
|
||||
/**
|
||||
* @brief Specific value to turn rw pin off, if unused.
|
||||
*/
|
||||
#define HD44780_RW_OFF (255U)
|
||||
|
||||
/**
|
||||
* @brief Size of RAM for custom chars
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user