72 lines
1.4 KiB
C
72 lines
1.4 KiB
C
#ifndef LCD_HD44780_H_
|
|
#define LCD_HD44780_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
// bit definetions
|
|
#define LCD_HD44780_RS 0
|
|
#define LCD_HD44780_RW 1
|
|
#define LCD_HD44780_E 2
|
|
|
|
#define LCD_HD44780_WRITE 0
|
|
#define LCD_HD44780_READ 1
|
|
|
|
typedef enum {
|
|
LCD_BITMODE_8BIT,
|
|
LCD_BITMODE_4BIT,
|
|
|
|
}lcd_hd44780_bitmode;
|
|
|
|
typedef enum {
|
|
|
|
LCD_HD44780_CLEAR_DISP = 0x1,
|
|
LCD_HD44780_RETURN_HOME = 0x2,
|
|
LCD_HD44780_ENTRY_MODE = 0x3,
|
|
LCD_HD44780_DISP_ONOFF_CTL = 0x4,
|
|
LCD_HD44780_CURSOR_SHIFT = 0x6,
|
|
|
|
}hd44780_cmd_t;
|
|
|
|
typedef enum{
|
|
LCD_HD44780_GET = 0,
|
|
LCD_HD44780_SET = 1,
|
|
|
|
}hd44780_setGet_t;
|
|
|
|
typedef enum{
|
|
LCD_HD44780_INSTRUCTION = 0,
|
|
LCD_HD44780_DATA = 1,
|
|
|
|
}hd44780_InstData_t;
|
|
|
|
typedef struct {
|
|
|
|
uint8_t data_bus : 8;
|
|
hd44780_setGet_t rw_pin : 1;
|
|
uint8_t e_pin : 1;
|
|
hd44780_InstData_t rs_pin :1 ;
|
|
|
|
}hd44780_gpioset_t;
|
|
|
|
typedef int (*setGet_Gpio_Event_fpt)(hd44780_gpioset_t *data_input, uint8_t set_get)reentrant;
|
|
typedef int (*wait_ms_Event_fpt)(uint32_t delay_ms)reentrant;
|
|
|
|
typedef struct{
|
|
|
|
void *DataGpio;
|
|
void *SettingsGpio;
|
|
setGet_Gpio_Event_fpt setGetGpio_event;
|
|
wait_ms_Event_fpt wait_event;
|
|
lcd_hd44780_bitmode bit_mode;
|
|
hd44780_gpioset_t gpio_data;
|
|
|
|
|
|
}lcd_hd44780_t;
|
|
|
|
|
|
void lcd_hd44780_init(lcd_hd44780_t *inst,lcd_hd44780_bitmode bit_mode);
|
|
void lcd_hd44780_regGpioEvt(lcd_hd44780_t *inst, setGet_Gpio_Event_fpt getGpioEvt_fpt);
|
|
void lcd_hd44780_regWaitEvt(lcd_hd44780_t *inst, wait_ms_Event_fpt waitEvt_fpt);
|
|
|
|
#endif /*LCD_HD44780_H_*/
|