some progress on 4 bit mode.. but doesnt work
This commit is contained in:
@@ -28,6 +28,32 @@ void lcd_hd44780_printf(lcd_hd44780_t *inst, char *string){
|
||||
|
||||
}*/
|
||||
|
||||
static int WaitUntilReady(cm_lcd_hd44780_t *inst){
|
||||
|
||||
// If display is init, then use Polling Busy Flag!
|
||||
if(inst->isInit){
|
||||
// RS = 0, RW = 1
|
||||
inst->gpio_data.rs_pin = 0;
|
||||
inst->gpio_data.rw_pin = 1;
|
||||
|
||||
// Read from the data bus
|
||||
inst->setGetGpio_event(&(inst->gpio_data), LCD_HD44780_GET);
|
||||
|
||||
// Loop until Busy Flag (D7) is clear
|
||||
while (inst->gpio_data.data_bus & 0x80) {
|
||||
inst->setGetGpio_event(&(inst->gpio_data), LCD_HD44780_GET);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}else{
|
||||
inst->wait_event(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static int lcd_write_8bit(cm_lcd_hd44780_t *inst, uint8_t dataOrCmd, hd44780_InstData_t mode){
|
||||
|
||||
// Set cmd on databus
|
||||
@@ -41,13 +67,15 @@ static int lcd_write_8bit(cm_lcd_hd44780_t *inst, uint8_t dataOrCmd, hd44780_Ins
|
||||
|
||||
// E pin must be high when data is not ready yet.
|
||||
inst->gpio_data.e_pin = 1;
|
||||
|
||||
inst->setGetGpio_event(&(inst->gpio_data),LCD_HD44780_SET);
|
||||
|
||||
// Then Clock data in with E pin. Data is clocked on Falling edge:
|
||||
inst->gpio_data.e_pin = 0;
|
||||
inst->setGetGpio_event(&(inst->gpio_data),LCD_HD44780_SET);
|
||||
|
||||
// Wait until display is ready:
|
||||
WaitUntilReady(inst);
|
||||
|
||||
// Then set E pin high so its ready for next time:
|
||||
inst->gpio_data.e_pin = 1;
|
||||
inst->setGetGpio_event(&(inst->gpio_data),LCD_HD44780_SET);
|
||||
@@ -66,9 +94,9 @@ static void lcd_writeCmd_disp(cm_lcd_hd44780_t *inst, hd44780_cmd_t cmd, hd44780
|
||||
}else{
|
||||
|
||||
// Write MSB first.
|
||||
lcd_write_8bit(inst, (cmd >> 4) & 0xf, LCD_HD44780_INSTRUCTION);
|
||||
lcd_write_8bit(inst, ((cmd >> 4) & 0x0F) << 4, LCD_HD44780_INSTRUCTION);
|
||||
// Write LSB last.
|
||||
lcd_write_8bit(inst, cmd & 0xf, LCD_HD44780_INSTRUCTION);
|
||||
lcd_write_8bit(inst, (cmd & 0x0F) << 4, LCD_HD44780_INSTRUCTION);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,7 +122,8 @@ void lcd_hd44780_initDisp(cm_lcd_hd44780_t *inst){
|
||||
|
||||
lcd_writeCmd_disp(inst, LCD_HD44780_ENTRY_MODE,LCD_HD44780_SET);
|
||||
|
||||
|
||||
// Init has been done, and we can now use Busy Flag polling instead of delay!
|
||||
inst->isInit = 0x1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ typedef struct{
|
||||
wait_ms_Event_fpt wait_event;
|
||||
lcd_hd44780_bitmode bit_mode;
|
||||
hd44780_gpioset_t gpio_data;
|
||||
// Flag for showing that init has been done.. After init im using polling Busy Flag instead of delay..
|
||||
uint8_t isInit;
|
||||
|
||||
|
||||
}cm_lcd_hd44780_t;
|
||||
|
||||
Reference in New Issue
Block a user