I have written my own HD44780 display functions that do everything I want to do except it usees delays to compensate for the AVR being much faster than the LCD. Everything in my code so far seems to work solidly in both 8-bit and 4-bit mode.
I would like to replace the delays with a function that can be called that waits for the Busy Flag to clear and/or possibly returns the BF.
If it returned the reading of the BF and my own code would use it to delay the program until it clears or display the BF reading on a PORT Pin or something else with it.
All the code I have seen so far needs a lot of other code to set this up and execute. So long as the function knows the data port and the three control pins this should be a simple function.
I'm thinking this could be the simple function:
Change the data port DDRx from output to input.
Clear the LCD RS pin and Set R/W pin.
Set the LCD E pin .
Read the LCD data port, PINx.
Clear the LCD E pin.
Change the data port DDRx back to output.
(Changing back to DDR out could be done elsewhere. However. this is the only place I believe I would ever read from the LCD so by putting it back to output I would not have to make sure of the direction many other times in code.)
I have seen code before that I'm sure does this. I have gone over it but understanding it was beyond me.