/[H8]/trunk/PIC/Demo trimmet/xlcd.h
ViewVC logotype

Contents of /trunk/PIC/Demo trimmet/xlcd.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91 - (show annotations) (download)
Tue May 8 09:37:15 2007 UTC (17 years ago) by hedin
File MIME type: text/plain
File size: 6350 byte(s)
added tcp/ip stack demo, trimmed.
1 /*********************************************************************
2 *
3 * External LCD access routines defs
4 *
5 *********************************************************************
6 * FileName: XLCD.h
7 * Dependencies: compiler.h
8 * Processor: PIC18
9 * Complier: MCC18 v1.00.50 or higher
10 * HITECH PICC-18 V8.10PL1 or higher
11 * Company: Microchip Technology, Inc.
12 *
13 * Software License Agreement
14 *
15 * The software supplied herewith by Microchip Technology Incorporated
16 * (the “Company”) for its PICmicro® Microcontroller is intended and
17 * supplied to you, the Company’s customer, for use solely and
18 * exclusively on Microchip PICmicro Microcontroller products. The
19 * software is owned by the Company and/or its supplier, and is
20 * protected under applicable copyright laws. All rights are reserved.
21 * Any use in violation of the foregoing restrictions may subject the
22 * user to criminal sanctions under applicable laws, as well as to
23 * civil liability for the breach of the terms and conditions of this
24 * license.
25 *
26 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
27 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
28 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
29 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
30 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
31 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
32 *
33 * Author Date Comment
34 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 * Nilesh Rajbharti 5/8/02 Original (Rev 1.0)
36 * Nilesh Rajbharti 7/10/02 Improved
37 ********************************************************************/
38 #ifndef __XLCD_H
39 #define __XLCD_H
40
41 #include "compiler.h"
42
43
44 /* XLCD peripheral routines.
45 *
46 * Notes:
47 * - These libraries routines are written to support the
48 * Hitachi HD44780 LCD controller.
49 * - The user must define the following items:
50 * - The LCD interface type (4- or 8-bits)
51 * - If 4-bit mode
52 * - whether using the upper or lower nibble
53 * - The data port
54 * - The tris register for data port
55 * - The control signal ports and pins
56 * - The control signal port tris and pins
57 * - The user must provide three delay routines:
58 * - DelayFor18TCY() provides a 18 Tcy delay
59 * - DelayPORXLCD() provides at least 15ms delay
60 * - DelayXLCD() provides at least 5ms delay
61 */
62
63 /* Interface type 8-bit or 4-bit
64 * For 8-bit operation uncomment the #define BIT8
65 */
66
67 /* When in 4-bit interface define if the data is in the upper
68 * or lower nibble. For lower nibble, comment the #define UPPER
69 */
70 //#define UPPER
71
72 /* DATA_PORT defines the port to which the LCD data lines are connected */
73
74 #define DATA_PORT PORTD
75 #define TRIS_DATA_PORT TRISD
76
77 /*
78 * Uncomment this line if non-blocking functions are desired.
79 * If following line is commented, caller must make sure that
80 * XLCD is free ( !XLCDIsBusy() )before calling any get/put commands.
81 */
82 #define XLCD_IS_BLOCKING
83
84 /*
85 * Comment following line if there is no read back capability
86 * for this LCD.
87 */
88 #define XLCD_READ_BACK
89
90 /*
91 * Uncomment following line if you want to read data from LCD
92 */
93 //#define XLCD_ENABLE_LCD_READS
94
95 /*
96 * Set your LCD type.
97 */
98 #define XCLD_TYPE (FOUR_BIT & LINES_5X8)
99
100 /*
101 * This is how LCD will be setup on Init.
102 */
103 #define XLCD_DISPLAY_SETUP (CURSOR_OFF & BLINK_OFF)
104
105 /*
106 * Uncomment following line if LCD data is to be read back.
107 */
108 //#define XLCD_ENABLE_LCD_READS
109
110 /* CTRL_PORT defines the port where the control lines are connected.
111 * These are just samples, change to match your application.
112 */
113
114 #define RW_PIN PORTD_RD5 /* PORT for RW */
115 #define TRIS_RW TRISD_RD5 /* TRIS for RW */
116 #define RS_PIN PORTD_RD4 /* PORT for RS */
117 #define TRIS_RS TRISD_RD4 /* TRIS for RS */
118 #define E_PIN PORTA_RA5 /* PORT for E */
119 #define TRIS_E TRISA_RA5 /* TRIS for E */
120
121 /* Display ON/OFF Control defines */
122 #define DON 0b00001111 /* Display on */
123 #define DOFF 0b00001011 /* Display off */
124 #define CURSOR_ON 0b00001111 /* Cursor on */
125 #define CURSOR_OFF 0b00001101 /* Cursor off */
126 #define BLINK_ON 0b00001111 /* Cursor Blink */
127 #define BLINK_OFF 0b00001110 /* Cursor No Blink */
128
129 /* Cursor or Display Shift defines */
130 #define SHIFT_CUR_LEFT 0b00010011 /* Cursor shifts to the left */
131 #define SHIFT_CUR_RIGHT 0b00010111 /* Cursor shifts to the right */
132 #define SHIFT_DISP_LEFT 0b00011011 /* Display shifts to the left */
133 #define SHIFT_DISP_RIGHT 0b00011111 /* Display shifts to the right */
134 #define DISP_CLEAR 0b00000001
135
136 /* Function Set defines */
137 #define FOUR_BIT 0b00101111 /* 4-bit Interface */
138 #define EIGHT_BIT 0b00111111 /* 8-bit Interface */
139 #define LINE_5X7 0b00110011 /* 5x7 characters, single line */
140 #define LINE_5X10 0b00110111 /* 5x10 characters */
141 #define LINES_5X7 0b00111111 /* 5x7 characters, multiple line */
142 #define LINES_5X8 0b00111000 /* 5x8 characters, multiple line */
143
144
145 void XLCDInit(void);
146 void XLCDPut(char data);
147 void XLCDPutString(char *string);
148 void XLCDPutROMString(ROM char *string);
149 char XLCDIsBusy(void);
150 void XLCDCommand(unsigned char cmd);
151 unsigned char XLCDGetAddr(void);
152 char XLCDGet(void);
153
154 #define XLCDGoto(row, col) XLCDCommand((col + (row * 0x40)) | 0x80)
155 #define XLCDClear() XLCDCommand(DISP_CLEAR)
156 #define XLCDCursorRight() XLCDCommand(SHIFT_CUR_RIGHT)
157 #define XLCDCursorLeft() XLCDCommand(SHIFT_CUR_LEFT)
158 #define XLCDShiftLeft() XLCDCommand(SHIFT_DISP_LEFT)
159 #define XLCDShiftRight() XLCDCommand(SHIFT_DISP_RIGHT)
160
161 #define XLCDCGRAMAddr(addr) XLCDCommand(addr | 0b01000000)
162 #define XLCDDDRAMAddr(addr) XLCDCommand(addr | 0b10000000)
163
164 /* User defines these routines/macros according to the oscillator frequency */
165 #define XLCDDelay500ns() XLCDDelay100us()
166
167 void XLCDDelay15ms(void);
168 void XLCDDelay4ms(void);
169 void XLCDDelay100us(void);
170
171 #endif

  ViewVC Help
Powered by ViewVC 1.1.20