1 | #ifndef __HW_LCD_H__
|
2 | #define __HW_LCD_H__
|
3 |
|
4 |
|
5 | /*****************************************/
|
6 | /************** Definitions **************/
|
7 | /*****************************************/
|
8 | // Control Signal Data Pins
|
9 | #define LCD_RS LATDbits.LATD8 // LCD RS signal
|
10 | #define LCD_RW LATDbits.LATD9 // LCD R/W signal
|
11 | #define LCD_1_EN LATDbits.LATD10 // LCD_1 E signal
|
12 | #define LCD_2_EN LATDbits.LATD10 // LCD_1 E signal
|
13 | #define LCD_3_EN LATDbits.LATD10 // LCD_1 E signal
|
14 |
|
15 | // LCD Addresses
|
16 | #define LCD_START_LINE1 0x00
|
17 | #define LCD_START_LINE2 0x40
|
18 | #define LCD_START_LINE3 0x14
|
19 | #define LCD_START_LINE4 0x54
|
20 |
|
21 | // Data Signals and Pin Direction
|
22 | #define LCD_DATA LATD // Port for LCD data
|
23 | #define LCD_IO_CNTRL TRISD
|
24 |
|
25 | // LCD Maximum Positions (beginning with 0)
|
26 | #define LCD_MAX_Y 1
|
27 | #define LCD_MAX_X 15
|
28 |
|
29 | // Lines (beginning with 0)
|
30 | #define LINE1 0
|
31 | #define LINE2 1
|
32 | #define LINE3 2
|
33 | #define LINE4 3
|
34 |
|
35 | // PutStr-Controls
|
36 | #define CONTINOUS 0
|
37 | #define LIMITED 1
|
38 |
|
39 | // Structure LCD Line
|
40 | typedef struct {
|
41 | unsigned char X;
|
42 | unsigned char Y;
|
43 | }TYPE_LCD_CURSORS;
|
44 |
|
45 | // Structure LC-Display
|
46 | typedef struct {
|
47 | TYPE_LCD_CURSORS Cursor;
|
48 | unsigned int En :1;
|
49 | unsigned int ID :3;
|
50 | unsigned :4;
|
51 | }TYPE_LC_DISPLAY;
|
52 |
|
53 |
|
54 |
|
55 | /*****************************************/
|
56 | /*********** Global Variables ************/
|
57 | /*****************************************/
|
58 |
|
59 |
|
60 |
|
61 | /*****************************************/
|
62 | /********** Function Prototypes **********/
|
63 | /*****************************************/
|
64 |
|
65 | // Macros
|
66 | /***** LCD COMMAND FUCNTION PROTOTYPES *****/
|
67 | #define __hw_LCD_Cursor_R(lcd) hw_Cmd_LCD (0x0014, lcd)
|
68 | #define __hw_LCD_Cursor_L(lcd) hw_Cmd_LCD (0x0010, lcd)
|
69 | #define __hw_LCD_Cursor_Invisible(lcd) hw_Cmd_LCD (0x000C, lcd)
|
70 | #define __hw_LCD_Cursor_Underline(lcd) hw_Cmd_LCD (0x000E, lcd)
|
71 | #define __hw_LCD_Display_Shift(lcd) hw_Cmd_LCD (0x001C, lcd)
|
72 | #define __hw_LCD_Display_Blank(lcd) hw_Cmd_LCD (0x0008, lcd)
|
73 | #define __hw_LCD_Home_Clr(lcd) hw_Cmd_LCD (0x0001, lcd)
|
74 | #define __hw_LCD_Home_It(lcd) hw_Cmd_LCD (0x0002, lcd)
|
75 | #define __hw_LCD_Line_2(lcd) hw_Cmd_LCD (0x00C0, lcd)
|
76 | #define __hw_LCD_Scroll_R_All(lcd) hw_Cmd_LCD (0x001E, lcd)
|
77 | #define __hw_LCD_Scroll_L_All(lcd) hw_Cmd_LCD (0x0018, lcd)
|
78 | #define __hw_LCD_Blinking_Block(lcd) hw_Cmd_LCD (0x000F, lcd)
|
79 |
|
80 |
|
81 | // Functions
|
82 | /****** LCD FUNCTION PROTOYPES ******/
|
83 | void hw_Open_LCD (TYPE_LC_DISPLAY *Lcd); // initialize display
|
84 | void hw_Cmd_LCD (unsigned int Cmd, TYPE_LC_DISPLAY *Lcd); // write command to lcd
|
85 | void hw_Data_LCD (unsigned int Data, TYPE_LC_DISPLAY *Lcd); // write data to lcd
|
86 | void hw_PutStr_LCD (unsigned int Op_Mode, unsigned char *Data, unsigned int Chars_to_Put, TYPE_LC_DISPLAY *Lcd);
|
87 | void hw_Enable_LCD (TYPE_LC_DISPLAY *Lcd);
|
88 | void hw_Disable_LCD (TYPE_LC_DISPLAY *Lcd);
|
89 | void hw_RegisterID_LCD (TYPE_LC_DISPLAY *Lcd, unsigned int LCD_Nr);
|
90 | void hw_Gotoxy_LCD (unsigned char X, unsigned char Y, TYPE_LC_DISPLAY *Lcd);
|
91 | void hw_Clear_LCD (TYPE_LC_DISPLAY *Lcd);
|
92 | int hw_ReadBusyFlag_LCD (TYPE_LC_DISPLAY *Lcd);
|
93 |
|
94 |
|
95 | #endif //__HW_LCD_H__
|