82 lines
1.7 KiB
C
82 lines
1.7 KiB
C
#include "lcd_hd44780.h"
|
|
#include <stddef.h>
|
|
void lcd_hd44780_writeToDisp(lcd_hd44780_t *inst){
|
|
|
|
inst->setGetGpio_event(&(inst->gpio_data),LCD_HD44780_SET);
|
|
}
|
|
/*
|
|
void lcd_hd44780_clearDisp(lcd_hd44780_t *inst){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
void lcd_hd44780_printf(lcd_hd44780_t *inst, char *string){
|
|
|
|
return;
|
|
|
|
}*/
|
|
|
|
static void lcd_writeCmd_disp(lcd_hd44780_t *inst, hd44780_cmd_t cmd, hd44780_setGet_t getSet){
|
|
|
|
inst->gpio_data.data_bus = cmd;
|
|
|
|
|
|
inst->gpio_data.rw_pin = getSet;
|
|
|
|
// We want to write an instruction.
|
|
inst->gpio_data.rs_pin = LCD_HD44780_INSTRUCTION;
|
|
|
|
// E pin is sopposed to be zero when data is ready on port.
|
|
inst->gpio_data.e_pin = 0;
|
|
|
|
inst->setGetGpio_event(&(inst->gpio_data),getSet);
|
|
|
|
// Then Clock data in with E pin:
|
|
inst->gpio_data.e_pin = 1;
|
|
|
|
inst->setGetGpio_event(&(inst->gpio_data),getSet);
|
|
|
|
// Then Clock data in with E pin:
|
|
inst->gpio_data.e_pin = 0;
|
|
|
|
inst->setGetGpio_event(&(inst->gpio_data),getSet);
|
|
|
|
|
|
}
|
|
|
|
void lcd_hd44780_regGpioEvt(lcd_hd44780_t *inst, setGet_Gpio_Event_fpt getGpioEvt_fpt){
|
|
|
|
//if(inst == NULL)return;
|
|
|
|
inst->setGetGpio_event = getGpioEvt_fpt;
|
|
}
|
|
|
|
void lcd_hd44780_regWaitEvt(lcd_hd44780_t *inst, wait_ms_Event_fpt waitEvt_fpt){
|
|
|
|
//if(inst == NULL)return;
|
|
|
|
inst->wait_event = waitEvt_fpt;
|
|
}
|
|
|
|
|
|
void lcd_hd44780_init(lcd_hd44780_t *inst, lcd_hd44780_bitmode bit_mode){
|
|
|
|
//inst->gpio_data = 0x00;
|
|
inst->bit_mode = bit_mode;
|
|
|
|
inst->gpio_data.data_bus = 0x0;
|
|
inst->gpio_data.e_pin = 0x0;
|
|
inst->gpio_data.rs_pin = 0x1;
|
|
inst->gpio_data.rw_pin = 0x0;
|
|
|
|
inst->setGetGpio_event(&(inst->gpio_data), 1);
|
|
|
|
|
|
lcd_writeCmd_disp(inst,LCD_HD44780_CLEAR_DISP,LCD_HD44780_SET);
|
|
//lcd_writeCmd_disp(inst,LCD_HD44780_DISP_ONOFF_CTL,LCD_HD44780_SET);
|
|
|
|
return;
|
|
}
|
|
|