1
0

HD44780.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //-------------------------------------------------------------------------------------------------
  2. // Wyœwietlacz alfanumeryczny ze sterownikiem HD44780
  3. // Sterowanie w trybie 8-bitowym z odczytem flagi zajêtoœci
  4. // Plik : HD44780.h
  5. // Mikrokontroler : Atmel AVR
  6. // Kompilator : avr-gcc
  7. // Autor : Rados³aw Kwiecieñ
  8. // �ród³o : http://radzio.dxp.pl/hd44780/
  9. // Data : 24.03.2007
  10. //-------------------------------------------------------------------------------------------------
  11. #include <avr/io.h>
  12. #include <util/delay.h>
  13. #include "expander.h"
  14. //-------------------------------------------------------------------------------------------------
  15. //
  16. // Konfiguracja sygna³ów steruj¹cych wyœwietlaczem.
  17. // Mo¿na zmieniæ stosownie do potrzeb.
  18. //
  19. //-------------------------------------------------------------------------------------------------
  20. #define LCD_RS_PORT 1
  21. #define LCD_RS (1 << 3)
  22. #define LCD_RW_PORT 1
  23. #define LCD_RW (1 << 2)
  24. #define LCD_E_PORT 1
  25. #define LCD_E (1 << 1)
  26. #define LCD_DATA_OUTPUT() expander_set_dir(0, 0x00, 0x00)
  27. #define LCD_DATA_INPUT() expander_set_dir(0, 0xFF, 0x00)
  28. //-------------------------------------------------------------------------------------------------
  29. //
  30. // Instrukcje kontrolera Hitachi HD44780
  31. //
  32. //-------------------------------------------------------------------------------------------------
  33. #define HD44780_CLEAR 0x01
  34. #define HD44780_HOME 0x02
  35. #define HD44780_ENTRY_MODE 0x04
  36. #define HD44780_EM_SHIFT_CURSOR 0
  37. #define HD44780_EM_SHIFT_DISPLAY 1
  38. #define HD44780_EM_DECREMENT 0
  39. #define HD44780_EM_INCREMENT 2
  40. #define HD44780_DISPLAY_ONOFF 0x08
  41. #define HD44780_DISPLAY_OFF 0
  42. #define HD44780_DISPLAY_ON 4
  43. #define HD44780_CURSOR_OFF 0
  44. #define HD44780_CURSOR_ON 2
  45. #define HD44780_CURSOR_NOBLINK 0
  46. #define HD44780_CURSOR_BLINK 1
  47. #define HD44780_DISPLAY_CURSOR_SHIFT 0x10
  48. #define HD44780_SHIFT_CURSOR 0
  49. #define HD44780_SHIFT_DISPLAY 8
  50. #define HD44780_SHIFT_LEFT 0
  51. #define HD44780_SHIFT_RIGHT 4
  52. #define HD44780_FUNCTION_SET 0x20
  53. #define HD44780_FONT5x7 0
  54. #define HD44780_FONT5x10 4
  55. #define HD44780_ONE_LINE 0
  56. #define HD44780_TWO_LINE 8
  57. #define HD44780_4_BIT 0
  58. #define HD44780_8_BIT 16
  59. #define HD44780_CGRAM_SET 0x40
  60. #define HD44780_DDRAM_SET 0x80
  61. //-------------------------------------------------------------------------------------------------
  62. //
  63. // Deklaracje funkcji
  64. //
  65. //-------------------------------------------------------------------------------------------------
  66. void LCD_WriteCommand(unsigned char);
  67. unsigned char LCD_ReadStatus(void);
  68. void LCD_WriteData(unsigned char);
  69. unsigned char LCD_ReadData(void);
  70. void LCD_WriteText(const char *);
  71. void LCD_GoTo(unsigned char, unsigned char);
  72. void LCD_Clear(void);
  73. void LCD_Home(void);
  74. void LCD_Initalize(void);
  75. void LCD_WriteTextP(const char *);
  76. //-------------------------------------------------------------------------------------------------
  77. //
  78. // Koniec pliku HD44780.h
  79. //
  80. //-------------------------------------------------------------------------------------------------