This commit is contained in:
Christian Madsen
2023-12-25 11:02:21 +01:00
parent 883d2d590c
commit 43a450b76c
2 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
#include "lcd_hd44780.h"
#include <stddef.h>
void lcd_hd44780_writeToDisp(lcd_hd44780_t *inst){
inst->setGetDataIO_event(inst->DataGpio,inst->port_data,LCD_HD44780_SET);
}
void lcd_hd44780_clearDisp(lcd_hd44780_t *inst){
return;
}
void lcd_hd44780_printf(lcd_hd44780_t *inst, char *string){
return;
}
void lcd_hd44780_regDataEvt(lcd_hd44780_t *inst ,void *inst_Data, setGet_DataGpio_Event_fpt getDataEvt_fpt){
if(inst == NULL)return;
if(inst_Data == NULL)return;
inst->DataGpio = inst_Data;
inst->setGetDataIO_event = getDataEvt_fpt;
}
void lcd_hd44780_regConfigEvt(lcd_hd44780_t *inst ,void *inst_Config, setGet_ConfigGpio_Event_fpt getConfigEvt_fpt){
if(inst == NULL)return;
if(inst_Config == NULL)return;
inst->SettingsGpio = inst_Config;
inst->setGetConfigIO_event = getConfigEvt_fpt;
return;
}
void lcd_hd44780_init(lcd_hd44780_t *inst, lcd_hd44780_bitmode bit_mode){
inst->port_data = 0x00;
inst->bit_mode = bit_mode;
return;
}

View File

@@ -1,4 +1,57 @@
#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;
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,
};
enum{
LCD_HD44780_GET = 0,
LCD_HD44780_SET = 1,
};
typedef int (*setGet_DataGpio_Event_fpt)(void*, uint8_t data_input, uint8_t set_get )reentrant;
typedef int (*setGet_ConfigGpio_Event_fpt)(void*, uint8_t data_input, uint8_t set_get )reentrant;
typedef struct{
void *DataGpio;
void *SettingsGpio;
setGet_DataGpio_Event_fpt setGetDataIO_event;
setGet_ConfigGpio_Event_fpt setGetConfigIO_event;
lcd_hd44780_bitmode bit_mode;
uint8_t port_data;
uint8_t port_settings;
}lcd_hd44780_t;
void lcd_hd44780_init(lcd_hd44780_t *inst,lcd_hd44780_bitmode bit_mode);
void lcd_hd44780_regConfigEvt(lcd_hd44780_t *inst , void *inst_Config, setGet_ConfigGpio_Event_fpt getConfigEvt_fpt);
void lcd_hd44780_regDataEvt(lcd_hd44780_t *inst , void *inst_Data, setGet_DataGpio_Event_fpt getDataEvt_fpt);
#endif /*LCD_HD44780_H_*/