Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2010
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. //-------------------------------------------------------------------------------------------------
  2. // Wyświetlacz alfanumeryczny ze sterownikiem HD44780
  3. // Sterowanie w trybie 4-bitowym bez odczytu flagi zajętości
  4. // z dowolnym przypisaniem sygnałów sterujących
  5. // Plik : HD44780.h
  6. // Mikrokontroler : Atmel AVR
  7. // Kompilator : avr-gcc
  8. // Autor : Radosław Kwiecień
  9. // Źródło : http://radzio.dxp.pl/hd44780/
  10. // Data : 24.03.2007
  11. //-------------------------------------------------------------------------------------------------
  12.  
  13. #include <avr/io.h>
  14. #include <util/delay.h>
  15.  
  16. //-------------------------------------------------------------------------------------------------
  17. //
  18. // Konfiguracja sygnałów sterujących wyświetlaczem.
  19. // Można zmienić stosownie do potrzeb.
  20. //
  21. //-------------------------------------------------------------------------------------------------
  22. #define LCD_RS_DIR DDRD
  23. #define LCD_RS_PORT PORTD
  24. #define LCD_RS_PIN PIND
  25. #define LCD_RS (1 << PD0)
  26.  
  27. #define LCD_RW_DIR DDRD
  28. #define LCD_RW_PORT PORTD
  29. #define LCD_RW_PIN PIND
  30. #define LCD_RW (1 << PD1)
  31.  
  32. #define LCD_E_DIR DDRD
  33. #define LCD_E_PORT PORTD
  34. #define LCD_E_PIN PIND
  35. #define LCD_E (1 << PD2)
  36.  
  37. #define LCD_DB4_DIR DDRB
  38. #define LCD_DB4_PORT PORTB
  39. #define LCD_DB4_PIN PINB
  40. #define LCD_DB4 (1 << PB4)
  41.  
  42. #define LCD_DB5_DIR DDRB
  43. #define LCD_DB5_PORT PORTB
  44. #define LCD_DB5_PIN PINB
  45. #define LCD_DB5 (1 << PB5)
  46.  
  47. #define LCD_DB6_DIR DDRB
  48. #define LCD_DB6_PORT PORTB
  49. #define LCD_DB6_PIN PINB
  50. #define LCD_DB6 (1 << PB6)
  51.  
  52. #define LCD_DB7_DIR DDRB
  53. #define LCD_DB7_PORT PORTB
  54. #define LCD_DB7_PIN PINB
  55. #define LCD_DB7 (1 << PB7)
  56.  
  57. //-------------------------------------------------------------------------------------------------
  58. //
  59. // Instrukcje kontrolera Hitachi HD44780
  60. //
  61. //-------------------------------------------------------------------------------------------------
  62.  
  63. #define HD44780_CLEAR 0x01
  64.  
  65. #define HD44780_HOME 0x02
  66.  
  67. #define HD44780_ENTRY_MODE 0x04
  68. #define HD44780_EM_SHIFT_CURSOR 0
  69. #define HD44780_EM_SHIFT_DISPLAY 1
  70. #define HD44780_EM_DECREMENT 0
  71. #define HD44780_EM_INCREMENT 2
  72.  
  73. #define HD44780_DISPLAY_ONOFF 0x08
  74. #define HD44780_DISPLAY_OFF 0
  75. #define HD44780_DISPLAY_ON 4
  76. #define HD44780_CURSOR_OFF 0
  77. #define HD44780_CURSOR_ON 2
  78. #define HD44780_CURSOR_NOBLINK 0
  79. #define HD44780_CURSOR_BLINK 1
  80.  
  81. #define HD44780_DISPLAY_CURSOR_SHIFT 0x10
  82. #define HD44780_SHIFT_CURSOR 0
  83. #define HD44780_SHIFT_DISPLAY 8
  84. #define HD44780_SHIFT_LEFT 0
  85. #define HD44780_SHIFT_RIGHT 4
  86.  
  87. #define HD44780_FUNCTION_SET 0x20
  88. #define HD44780_FONT5x7 0
  89. #define HD44780_FONT5x10 4
  90. #define HD44780_ONE_LINE 0
  91. #define HD44780_TWO_LINE 8
  92. #define HD44780_4_BIT 0
  93. #define HD44780_8_BIT 16
  94.  
  95. #define HD44780_CGRAM_SET 0x40
  96.  
  97. #define HD44780_DDRAM_SET 0x80
  98.  
  99. //-------------------------------------------------------------------------------------------------
  100. //
  101. // Deklaracje funkcji
  102. //
  103. //-------------------------------------------------------------------------------------------------
  104.  
  105. void LCD_WriteCommand(unsigned char);
  106. unsigned char LCD_ReadStatus(void);
  107. void LCD_WriteData(unsigned char);
  108. unsigned char LCD_ReadData(void);
  109. void LCD_WriteText(char *);
  110. void LCD_GoTo(unsigned char, unsigned char);
  111. void LCD_Clear(void);
  112. void LCD_Home(void);
  113. void LCD_Initalize(void);
  114. void LCD_ProgrammChar(unsigned char nr, unsigned char znak[]);
  115.  
  116. //-------------------------------------------------------------------------------------------------
  117. //
  118. // Koniec pliku HD44780.h
  119. //
  120. //-------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement